コード例 #1
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #2
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #3
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #4
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #5
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #6
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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
コード例 #7
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #8
0
    def test_011_charge_master_card(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 = 2015
        card.cvv = 123

        direct_market_data = HpsDirectMarketData('123456')

        builder = self.service.charge(17.02)\
            .with_card_holder(card_holder)\
            .with_direct_market_data(direct_market_data)

        if self.use_tokens:
            builder.with_token(self.__class__.mastercard_token)
        else:
            builder.with_card(card)

        response = builder.execute()

        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #9
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #10
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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
コード例 #11
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #12
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    def test_037_fraud_prevention_sale(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = 123

        response = self.service.charge(15000).with_card(card).execute()
        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #13
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    def test_038_fraud_prevention_return(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = 123

        response = self.service.refund(15000).with_card(card).execute()
        self.assertIsNotNone(response)
        if response.response_code != '00':
            self.assertEqual('41', response.response_code)
コード例 #14
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    def test_005_balance_inquiry_visa(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2025

        response = self.service.prepaid_balance_inquiry()\
            .with_card(card)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #15
0
    def test_005_balance_inquiry_visa(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2025

        response = self.service.prepaid_balance_inquiry()\
            .with_card(card)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #16
0
    def test_cvv_with_leading_zero(self):
        self.charge_service._config = TestServicesConfig.valid_services_config

        card = HpsCreditCard()
        card.number = "4111111111111111"
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = "012"

        response = self.charge_service.authorize(15.15, 'usd', card)
        self.assertIsNotNone(response)
        self.assertEquals('00', response.response_code)
コード例 #17
0
    def test_002_verify_master_card(self):
        card = HpsCreditCard()
        card.number = '5473500000000014'
        card.exp_month = 12
        card.exp_year = 2025

        response = self.service.verify()\
            .with_card(card)\
            .with_request_multi_use_token(self.use_tokens)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('85', response.response_code)
コード例 #18
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    def test_002_verify_master_card(self):
        card = HpsCreditCard()
        card.number = '5473500000000014'
        card.exp_month = 12
        card.exp_year = 2025

        response = self.service.verify()\
            .with_card(card)\
            .with_request_multi_use_token(self.use_tokens)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('85', response.response_code)
コード例 #19
0
    def test_001_verify_visa(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2015

        response = self.service.verify()\
            .with_card(card)\
            .with_request_multi_use_token(self.use_tokens)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('85', response.response_code)
コード例 #20
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    def test_034_offline_credit_return(self):
        card = HpsCreditCard()
        card.number = '5473500000000014'
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = 123

        direct_market_data = HpsDirectMarketData('123456')

        response = self.service.refund(15.15)\
            .with_card(card)\
            .with_direct_market_data(direct_market_data)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #21
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    def test_033_offline_sale(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = 123

        direct_market_data = HpsDirectMarketData('123456')

        response = self.service.offline_charge(17.10)\
            .with_card(card)\
            .with_offline_auth_code('654321')\
            .with_direct_market_data(direct_market_data)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #22
0
    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)
コード例 #23
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #24
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #25
0
ファイル: test_general.py プロジェクト: hps/heartland-python
    def test_update_token_expiry(self):
        config = HpsServicesConfig()
        config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'

        self.charge_service._config = config

        card = HpsCreditCard()
        card.number = "4111111111111111"
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = "012"

        response = self.charge_service.authorize(12.09, 'usd', card, request_multi_use_token=True)
        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
        self.assertIsNotNone(response.token_data)

        update_token_response = self.charge_service.update_token_expiry(response.token_data.token_value, 12, 2035)
        self.assertIsNotNone(response)
        self.assertEqual('0', update_token_response.response_code)
コード例 #26
0
    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)
コード例 #27
0
    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)
コード例 #28
0
    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
コード例 #29
0
    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)
コード例 #30
0
    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)
コード例 #31
0
    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
コード例 #32
0
    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)
コード例 #33
0
    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)
コード例 #34
0
    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)
コード例 #35
0
    def test_add_with_token(self):
        token_service = HpsTokenService(
            TestServicesConfig.valid_pay_plan_config.public_key)

        card = HpsCreditCard()
        card.number = 4111111111111111
        card.exp_month = '12'
        card.exp_year = '2020'
        card.cvv = '123'

        token = token_service.get_token(card)
        if token.token_value is None:
            self.fail("cannot generate token")

        payment_method = HpsPayPlanPaymentMethod()
        payment_method.customer_key = self.customer.customer_key
        payment_method.payment_method_type = HpsPayPlanPaymentMethodType.CREDIT_CARD
        payment_method.name_on_account = 'Bill Johnson'
        payment_method.payment_token = token.token_value
        payment_method.expiration_date = '0120'
        payment_method.country = 'USA'

        response = self.service.add_payment_method(payment_method)
        self.assertIsNotNone(response)
        self.assertIsNotNone(response.payment_method_key)
コード例 #36
0
    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)
コード例 #37
0
    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)
コード例 #38
0
    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)
コード例 #39
0
    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
コード例 #40
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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
コード例 #41
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #42
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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
コード例 #43
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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
コード例 #44
0
ファイル: test_moto.py プロジェクト: hps/heartland-python
    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)
コード例 #45
0
    def test_007_charge_master_card_token(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 = 2015
        card.cvv = 123

        response = self.service.charge(13.02)\
            .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__.mastercard_token = response.token_data.token_value
コード例 #46
0
    def test_037_fraud_prevention_sale(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = 123

        response = self.service.charge(15000).with_card(card).execute()
        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #47
0
    def test_038_fraud_prevention_return(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = 123

        response = self.service.refund(15000).with_card(card).execute()
        self.assertIsNotNone(response)
        if response.response_code != '00':
            self.assertEqual('41', response.response_code)
コード例 #48
0
    def test_cvv_with_leading_zero(self):
        self.charge_service._config = TestServicesConfig.valid_services_config

        card = HpsCreditCard()
        card.number = "4111111111111111"
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = "012"

        response = self.charge_service.authorize(15.15, 'usd', card)
        self.assertIsNotNone(response)
        self.assertEquals('00', response.response_code)
コード例 #49
0
    def test_034_offline_credit_return(self):
        card = HpsCreditCard()
        card.number = '5473500000000014'
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = 123

        direct_market_data = HpsDirectMarketData('123456')

        response = self.service.refund(15.15)\
            .with_card(card)\
            .with_direct_market_data(direct_market_data)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #50
0
    def test_033_offline_sale(self):
        card = HpsCreditCard()
        card.number = '4012002000060016'
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = 123

        direct_market_data = HpsDirectMarketData('123456')

        response = self.service.offline_charge(17.10)\
            .with_card(card)\
            .with_offline_auth_code('654321')\
            .with_direct_market_data(direct_market_data)\
            .execute()

        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
コード例 #51
0
    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)
コード例 #52
0
    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)
コード例 #53
0
    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
コード例 #54
0
    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
コード例 #55
0
    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)
コード例 #56
0
    def test_update_token_expiry(self):
        config = HpsServicesConfig()
        config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'

        self.charge_service._config = config

        card = HpsCreditCard()
        card.number = "4111111111111111"
        card.exp_month = 12
        card.exp_year = 2025
        card.cvv = "012"

        response = self.charge_service.authorize(12.09,
                                                 'usd',
                                                 card,
                                                 request_multi_use_token=True)
        self.assertIsNotNone(response)
        self.assertEqual('00', response.response_code)
        self.assertIsNotNone(response.token_data)

        update_token_response = self.charge_service.update_token_expiry(
            response.token_data.token_value, 12, 2035)
        self.assertIsNotNone(response)
        self.assertEqual('0', update_token_response.response_code)
コード例 #57
0
class TestCreditCard(object):
    # valid visa
    valid_visa = HpsCreditCard()
    valid_visa.cvv = 123
    valid_visa.exp_month = 12
    valid_visa.exp_year = 2025
    valid_visa.number = "4012002000060016"

    # valid visa no cvv
    valid_visa_no_cvv = copy.deepcopy(valid_visa)
    valid_visa_no_cvv.cvv = None

    # valid visa track data
    valid_visa_track = HpsTrackData()
    valid_visa_track.method = HpsTrackDataMethod.swipe
    valid_visa_track.value = '%B4012001000000016^VI TEST CREDIT^251200000000000000000000?'
    valid_visa_track.value += ';4012001000000016=25120000000000000000?'

    # valid visa track data e3 v1
    valid_visa_track_e3v1 = HpsTrackData()
    valid_visa_track_e3v1.method = HpsTrackDataMethod.swipe
    valid_visa_track_e3v1.value = '<E1050711%B4012001000000016^VI TEST CREDIT^251200000000000000000000?|m3VpZL7Km3cqqty3xcIUJ+hKb1lwraqDBvnqQjZybcl95ywOAmdNTKTua|+++++++/q6S49jif|11;4012001000000016=25120000000000000000?|1dxxl54agM6av5oo3myo37RH4wo|+++++++/q6S49jif|00|||/wECAQECAoFGAgEH2wMBTDT6jRZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0AemN+EBuiWATgwIPfIVLybYKTlitSTmJYek5yD3nxtfsR0Rfd9UAaMTxDEGYeQDVmlgJICy8r0RE3QK5tgGCmWXF+GzMmAyB5h4o+jqbIluSs/MbKURSand61aTi5rRhbQSeBNjlvajCtZULmXXjpn6nuXI4QhN89sYwYm5tFwwA6yBN6fDDx8cH5I7MB6wn+AjVzrCCvV347WA2iujV0ZjTFDPT|>'
    valid_visa_track_e3v1.encryption_data = HpsEncryptionData()
    valid_visa_track_e3v1.encryption_data.version = '01'

    # valid visa track data e3 v2
    valid_visa_track_e3v2 = HpsTrackData()
    valid_visa_track_e3v2.method = HpsTrackDataMethod.swipe
    valid_visa_track_e3v2.value = '1dxxl54agM6av5oo3myo37RH4wo'
    valid_visa_track_e3v2.encryption_data = HpsEncryptionData()
    valid_visa_track_e3v2.encryption_data.version = '02'
    valid_visa_track_e3v2.encryption_data.encrypted_track_number = '2'
    valid_visa_track_e3v2.encryption_data.ktb = '/wECAQECAoFGAgEH2wMBTDT6jRZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0AemN+EBuiWATgwIPfIVLybYKTlitSTmJYek5yD3nxtfsR0Rfd9UAaMTxDEGYeQDVmlgJICy8r0RE3QK5tgGCmWXF+GzMmAyB5h4o+jqbIluSs/MbKURSand61aTi5rRhbQSeBNjlvajCtZULmXXjpn6nuXI4QhN89sYwYm5tFwwA6yBN6fDDx8cH5I7MB6wn+AjVzrCCvV347WA2iujV0ZjTFDPT'

    # valid visa proximity data
    valid_visa_proximity = HpsTrackData()
    valid_visa_proximity.method = HpsTrackDataMethod.proximity
    valid_visa_proximity.value = '%B4012001000000016^VI TEST CREDIT^251200000000000000000000?'
    valid_visa_proximity.value += ';4012001000000016=25120000000000000000?'

    # valid visa track data e3 v1
    valid_visa_proximity_e3v1 = HpsTrackData()
    valid_visa_proximity_e3v1.method = HpsTrackDataMethod.proximity
    valid_visa_proximity_e3v1.value = '<E1050711%B4012001000000016^VI TEST CREDIT^251200000000000000000000?|m3VpZL7Km3cqqty3xcIUJ+hKb1lwraqDBvnqQjZybcl95ywOAmdNTKTua|+++++++/q6S49jif|11;4012001000000016=25120000000000000000?|1dxxl54agM6av5oo3myo37RH4wo|+++++++/q6S49jif|00|||/wECAQECAoFGAgEH2wMBTDT6jRZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0AemN+EBuiWATgwIPfIVLybYKTlitSTmJYek5yD3nxtfsR0Rfd9UAaMTxDEGYeQDVmlgJICy8r0RE3QK5tgGCmWXF+GzMmAyB5h4o+jqbIluSs/MbKURSand61aTi5rRhbQSeBNjlvajCtZULmXXjpn6nuXI4QhN89sYwYm5tFwwA6yBN6fDDx8cH5I7MB6wn+AjVzrCCvV347WA2iujV0ZjTFDPT|>'
    valid_visa_proximity_e3v1.encryption_data = HpsEncryptionData()
    valid_visa_proximity_e3v1.encryption_data.version = '01'

    # valid visa track data e3 v2
    valid_visa_proximity_e3v2 = HpsTrackData()
    valid_visa_proximity_e3v2.method = HpsTrackDataMethod.proximity
    valid_visa_proximity_e3v2.value = '1dxxl54agM6av5oo3myo37RH4wo'
    valid_visa_proximity_e3v2.encryption_data = HpsEncryptionData()
    valid_visa_proximity_e3v2.encryption_data.version = '02'
    valid_visa_proximity_e3v2.encryption_data.encrypted_track_number = '2'
    valid_visa_proximity_e3v2.encryption_data.ktb = '/wECAQECAoFGAgEH2wMBTDT6jRZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0AemN+EBuiWATgwIPfIVLybYKTlitSTmJYek5yD3nxtfsR0Rfd9UAaMTxDEGYeQDVmlgJICy8r0RE3QK5tgGCmWXF+GzMmAyB5h4o+jqbIluSs/MbKURSand61aTi5rRhbQSeBNjlvajCtZULmXXjpn6nuXI4QhN89sYwYm5tFwwA6yBN6fDDx8cH5I7MB6wn+AjVzrCCvV347WA2iujV0ZjTFDPT'

    # valid mastercard
    valid_mastercard = HpsCreditCard()
    valid_mastercard.cvv = 123
    valid_mastercard.exp_month = 12
    valid_mastercard.exp_year = 2025
    valid_mastercard.number = "5473500000000014"

    # valid mastercard no cvv
    valid_mastercard_no_cvv = copy.deepcopy(valid_mastercard)
    valid_mastercard_no_cvv.cvv = None

    # valid discover card
    valid_discover = HpsCreditCard()
    valid_discover.cvv = 123
    valid_discover.exp_month = 12
    valid_discover.exp_year = 2025
    valid_discover.number = "6011000990156527"

    # valid discover no cvv
    valid_discover_no_cvv = copy.deepcopy(valid_discover)
    valid_discover_no_cvv.cvv = None

    # valid amex
    valid_amex = HpsCreditCard()
    valid_amex.cvv = 1234
    valid_amex.exp_month = 12
    valid_amex.exp_year = 2025
    valid_amex.number = "372700699251018"

    # valid amex no cvv
    valid_amex_no_cvv = copy.deepcopy(valid_amex)
    valid_amex_no_cvv.cvv = None

    # valid jcb
    valid_jcb = HpsCreditCard()
    valid_jcb.cvv = 123
    valid_jcb.exp_month = 12
    valid_jcb.exp_year = 2025
    valid_jcb.number = "3566007770007321"

    # valid jcb no cvv
    valid_jcb_no_cvv = copy.deepcopy(valid_jcb)
    valid_jcb_no_cvv.cvv = None

    # invalid card
    invalid_card = HpsCreditCard()
    invalid_card.cvv = 123
    invalid_card.exp_month = 12
    invalid_card.exp_year = 2025
    invalid_card.number = "12345"