class TestCheck(object): # check holder _check_holder = HpsCheckHolder() _check_holder.address = HpsAddress() _check_holder.address.address = '6860 Dallas Parkway' _check_holder.address.city = 'Plano' _check_holder.address.state = 'TX' _check_holder.address.zip = '75024' _check_holder.dl_number = '1234567' _check_holder.dl_state = 'TX' _check_holder.first_name = 'John' _check_holder.last_name = 'Doe' _check_holder.phone = '1234567890' # good check approve = HpsCheck() approve.account_number = '24413815' approve.routing_number = '490000018' approve.check_type = CheckTypeType.personal approve.sec_code = 'PPD' approve.account_type = AccountTypeType.checking approve.check_holder = copy.deepcopy(_check_holder) # check w/ invalid check holder invalid_check_holder = copy.deepcopy(approve) invalid_check_holder.check_holder.dl_number = '' invalid_check_holder.check_holder.dl_state = '' invalid_check_holder.check_holder.phone = '' # bad check decline = copy.deepcopy(approve) decline.routing_number = '490000034' # certification check certification = HpsCheck() certification.account_number = '24413815' certification.routing_number = '490000018' certification.check_type = CheckTypeType.personal certification.sec_code = SecCode.ppd certification.account_type = AccountTypeType.checking certification.check_holder = HpsCheckHolder() certification.check_holder.address = HpsAddress() certification.check_holder.address.address = '123 Main St.' certification.check_holder.address.city = 'Downtown' certification.check_holder.address.state = 'NJ' certification.check_holder.address.zip = '12345' certification.check_holder.dl_number = '09876543210' certification.check_holder.dl_state = 'TX' certification.check_holder.first_name = 'John' certification.check_holder.last_name = 'Doe' certification.check_holder.phone = '8003214567' certification.check_holder.dob_year = '1985'
def test_020_partial_approval_master_card(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '75024' direct_market_data = HpsDirectMarketData('123456') card = HpsCreditCard() card.number = '6011000990156527' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 response = self.service.charge(155)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data)\ .with_allow_partial_auth(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('10', response.response_code) self.assertIsNotNone(response.authorized_amount) self.assertEqual(u'100.00', response.authorized_amount) self.__class__.test_20_transaction_id = response.transaction_id
def test_021_level_ii_response_b(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860 Dallas Pkwy' card_holder.address.zip = '750241234' card = HpsCreditCard() card.number = '4012002000060016' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 response = self.service.charge(112.34)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_cpc_req(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) self.assertEqual('B', response.cpc_indicator) cpc_data = HpsCPCData('9876543210', HpsTaxType.not_used) cpc_response = self.service.cpc_edit(response.transaction_id)\ .with_cpc_data(cpc_data)\ .execute() self.assertIsNotNone(cpc_response) self.assertEqual('00', cpc_response.response_code)
def test_013_charge_amex(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860 Dallas Pkwy' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '372700699251018' card.exp_month = 12 card.exp_year = 2025 card.cvv = 1234 direct_market_data = HpsDirectMarketData('123456') builder = self.service.charge(17.04)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data) if self.use_tokens: builder.with_token(self.__class__.amex_token) else: builder.with_card(card) response = builder.execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code)
def test_012_charge_discover(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '750241234' direct_market_data = HpsDirectMarketData('123456') card = HpsCreditCard() card.number = '6011000990156527' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 builder = self.service.charge(17.03)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data) if self.use_tokens: builder.with_token(self.__class__.discover_token) else: builder.with_card(card) response = builder.execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code)
def test_010_charge_visa(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860 Dallas Pkwy' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '4012002000060016' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 direct_market_data = HpsDirectMarketData('123456') builder = self.service.charge(17.01)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data) if self.use_tokens: builder.with_token(self.__class__.visa_token) else: builder.with_card(card) response = builder.execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) self.__class__.test_10_transaction_id = response.transaction_id
def test_023_level_ii_response_r(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '4012002000060016' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 response = self.service.charge(123.45)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_cpc_req(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) self.assertEqual('R', response.cpc_indicator) cpc_data = HpsCPCData('', HpsTaxType.tax_exempt) cpc_response = self.service.cpc_edit(response.transaction_id)\ .with_cpc_data(cpc_data)\ .execute() self.assertIsNotNone(cpc_response) self.assertEqual('00', cpc_response.response_code)
def test_027_level_ii_response_s(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '5473500000000014' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 response = self.service.charge(111.08)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_cpc_req(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) self.assertEqual('S', response.cpc_indicator) cpc_data = HpsCPCData('9876543210', HpsTaxType.sales_tax, 1.00) cpc_response = self.service.cpc_edit(response.transaction_id)\ .with_cpc_data(cpc_data)\ .execute() self.assertIsNotNone(cpc_response) self.assertEqual('00', cpc_response.response_code)
def test_032_level_ii_no_response(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '372700699251018' card.exp_month = 12 card.exp_year = 2025 card.cvv = 1234 response = self.service.charge(111.13)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_cpc_req(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) self.assertEqual('0', response.cpc_indicator) cpc_data = HpsCPCData('9876543210', HpsTaxType.tax_exempt) cpc_response = self.service.cpc_edit(response.transaction_id)\ .with_cpc_data(cpc_data)\ .execute() self.assertIsNotNone(cpc_response) self.assertEqual('00', cpc_response.response_code)
def test_018_partial_approval_visa(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '4012002000060016' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 direct_market_data = HpsDirectMarketData('123456') response = self.service.charge(130)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data)\ .with_allow_partial_auth(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('10', response.response_code) self.assertIsNotNone(response.authorized_amount) self.assertEqual(u'110.00', response.authorized_amount)
def test_016_authorization_master_card(self): # Test 016a Authorization card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860 Dallas Pkwy' card_holder.address.zip = '750241234' card = HpsCreditCard() card.number = '5473500000000014' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 direct_market_data = HpsDirectMarketData('123456') response = self.service.authorize(17.07)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) # test 016b Capture/AddToBatch capture = self.service.capture(response.transaction_id).execute() self.assertIsNotNone(capture) self.assertEqual('00', capture.response_code)
class TestCardHolder(object): # heartland's address _heartland_address = HpsAddress() _heartland_address.address = 'One Heartland Way' _heartland_address.city = 'Jeffersonville' _heartland_address.state = 'IN' _heartland_address.zip = '47130' _heartland_address.country = 'United States' # cert address _cert_address = HpsAddress() _cert_address.address = '6860 Dallas Pkwy' _cert_address.city = 'Irvine' _cert_address.state = 'TX' _cert_address.zip = '750241234' _cert_address.country = 'United States' # base card holder _card_holder = HpsCardHolder() _card_holder.first_name = 'Bill' _card_holder.last_name = 'Johnson' _card_holder.address = _cert_address # valid card holder valid_card_holder = copy.deepcopy(_card_holder) valid_card_holder.address = _heartland_address # certification card holder - short zip cert_holder_short_zip = copy.deepcopy(_card_holder) cert_holder_short_zip.address.zip = '75024' # certification card holder - short zip, no street cert_holder_short_zip_no_street = copy.deepcopy(_card_holder) cert_holder_short_zip_no_street.address.address = '6860' cert_holder_short_zip_no_street.address.zip = '75024' # certification card holder - long zip cert_holder_long_zip = copy.deepcopy(_card_holder) # certification card holder - long zip, no street cert_holder_long_zip_no_street = copy.deepcopy(_card_holder) cert_holder_long_zip_no_street.address.address = '6860'
def test_004_verify_amex(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '372700699251018' card.exp_month = 12 card.exp_year = 2025 response = self.service.verify()\ .with_card(card)\ .with_card_holder(card_holder)\ .with_request_multi_use_token(self.use_tokens)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code)
def test_003_verify_discover(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '6011000990156527' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 response = self.service.verify()\ .with_card(card)\ .with_card_holder(card_holder)\ .with_request_multi_use_token(self.use_tokens)\ .execute() self.assertIsNotNone(response) self.assertEqual('85', response.response_code)
def test_042_charge_gsb(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '6277220572999800' card.exp_month = 12 card.exp_year = 2049 direct_market_data = HpsDirectMarketData('123456') response = self.service.charge(2.10)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code)
def test_006_charge_visa_token(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860 Dallas Pkwy' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '4012002000060016' card.exp_month = 12 card.exp_year = 2025 response = self.service.charge(13.01)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_request_multi_use_token(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) self.assertIsNotNone(response.token_data) self.assertIsNotNone(response.token_data.token_value) self.__class__.visa_token = response.token_data.token_value
def test_014_charge_jcb(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860 Dallas Pkwy' card_holder.address.zip = '750241234' card = HpsCreditCard() card.number = '3566007770007321' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 direct_market_data = HpsDirectMarketData('123456') response = self.service.charge(17.05)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code)
def test_008_charge_discover_token(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '750241234' card = HpsCreditCard() card.number = '6011000990156527' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 response = self.service.charge(13.03)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_request_multi_use_token(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) self.assertIsNotNone(response.token_data) self.assertIsNotNone(response.token_data.token_value) self.__class__.discover_token = response.token_data.token_value
def test_009_charge_amex_token(self): card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860 Dallas Pkwy' card_holder.address.zip = '75024' card = HpsCreditCard() card.number = '372700699251018' card.exp_month = 12 card.exp_year = 2025 card.cvv = 1234 response = self.service.charge(13.04)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_request_multi_use_token(True)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code) self.assertIsNotNone(response.token_data) self.assertIsNotNone(response.token_data.token_value) self.__class__.amex_token = response.token_data.token_value
def test_017_authorization_discover(self): # Test 017a Authorization card_holder = HpsCardHolder() card_holder.address = HpsAddress() card_holder.address.address = '6860' card_holder.address.zip = '75024' direct_market_data = HpsDirectMarketData('123456') card = HpsCreditCard() card.number = '6011000990156527' card.exp_month = 12 card.exp_year = 2025 card.cvv = 123 response = self.service.authorize(17.08)\ .with_card(card)\ .with_card_holder(card_holder)\ .with_direct_market_data(direct_market_data)\ .execute() self.assertIsNotNone(response) self.assertEqual('00', response.response_code)