예제 #1
0
 def test_authorize_credit_card_save(self):
     self.client._customer.create_saved_profile.return_value = ('1', '2')
     card = AuthorizeCreditCard(self.client, self.credit_card)
     result = card.save()
     self.assertEqual(self.client._customer.create_saved_payment.call_args,
         ((self.credit_card,), {'address': None}))
     self.assertTrue(isinstance(result, AuthorizeSavedCard))
     self.assertEqual(result.uid, '1|2')
예제 #2
0
 def test_authorize_credit_card_capture(self):
     self.client._transaction.capture.return_value = TRANSACTION_RESULT
     card = AuthorizeCreditCard(self.client, self.credit_card)
     result = card.capture(10)
     self.assertEqual(self.client._transaction.capture.call_args,
                      ((10, self.credit_card, None), {}))
     self.assertTrue(isinstance(result, AuthorizeTransaction))
     self.assertEqual(result.uid, '2171062816')
     self.assertEqual(result.full_response, TRANSACTION_RESULT)
예제 #3
0
 def test_authorize_credit_card_capture(self):
     self.client._transaction.capture.return_value = TRANSACTION_RESULT
     card = AuthorizeCreditCard(self.client, self.credit_card)
     result = card.capture(10)
     self.assertEqual(self.client._transaction.capture.call_args,
         ((10, self.credit_card, None), {}))
     self.assertTrue(isinstance(result, AuthorizeTransaction))
     self.assertEqual(result.uid, '2171062816')
     self.assertEqual(result.full_response, TRANSACTION_RESULT)
예제 #4
0
 def test_authorize_credit_card_auth(self):
     self.client._transaction.auth.return_value = TRANSACTION_RESULT
     card = AuthorizeCreditCard(self.client, self.credit_card)
     result = card.auth(10)
     self.assertEqual(self.client._transaction.auth.call_args,
         ((10, self.credit_card, None, None),
          {'invoice_number': None, 'description': None}))
     self.assertTrue(isinstance(result, AuthorizeTransaction))
     self.assertEqual(result.uid, '2171062816')
     self.assertEqual(result.full_response, TRANSACTION_RESULT)
예제 #5
0
 def test_authorize_credit_card_recurring(self):
     self.client._recurring.create_subscription.return_value = '1'
     card = AuthorizeCreditCard(self.client, self.credit_card)
     today = date.today()
     result = card.recurring(10, today, months=1)
     self.assertEqual(self.client._recurring.create_subscription.call_args,
         ((self.credit_card, 10, today), {'days': None, 'months': 1,
         'occurrences': None, 'trial_amount': None,
         'trial_occurrences': None}))
     self.assertTrue(isinstance(result, AuthorizeRecurring))
     self.assertEqual(result.uid, '1')
class AddPaymentProfile:
    """
    Add a payment profile
    """
    __name__ = 'party.party.payment_profile.add'

    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))
        address = Address(
            card_info.address.street,
            card_info.address.city,
            card_info.address.zip,
            card_info.address.country.code,
        )
        saved_card = AuthorizeCreditCard(client,
                                         credit_card=cc,
                                         address=address,
                                         email=card_info.party.email)
        saved_card = saved_card.save()
        return self.create_profile(saved_card.uid)
예제 #7
0
def get_card(card_num,
             cvn,
             exp_month,
             exp_year,
             fname,
             lname,
             street,
             city,
             state,
             zipcode,
             authorize_id,
             authorize_key,
             country='USA'):
    client = get_client(authorize_id, authorize_key)
    address = Address(street, city, state, zipcode, country)
    card = CreditCard(card_num, exp_year, exp_month, cvn, fname, lname)
    return AuthorizeCreditCard(client, card, address=address)
예제 #8
0
 def test_authorize_credit_card_basic(self):
     card = AuthorizeCreditCard(self.client, self.credit_card)
     card = AuthorizeCreditCard(self.client, self.credit_card, self.address)
     repr(card)