Ejemplo n.º 1
0
    def process_purchase(self,
                         transaction_total,
                         card_type,
                         card_number,
                         card_expiry,
                         card_cvv,
                         cardholder_name,
                         merchant_reference=''):

        request_body = make_request_body_for_purchase(transaction_total, card_type, card_number, card_expiry, card_cvv,
                                                      cardholder_name, merchant_reference)
        payload = json.dumps(request_body)

        purchase = transactions.Transaction(self.api_key, self.api_secret, self.token, self.url, payload)
        purchase.run_transaction()

        return purchase
Ejemplo n.º 2
0
    def test_request_body_without_reference(self):
        request_body = make_request_body_for_purchase('2499', 'visa', '4005519200000004', '1019', '123',
                                                      'Donald Duck')
        expected_request_body = {
            "merchant_ref": '',
            "transaction_type": "purchase",
            "method": "credit_card",
            "amount": '2499',
            "partial_redemption": "false",
            "currency_code": "USD",
            "credit_card": {
                "type":  'visa',
                "cardholder_name": 'Donald Duck',
                "card_number": '4005519200000004',
                "exp_date": '1019',
                "cvv": '123'
            }
        }

        self.assertEqual(request_body, expected_request_body)
Ejemplo n.º 3
0
    def test_request_body_with_reference(self):
        request_body = make_request_body_for_purchase('2500', 'discover', '6510000000001248', '1020', '234',
                                                      'Daisy Duck', 'Sale ref')

        expected_request_body = {
            "merchant_ref": 'Sale ref',
            "transaction_type": "purchase",
            "method": "credit_card",
            "amount": '2500',
            "partial_redemption": "false",
            "currency_code": "USD",
            "credit_card": {
                "type":  'discover',
                "cardholder_name": 'Daisy Duck',
                "card_number": '6510000000001248',
                "exp_date": '1020',
                "cvv": '234'
            }
        }

        self.assertEqual(request_body, expected_request_body)
Ejemplo n.º 4
0
    def process_purchase(self,
                         transaction_total,
                         card_type,
                         card_number,
                         card_expiry,
                         card_cvv,
                         cardholder_name,
                         merchant_reference='',
                         billing_address_street='',
                         billing_address_city='',
                         billing_address_state_province='',
                         billing_address_country='',
                         billing_address_zip_postal_code='',
                         billing_address_email='',
                         billing_address_phone_type='',
                         billing_address_phone_number=''):
        # billing_address* parameters are optional for Payeezy API, however merchants who have turned on AVS check,
        # would require to provide "billing_address" object in the request payload.

        request_body = make_request_body_for_purchase(
            transaction_total, card_type, card_number, card_expiry, card_cvv,
            cardholder_name, merchant_reference, billing_address_street,
            billing_address_city, billing_address_state_province,
            billing_address_country, billing_address_zip_postal_code,
            billing_address_email, billing_address_phone_type,
            billing_address_phone_number)
        payload = json.dumps(request_body)
        # According to Payeezy Sandbox, response would contain "avs & token object" fields only if the merchant has
        # enabled AVS check and Token based services with Payeezy.
        # TODO How do we test it?

        purchase = transactions.Transaction(self.api_key, self.api_secret,
                                            self.token, self.url, payload)
        purchase.run_transaction()

        return purchase