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)
Exemplo n.º 2
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')
Exemplo n.º 3
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))
Exemplo n.º 5
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')