Ejemplo n.º 1
0
    def process(self):
    
        tree = etree.parse(BytesIO(self.data))
        #print(etree.tostring(tree, pretty_print=True))
        error_code = tree.find('errorCode')
        if error_code is not None and error_code.text != '0':
            error_message = tree.find('errorMessage')
            if error_message is None:
                error_message = tree.find('errorMsg')

            if error_message is not None:
                error_message = error_message.text
            
            raise PaymentException(message=error_message)

        fields = [
            ('errorCode', 'processor_code'),
            ('errorMessage', 'error_message'),
            ('command', 'acao'),
            ('time', 'transaction_timestamp'),
            ('result', 'processor_message')
        ]

        for f_name, f_translated in fields:
            field = tree.find(f_name)
            if field is not None:
                setattr(self, f_translated, field.text)
Ejemplo n.º 2
0
    def process(self):

        tree = etree.parse(BytesIO(self.data))
        error_code = tree.find('errorCode')

        fields = [('errorCode', 'processor_code'),
                  ('errorMessage', 'error_message'),
                  ('time', 'transaction_timestamp'),
                  ('result', 'processor_message')]

        for f_name, f_translated in fields:
            field = tree.find(f_name)
            if field is not None:
                setattr(self, f_translated, field.text)
Ejemplo n.º 3
0
    def process(self):
        tree = etree.parse(BytesIO(self.data))

        error_code = tree.find('errorCode').text

        if error_code != '0':
            error_message = tree.find('errorMessage').text

            raise CardException(message=error_message, code=error_code)

        self._meta = {
            'command': tree.find('command').text,
            'time': tree.find('time').text,
        }

        self.token = tree.find('result').find('token').text
Ejemplo n.º 4
0
    def process(self):
        tree = etree.parse(StringIO(self.data))

        error_code = tree.find('errorCode').text

        if error_code != '0':
            error_message = tree.find('errorMessage').text

            raise CustomerException(message=error_message)

        self._meta = {
            'command': tree.find('command').text,
            'time': tree.find('time').text,
        }

        self.success = True
Ejemplo n.º 5
0
    def process(self):
        tree = etree.parse(StringIO(self.data))

        error_code = tree.find('errorCode').text

        if error_code != '0':
            error_message = tree.find('errorMessage').text

            raise CardException(message=error_message, code=error_code)

        self._meta = {
            'command': tree.find('command').text,
            'time': tree.find('time').text,
        }

        self.token = tree.find('result').find('token').text
Ejemplo n.º 6
0
    def process(self):
        tree = etree.parse(StringIO(self.data))

        error_code = tree.find('errorCode').text

        if error_code != '0':
            error_message = tree.find('errorMessage').text

            raise CustomerException(message=error_message, code=error_code)

        self._meta = {
            'command': tree.find('command').text,
            'time': tree.find('time').text,
        }

        self.success = True
Ejemplo n.º 7
0
    def process(self):
        self.approved = False
        self.authorized = False
        self.captured = False

        tree = etree.parse(BytesIO(self.data))
        error_code = tree.find('errorCode')
        if error_code is not None and error_code.text != '0':
            error_message = tree.find('errorMsg').text
            raise PaymentException(message=error_message, code=error_code)

        processor_code = tree.find('processorCode')

        if processor_code.text is not None and processor_code.text.lower(
        ) == 'a':
            self.approved = True

        if self.approved:
            response_message = tree.find('transactionID')

        fields = [
            ('transactionID', 'transaction_id'),
            ('authCode', 'auth_code'),
            ('orderID', 'order_id'),
            ('referenceNum', 'reference_num'),
            ('transactionTimestamp', 'transaction_timestamp'),
            ('boletoUrl', 'boleto_url'),
            ('responseCode', 'response_code'),
        ]

        for f_name, f_translated in fields:
            field = tree.find(f_name)
            if field is not None:
                setattr(self, f_translated, field.text)

        response_message = tree.find('responseMessage')
        if response_message is not None and response_message.text:
            response_message = response_message.text.lower()

            if response_message == 'authorized':
                self.authorized = True
            elif response_message == 'captured':
                self.authorized = True
                self.captured = True
            elif response_message == 'issued':
                self.authorized = True
Ejemplo n.º 8
0
    def process(self):
        self.approved = False
        self.authorized = False
        self.captured = False

        tree = etree.parse(StringIO(self.data))
        error_code = tree.find('errorCode')
        if error_code is not None and error_code.text != '0':
            error_message = tree.find('errorMsg').text
            raise PaymentException(message=error_message, code=error_code)

        processor_code = tree.find('processorCode')

        if processor_code.text is not None and processor_code.text.lower() == 'a':
            self.approved = True

        if self.approved:
            response_message = tree.find('transactionID')

        fields = [
            ('transactionID', 'transaction_id'),
            ('authCode', 'auth_code'),
            ('orderID', 'order_id'),
            ('referenceNum', 'reference_num'),
            ('transactionTimestamp', 'transaction_timestamp'),
            ('boletoUrl', 'boleto_url'),
            ('responseCode', 'response_code'),
        ]

        for f_name, f_translated in fields:
            field = tree.find(f_name)
            if field is not None:
                setattr(self, f_translated, field.text)

        response_message = tree.find('responseMessage')
        if response_message is not None and response_message.text:
            response_message = response_message.text.lower()

            if response_message == 'authorized':
                self.authorized = True
            elif response_message == 'captured':
                self.authorized = True
                self.captured = True
            elif response_message == 'issued':
                self.authorized = True
Ejemplo n.º 9
0
    def process(self):
        tree = etree.parse(StringIO(self.data))

        error_code = tree.find('errorCode').text

        if error_code != '0':
            error_message = tree.find('errorMessage').text

            if 'already exists' in error_message.lower():
                raise CustomerAlreadyExists(message=error_message)

            raise CustomerException(message=error_message)

        self._meta = {
            'command': tree.find('command').text,
            'time': tree.find('time').text,
        }

        self.id = tree.find('result').find('customerId').text
    def process(self):
        tree = etree.parse(StringIO(self.data))

        error_code = tree.find('errorCode').text

        if error_code != '0':
            error_message = tree.find('errorMessage').text

            if 'already exists' in error_message.lower():
                raise CustomerAlreadyExists(message=error_message)

            raise CustomerException(message=error_message)

        self._meta = {
            'command': tree.find('command').text,
            'time': tree.find('time').text,
        }

        self.id = tree.find('result').find('customerId').text
Ejemplo n.º 11
0
    def process(self):
        self.approved = False
        self.authorized = False
        self.captured = False

        tree = etree.parse(StringIO(self.data))

        processor_code = tree.find('processorCode')
        if processor_code.text.lower() == 'a':
            self.approved = True

        if self.approved:
            response_message = tree.find('transactionID')

        fields = [
            ('transactionID', 'transaction_id'),
            ('authCode', 'auth_code'),
            ('orderID', 'order_id'),
            ('referenceNum', 'reference_num'),
            ('transactionTimestamp', 'transaction_timestamp'),
        ]

        for f_name, f_translated in fields:
            field = tree.find(f_name)
            if field is not None:
                setattr(self, f_translated, field.text)

        response_message = tree.find('responseMessage')
        if response_message is not None and response_message.text:
            response_message = response_message.text.lower()

            if response_message == 'authorized':
                self.authorized = True
            elif response_message == 'captured':
                self.authorized = True
                self.captured = True
Ejemplo n.º 12
0
    def process(self):
        self.approved = False
        self.authorized = False
        self.captured = False

        tree = etree.parse(StringIO(self.data))

        processor_code = tree.find('processorCode')
        if processor_code.text.lower() == 'a':
            self.approved = True

        if self.approved:
            response_message = tree.find('transactionID')

        fields = [
            ('transactionID', 'transaction_id'),
            ('authCode', 'auth_code'),
            ('orderID', 'order_id'),
            ('referenceNum', 'reference_num'),
            ('transactionTimestamp', 'transaction_timestamp'),
        ]

        for f_name, f_translated in fields:
            field = tree.find(f_name)
            if field is not None:
                setattr(self, f_translated, field.text)

        response_message = tree.find('responseMessage')
        if response_message is not None and response_message.text:
            response_message = response_message.text.lower()

            if response_message == 'authorized':
                self.authorized = True
            elif response_message == 'captured':
                self.authorized = True
                self.captured = True
Ejemplo n.º 13
0
    def process(self):
        tree = etree.parse(BytesIO(self.data))

        header = tree.find('header')
        error_code = header.find('errorCode')

        if error_code is not None and error_code.text != '0':
            error_message = ''  #header.find('errorMsg').text
            print(etree.tostring(tree, pretty_print=False))
            raise PaymentException(message=error_message)

        result = tree.find('result')
        conf = result.find('resultSetInfo')

        self.pages = conf.find('totalNumberOfRecords').text if conf.find(
            'totalNumberOfRecords') is not None else 0
        self.page_number = conf.find('pageNumber').text if conf.find(
            'pageNumber') is not None else None
        self.page_token = conf.find('pageToken').text if conf.find(
            'pageToken') is not None else None
        self.items = []
        records = result.find('records')
        for element in records.iter('record'):
            #print(etree.tostring(element, pretty_print=False))
            #print('-----')
            fields = [('transactionId', 'transaction_id'),
                      ('referenceNummber', 'reference_num'),
                      ('transactionType', 'transaction_type'),
                      ('transactionAmount', 'transaction_amount'),
                      ('shippingAmount', 'shipping_amount'),
                      ('transactionDate', 'transaction_date'),
                      ('orderId', 'order_id'),
                      ('splitPaymentOrderId', 'split_payment_order_id'),
                      ('userId', 'user_id'), ('customerId', 'customer_id'),
                      ('companyName', 'company_name'),
                      ('responseCode', 'response_code'),
                      ('approvalCode', 'approval_code'),
                      ('paymentType', 'payment_type'),
                      ('bankRoutingNumber', 'bank_routing_number'),
                      ('achAccountNumber', 'ach_account_number'),
                      ('avsResponseCode', 'avs_response_code'),
                      ('billingAddress1', 'billing_address1'),
                      ('billingName', 'billing_name'),
                      ('billingAddress2', 'billing_address2'),
                      ('billingCity', 'billing_city'),
                      ('billingState', 'billing_state'),
                      ('billingCountry', 'billing_country'),
                      ('billingZip', 'billing_zip'),
                      ('billingPhone', 'billing_phone'),
                      ('billingEmail', 'billing_email'),
                      ('comments', 'comments'),
                      ('transactionStatus', 'transaction_status'),
                      ('transactionState', 'transaction_state'),
                      ('recurringPaymentFlag', 'recurring_payment_flag'),
                      ('processorReturnedData', 'processor_returned_data'),
                      ('gatewayDebitNetworkID', 'gateway_debit_network_id'),
                      ('creditCardType', 'credit_card_type'),
                      ('boletoUrl', 'boleto_url'),
                      ('boletoNumber', 'boleto_number'),
                      ('expirationDate', 'expiration_date'),
                      ('processorID', 'processor_id'),
                      ('dateOfPayment', 'date_of_payment'),
                      ('dateOfFunding', 'date_of_funding'),
                      ('bankOfPayment', 'bank_of_payment'),
                      ('branchOfPayment', 'branch_of_payment'),
                      ('paidAmount', 'paid_amount'), ('bankFee', 'bank_fee'),
                      ('netAmount', 'net_amount'),
                      ('returnCode', 'return_code'),
                      ('clearingCode', 'clearing_code'),
                      ('customField1', 'custom_field1'),
                      ('customField2', 'custom_field2'),
                      ('customField3', 'custom_field3'),
                      ('customField4', 'custom_field4'),
                      ('customField5', 'custom_field5'),
                      ('numberOfInstallments', 'number_of_installments'),
                      ('chargeInterest', 'charge_interest'),
                      ('processorTransactionID', 'processor_transaction_id'),
                      ('processorReferenceNumber',
                       'processor_reference_number')]
            item = {}
            for f_name, f_translated in fields:
                field = element.find(f_name)
                if field is not None:
                    item.update({f_translated: field.text})
            if item is not None:
                self.items.append(item)
Ejemplo n.º 14
0
    def process(self):
        self.approved = False
        self.authorized = False
        self.captured = False

        tree = etree.parse(BytesIO(self.data))
        error_code = tree.find('errorCode')
        if error_code is not None and error_code.text != '0':
            error_message = tree.find('errorMsg').text
            raise PaymentException(message=error_message)

        processor_code = tree.find('processorCode')

        if processor_code.text is not None and processor_code.text.lower(
        ) == 'a':
            self.approved = True

        if self.approved:
            response_message = tree.find('transactionID')

        fields = [
            ('transactionID', 'transaction_id'),
            ('authCode', 'auth_code'),
            ('orderID', 'order_id'),
            ('referenceNum', 'reference_num'),
            ('transactionTimestamp', 'transaction_timestamp'),
            ('boletoUrl', 'boleto_url'),
            ('processorCode', 'processor_code'),
            ('responseCode', 'response_code'),
            ('processorTransactionID', 'processor_transaction_id'),
            ('processorReferenceNumber', 'processor_reference_number'),
            ('errorMessage', 'error_message'),
            ('avsResponseCode', 'avs_response_code'),
            ('processorMessage', 'processor_message'),
            ('processorName', 'processor_name'),
            ('onlineDebitURL', 'online_debit_url'),
            ('authenticationURL', 'authentication_url'),
            ('creditCardBin', 'credit_card_bin'),
            ('creditCardLast4', 'credit_card_last_4'),
            ('creditCardCountry', 'credit_card_coutry'),
            ('creditCardScheme', 'credit_card_scheme'),
        ]

        for f_name, f_translated in fields:
            field = tree.find(f_name)
            if field is not None:
                setattr(self, f_translated, field.text)

        response_message = tree.find('responseMessage')

        if response_message is not None and response_message.text:
            response_message = response_message.text.lower()
            self.response_message = response_message

            if response_message == 'authorized':
                self.authorized = True
            elif response_message == 'captured':
                self.authorized = True
                self.captured = True
            elif response_message == 'issued':
                self.authorized = True