Ejemplo n.º 1
0
    def test_live_basic_credit_card(self):
        # Create a customer so that we can test payment creation against him
        result = Customer.create()
        customer_id = result.customer_id

        # Create a new credit card
        result = CreditCard.create(customer_id, CREDIT_CARD)
        payment_id = result.payment_id

        # Attempt to create a duplicate credit card entry. This will fail
        # since it is a duplicate payment method.
        self.assertRaises(AuthorizeResponseError, CreditCard.create,
                          customer_id, CREDIT_CARD)

        # Read credit card data
        result = CreditCard.details(customer_id, payment_id)
        self.assertEquals(PAYMENT_RESULT, result.payment_profile.payment)

        # Update credit card
        CreditCard.update(customer_id, payment_id, UPDATE_CREDIT_CARD)
        CreditCard.update(customer_id, payment_id,
                          UPDATE_CREDIT_CARD_WITH_MASK)
        CreditCard.update(customer_id, payment_id,
                          UPDATE_CREDIT_CARD_WITHOUT_MASK)

        # Invalid masked number
        self.assertRaises(AuthorizeResponseError, CreditCard.update,
                          customer_id, payment_id,
                          UPDATE_CREDIT_CARD_INVALID_MASK)

        # Delete tests
        CreditCard.delete(customer_id, payment_id)
        self.assertRaises(AuthorizeResponseError, CreditCard.delete,
                          customer_id, payment_id)
    def test_live_basic_credit_card(self):
        # Create a customer so that we can test payment creation against him
        result = Customer.create()
        customer_id = result.customer_id

        # Create a new credit card
        result = CreditCard.create(customer_id, CREDIT_CARD)
        payment_id = result.payment_id

        # Attempt to create a duplicate credit card entry. This will fail
        # since it is a duplicate payment method.
        self.assertRaises(AuthorizeResponseError, CreditCard.create, customer_id, CREDIT_CARD)

        # Read credit card data
        result = CreditCard.details(customer_id, payment_id)
        self.assertEquals(PAYMENT_RESULT, result.payment_profile.payment)

        # Update credit card
        CreditCard.update(customer_id, payment_id, UPDATE_CREDIT_CARD)
        CreditCard.update(customer_id, payment_id, UPDATE_CREDIT_CARD_WITH_MASK)
        CreditCard.update(customer_id, payment_id, UPDATE_CREDIT_CARD_WITHOUT_MASK)

        # Invalid masked number
        self.assertRaises(AuthorizeResponseError, CreditCard.update, customer_id, payment_id, UPDATE_CREDIT_CARD_INVALID_MASK)

        # Delete tests
        CreditCard.delete(customer_id, payment_id)
        self.assertRaises(AuthorizeResponseError, CreditCard.delete, customer_id, payment_id)
    def authorize_authorize_net(self, card_info=None):
        """
        Authorize using authorize.net for the specific transaction.

        :param credit_card: An instance of CreditCardView
        """
        TransactionLog = Pool().get('payment_gateway.transaction.log')

        client = self.gateway.get_authorize_client()
        client._transaction.base_params['x_currency_code'] = self.currency.code

        if card_info:
            cc = CreditCard(
                card_info.number,
                card_info.expiry_year,
                card_info.expiry_month,
                card_info.csc,
                card_info.owner,
            )
            credit_card = client.card(cc)
        elif self.payment_profile:
            credit_card = client.saved_card(
                self.payment_profile.provider_reference)
        else:
            self.raise_user_error('no_card_or_profile')

        try:
            result = credit_card.auth(self.amount)
        except AuthorizeResponseError, exc:
            self.state = 'failed'
            self.save()
            TransactionLog.serialize_and_create(self, exc.full_response)
    def test_live_full_credit_card(self):
        # Create a customer so that we can test payment creation against him
        result = Customer.create()
        customer_id = result.customer_id

        result = CreditCard.create(customer_id, FULL_CREDIT_CARD)
        payment_id = result.payment_id

        # Make sure the billing address we set is the same we get back
        result = CreditCard.details(customer_id, payment_id)
        self.assertEquals(FULL_CREDIT_CARD['billing'], result.payment_profile.bill_to)

        # Validate the credit card information
        result = CreditCard.validate(customer_id, payment_id, {
            'card_code': '456',
            'validation_mode': 'testMode',
        })
    def test_live_full_credit_card(self):
        # Create a customer so that we can test payment creation against him
        result = Customer.create()
        customer_id = result.customer_id

        result = CreditCard.create(customer_id, FULL_CREDIT_CARD)
        payment_id = result.payment_id

        # Make sure the billing address we set is the same we get back
        result = CreditCard.details(customer_id, payment_id)
        self.assertEquals(FULL_CREDIT_CARD['billing'], result.payment_profile.bill_to)

        # Validate the credit card information
        result = CreditCard.validate(customer_id, payment_id, {
            'card_code': '456',
            'validation_mode': 'testMode',
        })
Ejemplo n.º 6
0
 def setUp(self):
     # Random in testing feels gross, otherwise running the same test
     # suite in quick succession produces failures because Authorize.net
     # thinks the transactions are duplicates and rejects them
     self.amount1 = random.randrange(100, 100000) / 100.0
     self.amount2 = random.randrange(100, 100000) / 100.0
     self.client = AuthorizeClient(TEST_LOGIN_ID, TEST_TRANSACTION_KEY)
     self.year = date.today().year + 10
     self.credit_card = CreditCard('4111111111111111', self.year, 1, '911',
         'Jeff', 'Schenck')
     self.address = Address('45 Rose Ave', 'Venice', 'CA', '90291')
Ejemplo n.º 7
0
 def setUp(self):
     self.transaction_api_patcher = mock.patch(
         'authorize.client.TransactionAPI')
     self.transaction_api = self.transaction_api_patcher.start()
     self.customer_api_patcher = mock.patch('authorize.client.CustomerAPI')
     self.customer_api = self.customer_api_patcher.start()
     self.recurring_api_patcher = mock.patch(
         'authorize.client.RecurringAPI')
     self.recurring_api = self.recurring_api_patcher.start()
     self.client = AuthorizeClient('123', '456')
     self.year = date.today().year + 10
     self.credit_card = CreditCard('4111111111111111', self.year, 1, '911',
                                   'Jeff', 'Schenck')
     self.address = Address('45 Rose Ave', 'Venice', 'CA', '90291')
    def transition_add_authorize_net(self):
        """
        Handle the case if the profile should be added for authorize.net
        """
        card_info = self.card_info

        client = card_info.gateway.get_authorize_client()
        try:
            cc = CreditCard(
                card_info.number,
                card_info.expiry_year,
                card_info.expiry_month,
                card_info.csc,
                card_info.owner,
            )
        except AuthorizeInvalidError, e:
            self.raise_user_error(unicode(e))
Ejemplo n.º 9
0
 def setUp(self):
     self.client = AuthorizeClient(TEST_LOGIN_ID, TEST_TRANSACTION_KEY)
     self.year = date.today().year + 10
     self.credit_card = CreditCard('4111111111111111', self.year, 1, '911',
                                   'Jeff', 'Schenck')
     self.address = Address('45 Rose Ave', 'Venice', 'CA', '90291')