Esempio n. 1
0
 def build_soap(self, xml_dict):
     #TODO build this up properly
     soap_payload = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <soapenv:Header>
             <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                 <wsse:UsernameToken>
                     <wsse:Username>%(merchant_id)s</wsse:Username>
                     <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%(api_key)s</wsse:Password>
                 </wsse:UsernameToken>
             </wsse:Security>
         </soapenv:Header>
         <soapenv:Body>
         %(body)s
         </soapenv:Body>
     </soapenv:Envelope>
     '''
     root = ET.Element('requestMessage')
     root.attrib['xmlns'] = self.namespace
     dicttoxml(xml_dict, root)
     body = ET.tostring(root)
     return soap_payload % {
         'merchant_id': self.merchant_id,
         'api_key': self.api_key,
         'body': body,
     }
 def __call__(self, url, msg, headers):
     if self.failure:
         return self.failure
     self.validate_request(msg)
     data = xmltodict(ET.fromstring(msg))
     response = self.receive(data)
     ret = ET.tostring(self.send(data, response))
     self.validate_response(ret)
     return ret
 def __call__(self, url, msg, headers):
     if self.failure:
         return self.failure
     self.validate_request(msg)
     data = xmltodict(ET.fromstring(msg))
     response = self.receive(data)
     ret = ET.tostring(self.send(data, response))
     self.validate_response(ret)
     return ret
 def __call__(self, url, msg, headers):
     if self.failure:
         return self.failure
     self.validate_request(msg)
     msg = msg.replace('xmlns="%s"' % self.namespace, '')
     data = xmltodict(ET.fromstring(msg))
     if '{http://schemas.xmlsoap.org/soap/envelope/}Body' in data:
         data = data['{http://schemas.xmlsoap.org/soap/envelope/}Body']['requestMessage']
     response = self.receive(data)
     ret = ET.tostring(self.send(data, response))
     self.validate_response(ret)
     return ret
 def __call__(self, url, msg, headers):
     if self.failure:
         return self.failure
     #self.validate_request(msg)
     msg = msg.replace('xmlns="%s"' % self.namespace, '')
     data = xmltodict(ET.fromstring(msg))
     if '{http://schemas.xmlsoap.org/soap/envelope/}Body' in data:
         data = data['{http://schemas.xmlsoap.org/soap/envelope/}Body']['requestMessage']
     response = self.receive(data)
     ret = ET.tostring(self.send(data, response))
     #self.validate_response(ret)
     return ret
Esempio n. 6
0
 def send(self, data, response):
     root = ET.Element('XMLPayResponse', {'xmlns':'http://www.paypal.com/XMLPay'})
     msg = {'ResponseData': {'Vendor':data['RequestData']['Vendor'],
                             'Partner':data['RequestData']['Partner'],
                             'TransactionResults': {'TransactionResult': response }}}
     dicttoxml(msg, root)
     return root
    def parse(self, soap):
        result = {}
        keys  = self.soap_keys()
        doc  = ET.fromstring(soap)

        for key in keys:
            nodes = doc.findall('.//' + key)
            result[key] = len(nodes) and nodes[0].text or None
        return result
 def parse(self, soap):
     doc  = xmltodict(ET.fromstring(soap))
     response_type = doc.keys()[0]
     response = doc[response_type]
     response_class = {'NewOrderResp':self.NewOrderResponse,
                       'ProfileResp':self.ProfileResponse,
                       'QuickResp':self.QuickResponse,
                       'ReversalResp':self.ReversalResponse,
                       'MarkForCaptureResp':self.NewOrderResponse,}[response_type]
     return response_class(self, response)
 def parse(self, soap):
     doc = xmltodict(ET.fromstring(soap))
     response_type = doc.keys()[0]
     response = doc[response_type]
     response_class = {
         'NewOrderResp': self.NewOrderResponse,
         'ProfileResp': self.ProfileResponse,
         'QuickResp': self.QuickResponse,
         'ReversalResp': self.ReversalResponse,
         'MarkForCaptureResp': self.NewOrderResponse,
     }[response_type]
     return response_class(self, response)
Esempio n. 10
0
 def build_soap(self, xml_dict):
     #TODO build this up properly
     soap_payload = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <soapenv:Header>
             <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                 <wsse:UsernameToken>
                     <wsse:Username>%(merchant_id)s</wsse:Username>
                     <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%(api_key)s</wsse:Password>
                 </wsse:UsernameToken>
             </wsse:Security>
         </soapenv:Header>
         <soapenv:Body>
         %(body)s
         </soapenv:Body>
     </soapenv:Envelope>
     '''
     root = ET.Element('requestMessage')
     root.attrib['xmlns'] = self.namespace
     dicttoxml(xml_dict, root)
     body = ET.tostring(root)
     return soap_payload % {'merchant_id': self.merchant_id,
                            'api_key': self.api_key,
                            'body': body,}
 def send(self, data, response):
     root = ET.Element('Response')
     dicttoxml(response, root)
     return root
Esempio n. 12
0
 def send(self, data, response):
     root = ET.Element('replyMessage')
     root.attrib['xmlns'] = self.namespace
     dicttoxml(response, root)
     return root
Esempio n. 13
0
 def __call__(self, url, msg, headers):
     msg = msg.replace('xmlns="http://www.paypal.com/XMLPay"', '') #arghhh, don't care to deal with namespaces
     data = xmltodict(ET.fromstring(msg))
     response = self.receive(data)
     return ET.tostring(self.send(data, response))