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)
def test_authorized_saved_card_update(self): address = Address('45 Rose Ave', 'Venice', 'CA', '90291') result_dict = { 'first_name': 'Jeff', 'last_name': 'Shenck', 'address': address, 'payment': PROFILE} self.client._customer.retrieve_saved_payment.return_value = result_dict self.client._customer.update_saved_payment.return_value = None saved = AuthorizeSavedCard(self.client, '1|2') saved.update(address=address)
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')
def test_authorize_saved_card_get_payment_info(self): address = Address('45 Rose Ave', 'Venice', 'CA', '90291') result_dict = { 'first_name': 'Jeff', 'last_name': 'Shenck', 'address': address, 'payment': PROFILE} self.client._customer.retrieve_saved_payment.return_value = result_dict saved = AuthorizeSavedCard(self.client, '1|2') result = saved.get_payment_info() self.assertEqual(result['first_name'], result_dict['first_name']) self.assertEqual(result['last_name'], result_dict['last_name']) self.assertEqual( result['address'].street, result_dict['address'].street)
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 test_live_address(self): # Create a customer so that we can test payment creation against him result = Customer.create() customer_id = result.customer_id # Create a new shipping address result = Address.create(customer_id, ADDRESS) address_id = result.address_id result = Address.details(customer_id, address_id) # Compare the address without the customer_address_id del result.address['address_id'] self.assertEquals(ADDRESS, result.address) Address.update(customer_id, address_id, ADDRESS) # Delete the address and make sure it is deleted by attempting to # delete it again. Address.delete(customer_id, address_id) self.assertRaises(AuthorizeResponseError, Address.delete, customer_id, address_id)
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')