コード例 #1
0
ファイル: test_reporting.py プロジェクト: slogsdon/python-sdk
    def test_check_crypto_gold_standard(self):
        gold_config = ServicesConfig()
        gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
        gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

        ServicesContainer.configure(gold_config, 'gold standard')
        summary = ReportingService.activity()\
            .with_start_date(datetime.datetime.today() + datetime.timedelta(days=-7))\
            .with_end_date(datetime.datetime.today() + datetime.timedelta(days=-1))\
            .execute('gold standard')
        self.assertNotEqual(None, summary)
コード例 #2
0
    def test_check_crypto_gold_standard(self):
        gold_config = ServicesConfig()
        gold_config.secret_api_key = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'
        gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

        ServicesContainer.configure(gold_config, 'gold standard')
        response = self.track.charge(10)\
            .with_currency('USD')\
            .with_allow_duplicates(True)\
            .execute('gold standard')
        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #3
0
 def configure_client(self):
     config = ServicesConfig()
     global_payment = self.env['payment.acquirer'].search([
         ('id', '=', self.env.ref('payment.payment_acquirer_global').id)
     ])
     config.merchant_id = global_payment.gp_seller_account
     config.account_id = global_payment.gp_id_account
     config.shared_secret = global_payment.gp_shared_secret_account
     config.service_url = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'
     ServicesContainer.configure(config)
     print(global_payment.gp_seller_account)
     print(config.shared_secret)
コード例 #4
0
    def test_check_crypto_gold_standard(self):
        gold_config = ServicesConfig()
        gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
        gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

        ServicesContainer.configure(gold_config, 'gold standard')
        response = self.card.authorize(10)\
            .with_currency('USD')\
            .with_allow_duplicates(True)\
            .execute('gold standard')
        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #5
0
class IntegrationGatewaysPorticoConnectorDebitTests(unittest.TestCase):
    '''
    Ensure recurring transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'
    config.service_url = 'https://cert.api2.heartlandportico.com'

    ServicesContainer.configure(config, 'recurring')

    @staticmethod
    def payment_id(payment_type):
        return '{0}-GlobalApi-{1}'.format(datetime.date.today().isoformat(),
                                          payment_type)

    def test_check_crypto_gold_standard(self):
        gold_config = ServicesConfig()
        gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
        gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

        ServicesContainer.configure(gold_config, 'gold standard')

        payment_method = RecurringPaymentMethod.find(
            self.payment_id('credit'), config_name='gold standard')
        self.assertNotEqual(None, payment_method)

        response = payment_method.charge(14.01)\
            .with_currency('USD')\
            .with_allow_duplicates(True)\
            .execute('gold standard')
        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #6
0
ファイル: __init__.py プロジェクト: pseudoGal/SDK
 def with_hosted_payment_data(self, value):
     client = ServicesContainer.instance().get_client('default')
     if client.supports_hosted_payments:
         self.hosted_payment_data = value
         return self
     raise BuilderException(
         'Your current gateway does not support hosted payments.')
コード例 #7
0
ファイル: test_credit_auth.py プロジェクト: pseudoGal/SDK
class CreditAuthTests(unittest.TestCase):
    '''
    Ensure CreditAuth transaction works
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w'
    config.service_url = 'https://cert.api2.heartlandportico.com'

    ServicesContainer.configure(config)

    card = CreditCardData()
    card.number = '4111111111111111'
    card.exp_month = '12'
    card.exp_year = '2025'
    card.cvn = '123'
    card.card_holder_name = 'Joe Smith'

    def test_credit_auth(self):
        response = self.card.authorize(10) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #8
0
 def test_container_instance(self):
     """
     Ensures configured gateway instance is available
     """
     gateway = ServicesContainer.instance().get_client("default")
     self.assertIsNotNone(gateway)
     self.assertTrue(isinstance(gateway, PorticoConnector))
コード例 #9
0
    def test_check_crypto_gold_standard(self):
        gold_config = ServicesConfig()
        gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
        gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

        ServicesContainer.configure(gold_config, 'gold standard')

        payment_method = RecurringPaymentMethod.find(
            self.payment_id('credit'), config_name='gold standard')
        self.assertNotEqual(None, payment_method)

        response = payment_method.charge(14.01)\
            .with_currency('USD')\
            .with_allow_duplicates(True)\
            .execute('gold standard')
        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #10
0
ファイル: management_builder.py プロジェクト: pseudoGal/SDK
    def execute(self):
        """
        Executes the builder against the gateway.
        :return: Transaction
        """
        TransactionBuilder.execute(self)

        client = ServicesContainer.instance().get_client()
        return client.manage_transaction(self)
コード例 #11
0
ファイル: __init__.py プロジェクト: pseudoGal/SDK
    def execute(self, config_name=None):
        """
        Executes the builder against the gateway.
        :return: Report
        """

        if config_name is None:
            config_name = "default"

        client = ServicesContainer.instance().get_client(config_name)
        return client.process_report(self)
コード例 #12
0
ファイル: __init__.py プロジェクト: pseudoGal/SDK
    def execute(self, config_name=None):
        """
        Executes the builder against the gateway.
        :return: RecurringEntity
        """

        if config_name is None:
            config_name = "default"

        TransactionBuilder.execute(self)

        client = ServicesContainer.instance().get_recurring_client(config_name)
        return client.process_recurring(self)
コード例 #13
0
ファイル: __init__.py プロジェクト: pseudoGal/SDK
    def execute(self, config_name=None):
        """
        Executes the builder against the gateway.
        :return: Transaction
        """

        if config_name is None:
            config_name = "default"

        TransactionBuilder.execute(self)

        client = ServicesContainer.instance().get_client(config_name)
        return client.manage_transaction(self)
コード例 #14
0
ファイル: __init__.py プロジェクト: pseudoGal/SDK
    def serialize(self, config_name=None):
        """
        Serializes an authorization builder for hosted payment page requests.
        Requires the gateway and account support hosted payment pages.
        :return: string
        """

        if config_name is None:
            config_name = "default"

        self.transaction_modifier = TransactionModifier.HostedRequest
        TransactionBuilder.execute(self)

        client = ServicesContainer.instance().get_client(config_name)
        if client and client.supports_hosted_payments:
            return client.serialize_request(self)
        raise BuilderException(
            'Your current gateway does not support hosted payments.')
コード例 #15
0
class TestServicesContainer(unittest.TestCase):
    """
    Test GlobalPayments.Api.ServicesContainer
    """

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w'
    config.service_url = 'https://cert.api2.heartlandportico.com'

    ServicesContainer.configure(config)

    def test_container_instance(self):
        """
        Ensures configured gateway instance is available
        """
        gateway = ServicesContainer.instance().get_client("default")
        self.assertIsNotNone(gateway)
        self.assertTrue(isinstance(gateway, PorticoConnector))
コード例 #16
0
class IntegrationGatewaysPorticoConnectorEbtTests(unittest.TestCase):
    '''
    Ensure reporting transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w'
    config.service_url = 'https://cert.api2.heartlandportico.com'
    config.developer_id = '000000'
    config.version_number = '0000'

    ServicesContainer.configure(config, 'reporting')

    def test_activity(self):
        # TODO: add start/end dates
        response = ReportingService.activity().execute('reporting')

        self.assertNotEqual(None, response)
        self.assertTrue(len(response) > -1)

    def test_transaction_detail(self):
        # TODO: add start/end dates
        activity = ReportingService.activity().execute('reporting')

        self.assertNotEqual(None, activity)

        if len(activity) > 0:
            response = ReportingService.transaction_detail(
                activity[0].transaction_id).execute('reporting')

            self.assertNotEqual(None, response)
            self.assertEqual('00', response.gateway_response_code)

    def test_check_crypto_gold_standard(self):
        gold_config = ServicesConfig()
        gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
        gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

        ServicesContainer.configure(gold_config, 'gold standard')
        summary = ReportingService.activity()\
            .with_start_date(datetime.datetime.today() + datetime.timedelta(days=-7))\
            .with_end_date(datetime.datetime.today() + datetime.timedelta(days=-1))\
            .execute('gold standard')
        self.assertNotEqual(None, summary)
コード例 #17
0
class IntegrationGatewaysPorticoConnectorCertificationEcommerceTests(
        unittest.TestCase):
    '''
    Ensure ecommerce transactions work
    '''

    BATCH_NOT_OPEN = 'Transaction was rejected because it requires a batch to be open.'
    BATCH_EMPTY = 'Batch close was rejected because no transactions are associated with the currently open batch'

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
    config.service_url = 'https://cert.api2.heartlandportico.com'
    config.developer_id = '000000'
    config.version_number = '0000'

    ServicesContainer.configure(config, 'ecommerce')

    use_tokens = True

    def test_000_close_batch(self):
        try:
            response = BatchService.close_batch('ecommerce')
            self.assertNotEqual(None, response)
        except Exception as e:
            if str(e.message).find(self.BATCH_NOT_OPEN) != -1 or str(
                    e.message).find(self.BATCH_EMPTY) != -1:
                return

    # Account verification

    def test_001_verify_visa(self):
        card = TestCards.visa_manual()

        response = card.verify() \
            .with_request_multi_use_token(self.use_tokens) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_002_verify_mastercard(self):
        card = TestCards.mastercard_manual()

        response = card.verify() \
            .with_request_multi_use_token(self.use_tokens) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_003_verify_discover(self):
        card = TestCards.discover_manual()

        address = Address()
        address.postal_code = '75024'

        response = card.verify() \
            .with_address(address) \
            .with_request_multi_use_token(self.use_tokens) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # Address verificaiton

    def test_004_verify_amex(self):
        card = TestCards.amex_manual()

        address = Address()
        address.postal_code = '75024'

        response = card.verify() \
            .with_address(address) \
            .with_request_multi_use_token(self.use_tokens) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # Balance Inquiry (prepaid)

    def test_005_balance_inquiry_visa(self):
        card = TestCards.visa_swipe()

        response = card.balance_inquiry().execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # Credit Sale (with token request)

    def test_006_charge_visa_token(self):
        global visa_token

        card = TestCards.visa_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '75024'

        response = card.charge(13.01) \
            .with_currency('USD') \
            .with_address(address) \
            .with_request_multi_use_token(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertNotEqual(None, response.token)

        visa_token = response.token

    def test_007_charge_mastercard_token(self):
        global mastercard_token

        card = TestCards.mastercard_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(13.02) \
            .with_currency('USD') \
            .with_address(address) \
            .with_request_multi_use_token(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertNotEqual(None, response.token)

        mastercard_token = response.token

    def test_008_charge_discover_token(self):
        global discover_token

        card = TestCards.discover_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '75024'

        response = card.charge(13.03) \
            .with_currency('USD') \
            .with_address(address) \
            .with_request_multi_use_token(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertNotEqual(None, response.token)

        discover_token = response.token

    def test_009_charge_amex_token(self):
        global amex_token

        card = TestCards.amex_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '75024'

        response = card.charge(13.04) \
            .with_currency('USD') \
            .with_address(address) \
            .with_request_multi_use_token(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertNotEqual(None, response.token)

        amex_token = response.token

    # Credit Sale

    def test_010_charge_visa(self):
        global visa_token

        card = TestCards.visa_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '75024'

        if self.use_tokens:
            card = CreditCardData()
            card.token = visa_token

        response = card.charge(17.01) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        void_response = response.void().execute('ecommerce')

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code,
                         void_response.response_message)

    def test_011_charge_mastercard(self):
        global mastercard_token

        card = TestCards.mastercard_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        if self.use_tokens:
            card = CreditCardData()
            card.token = mastercard_token

        response = card.charge(17.02) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_012_charge_discover(self):
        global discover_token

        card = TestCards.discover_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '750241234'

        if self.use_tokens:
            card = CreditCardData()
            card.token = discover_token

        response = card.charge(17.03) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_013_charge_amex(self):
        global amex_token

        card = TestCards.amex_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '75024'

        if self.use_tokens:
            card = CreditCardData()
            card.token = amex_token

        response = card.charge(17.04) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_014_charge_jcb(self):
        card = TestCards.jcb_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '75024'

        response = card.charge(17.05) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # Credit Authorization

    def test_015_autorize_visa(self):
        # 015a authorization
        card = TestCards.visa_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '75024'

        response = card.authorize(17.06) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        # 015b capture
        capture = response.capture().execute('ecommerce')

        self.assertNotEqual(None, capture)
        self.assertEqual('00', capture.response_code, capture.response_message)

    def test_016_autorize_mastercard(self):
        # 016a authorization
        card = TestCards.mastercard_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '750241234'

        response = card.authorize(17.07) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        # 016b capture
        capture = response.capture().execute('ecommerce')

        self.assertNotEqual(None, capture)
        self.assertEqual('00', capture.response_code, capture.response_message)

    def test_017_autorize_discover(self):
        # 017a authorization
        card = TestCards.discover_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.authorize(17.08) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        # 017b capture
        # do not capture

    # Partially approved sale

    def test_018_partial_approval_visa(self):
        card = TestCards.visa_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(130) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_partial_auth(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('10', response.response_code,
                         response.response_message)
        self.assertNotEqual(None, response.authorized_amount)
        self.assertEqual('110.00', response.authorized_amount)

    def test_019_partial_approval_discover(self):
        card = TestCards.discover_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(145) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_partial_auth(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('10', response.response_code,
                         response.response_message)
        self.assertNotEqual(None, response.authorized_amount)
        self.assertEqual('65.00', response.authorized_amount)

    def test_020_partial_approval_mastercard(self):
        card = TestCards.mastercard_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(155) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_partial_auth(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('10', response.response_code,
                         response.response_message)
        self.assertNotEqual(None, response.authorized_amount)
        self.assertEqual('100.00', response.authorized_amount)

    # Level II - Corporate Purchase Card

    def test_021_level_ii_response_b(self):
        card = TestCards.visa_manual()

        address = Address()
        address.street_address_1 = '6860 Dallas Pkwy'
        address.postal_code = '750241234'

        response = card.charge(112.34) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('B', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_po_number('9876543210') \
            .with_tax_type(TaxType.NotUsed) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_022_level_ii_response_b(self):
        card = TestCards.visa_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '750241234'

        response = card.charge(112.34) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('B', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_tax_type(TaxType.SalesTax) \
            .with_tax_amount(1.00) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_023_level_ii_response_r(self):
        card = TestCards.visa_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(123.45) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('R', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_tax_type(TaxType.TaxExempt) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_024_level_ii_response_s(self):
        card = TestCards.visa_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(134.56) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('S', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_tax_type(TaxType.SalesTax) \
            .with_tax_amount(1.00) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_025_level_ii_response_s(self):
        card = TestCards.mastercard_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(111.06) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('S', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_po_number('9876543210') \
            .with_tax_type(TaxType.NotUsed) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_026_level_ii_response_s(self):
        card = TestCards.mastercard_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(111.07) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('S', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_tax_type(TaxType.SalesTax) \
            .with_tax_amount(1.00) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_027_level_ii_response_s(self):
        card = TestCards.mastercard_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(111.08) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('S', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_po_number('9876543210') \
            .with_tax_type(TaxType.SalesTax) \
            .with_tax_amount(1.00) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_028_level_ii_response_s(self):
        card = TestCards.mastercard_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(111.09) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('S', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_po_number('9876543210') \
            .with_tax_type(TaxType.TaxExempt) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_029_level_ii_no_response(self):
        card = TestCards.amex_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(111.10) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('0', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_po_number('9876543210') \
            .with_tax_type(TaxType.NotUsed) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_030_level_ii_no_response(self):
        card = TestCards.amex_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(111.11) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('0', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_tax_type(TaxType.SalesTax) \
            .with_tax_amount(1.00) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_031_level_ii_no_response(self):
        card = TestCards.amex_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(111.12) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('0', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_po_number('9876543210') \
            .with_tax_type(TaxType.SalesTax) \
            .with_tax_amount(1.00) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    def test_032_level_ii_no_response(self):
        card = TestCards.amex_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(111.13) \
            .with_currency('USD') \
            .with_address(address) \
            .with_commercial_request(True) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('0', response.commercial_indicator)

        cpc_response = response.edit() \
            .with_po_number('9876543210') \
            .with_tax_type(TaxType.TaxExempt) \
            .execute('ecommerce')

        self.assertNotEqual(None, cpc_response)
        self.assertEqual('00', cpc_response.response_code,
                         cpc_response.response_message)

    # Prior / Voice authorization

    def test_033_offline_sale(self):
        card = TestCards.visa_manual()

        response = card.charge(17.01) \
            .with_currency('USD') \
            .with_modifier(TransactionModifier.Offline) \
            .with_offline_auth_code('654321') \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_033_offline_authorization(self):
        card = TestCards.visa_manual()

        response = card.authorize(17.10) \
            .with_currency('USD') \
            .with_modifier(TransactionModifier.Offline) \
            .with_offline_auth_code('654321') \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # Offline return

    def test_034_offline_return(self):
        card = TestCards.visa_manual()

        response = card.refund(15.15) \
            .with_currency('USD') \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # Online void / reversal

    def test_035_void_test_10(self):
        pass

    def test_036_void_test_20(self):
        pass

    # Advanced Fraud Screening

    @unittest.skip('AFS not configured')
    def test_037_fraud_prevention_sale(self):
        card = TestCards.visa_manual()

        response = card.charge(15000) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('FR', response.response_code,
                         response.response_message)

    @unittest.skip('AFS not configured')
    def test_038_fraud_prevention_return(self):
        card = TestCards.visa_manual()

        response = card.refund(15000) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('41', response.response_code,
                         response.response_message)

    # One Card / GSB / Prepaid

    @unittest.skipIf(use_prepaid == False, 'ignore prepaid')
    def test_037_balance_inquiry_gsb(self):
        card = TestCards.gsb_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.balance_inquiry() \
            .with_address(address) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    @unittest.skipIf(use_prepaid == False, 'ignore prepaid')
    def test_038_add_value_gsb(self):
        card = CreditTrackData()
        card.value = '%B6277220572999800^   /                         ^49121010557010000016000000?F;6277220572999800=49121010557010000016?'

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.add_value(15.00) \
            .with_currency('USD') \
            .with_address(address) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    @unittest.skipIf(use_prepaid == False, 'ignore prepaid')
    def test_039_charge_gsb(self):
        card = TestCards.gsb_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(2.05) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        void_response = response.void().execute('ecommerce')

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code,
                         void_response.response_message)

    @unittest.skipIf(use_prepaid == False, 'ignore prepaid')
    def test_040_charge_gsb(self):
        card = TestCards.gsb_manual()

        address = Address()
        address.street_address_1 = '6860'
        address.postal_code = '75024'

        response = card.charge(2.10) \
            .with_currency('USD') \
            .with_address(address) \
            .with_invoice_number('123456') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    @unittest.skipIf(use_prepaid == False, 'ignore prepaid')
    def test_041_void_gsb(self):
        pass

    # HMS Gift

    def test_042_activate_gift_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.activate(6.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_043_activate_gift_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.activate(7.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_044_add_value_gift_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.add_value(8.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_045_add_value_gift_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.add_value(9.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_046_balance_inquiry_gift_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.balance_inquiry().execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('10.00', response.balance_amount)

    def test_047_balance_inquiry_gift_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.balance_inquiry().execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('10.00', response.balance_amount)

    def test_048_replace_gift_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.replace_with(
            TestCards.gift_card_2_manual()).execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_049_replace_gift_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.replace_with(
            TestCards.gift_card_1_swipe()).execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_050_sale_gift_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.charge(1.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_051_sale_gift_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.charge(2.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_052_sale_gift_1_void(self):
        card = TestCards.gift_card_1_swipe()

        response = card.charge(1.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        void_response = response.void().execute('ecommerce')

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code,
                         void_response.response_message)

    def test_053_sale_gift_2_void(self):
        card = TestCards.gift_card_2_manual()

        response = card.charge(2.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        void_response = response.void().execute('ecommerce')

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code,
                         void_response.response_message)

    def test_054_void_gift(self):
        pass

    def test_055_reversal_gift_1(self):
        pass

    def test_056_reversal_gift_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.charge(2.00) \
            .with_currency('USD') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        # reverse based on card, not transaction id
        reverse_response = card.reverse(2.00).execute('ecommerce')

        self.assertNotEqual(None, reverse_response)
        self.assertEqual('00', reverse_response.response_code,
                         reverse_response.response_message)

    def test_057_deactivate_gift_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.deactivate().execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_058_receipts_messaging(self):
        pass

    # HMS Rewards

    def test_059_balance_inquiry_rewards_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.balance_inquiry().execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('0', response.points_balance_amount)

    def test_060_balance_inquiry_rewards_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.balance_inquiry().execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
        self.assertEqual('0', response.points_balance_amount)

    def test_061_create_alias_gift_1(self):
        response = GiftCard.create('9725550100', 'ecommerce')

        self.assertNotEqual(None, response)

    def test_062_create_alias_gift_2(self):
        response = GiftCard.create('9725550100', 'ecommerce')

        self.assertNotEqual(None, response)

    def test_063_add_alias_rewards_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.add_alias('9725550100').execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_064_add_alias_rewards_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.add_alias('9725550100').execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_065_remove_alias_rewards_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.remove_alias('9725550100').execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_066_redeem_rewards_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.charge(100) \
            .with_currency('points') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_067_redeem_rewards_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.charge(200) \
            .with_currency('points') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_068_redeem_rewards_2(self):
        card = GiftCard()
        card.alias = '9725550100'

        response = card.charge(300) \
            .with_currency('points') \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_069_reward_rewards_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.rewards(10).execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_070_reward_rewards_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.rewards(11).execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_071_replace_rewards_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.replace_with(
            TestCards.gift_card_2_manual()).execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_072_replace_rewards_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.replace_with(
            TestCards.gift_card_1_swipe()).execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_073_deactivate_rewards_1(self):
        card = TestCards.gift_card_1_swipe()

        response = card.deactivate().execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_074_deactivate_rewards_2(self):
        card = TestCards.gift_card_2_manual()

        response = card.deactivate().execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_075_receipts_messaging(self):
        pass

    def test_999_close_batch(self):
        try:
            response = BatchService.close_batch('ecommerce')
            self.assertNotEqual(None, response)
        except Exception as e:
            if str(e.message).find(self.BATCH_NOT_OPEN) != -1 or str(
                    e.message).find(self.BATCH_EMPTY) != -1:
                return
コード例 #18
0
class IntegrationGatewaysPorticoConnectorCreditTests(unittest.TestCase):
    '''
    Ensure credit transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w'
    config.service_url = 'https://cert.api2.heartlandportico.com'
    config.developer_id = '000000'
    config.version_number = '0000'

    ServicesContainer.configure(config)

    card = CreditCardData()
    card.number = '4111111111111111'
    card.exp_month = '12'
    card.exp_year = '2025'
    card.cvn = '123'
    card.card_holder_name = 'Joe Smith'

    track = CreditTrackData()
    track.value = '<E1050711%B4012001000000016^VI TEST CREDIT^251200000000000000000000?|LO04K0WFOmdkDz0um+GwUkILL8ZZOP6Zc4rCpZ9+kg2T3JBT4AEOilWTI|+++++++Dbbn04ekG|11;4012001000000016=25120000000000000000?|1u2F/aEhbdoPixyAPGyIDv3gBfF|+++++++Dbbn04ekG|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|>;'
    track.encryption_data = EncryptionData()
    track.encryption_data.version = '01'

    def test_credit_auth(self):
        response = self.card.authorize(14) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

        capture = response.capture(16).with_gratuity(2).execute()

        self.assertNotEqual(None, capture)
        self.assertEqual('00', capture.response_code)

    def test_credit_auth_with_convenience(self):
        response = self.card.authorize(14) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .with_convenience_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_auth_with_shipping(self):
        response = self.card.authorize(14) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .with_shipping_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_sale(self):
        response = self.card.charge(15) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_sale_with_convenience(self):
        response = self.card.charge(15) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .with_convenience_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_sale_with_shipping(self):
        response = self.card.charge(15) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .with_shipping_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_offline_auth(self):
        response = self.card.authorize(16) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_offline_auth_with_convenience(self):
        response = self.card.authorize(16) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .with_convenience_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_offline_auth_with_shipping(self):
        response = self.card.authorize(16) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .with_shipping_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_offline_sale(self):
        response = self.card.charge(17) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_offline_sale_with_convenience(self):
        response = self.card.charge(17) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .with_convenience_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_offline_sale_with_shipping(self):
        response = self.card.charge(17) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .with_shipping_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_refund(self):
        response = self.card.refund(16) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_reverse(self):
        response = self.card.reverse(15) \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_auth(self):
        response = self.track.authorize(14) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

        capture = response.capture(16).with_gratuity(2).execute()

        self.assertNotEqual(None, capture)
        self.assertEqual('00', capture.response_code)

    def test_credit_swipe_auth_with_convenience(self):
        response = self.track.authorize(14) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .with_convenience_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_auth_with_shipping(self):
        response = self.track.authorize(14) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .with_shipping_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_sale(self):
        response = self.track.charge(15) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_sale_with_convenience(self):
        response = self.track.charge(15) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .with_convenience_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_sale_with_shipping(self):
        response = self.track.charge(15) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .with_shipping_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_offline_auth(self):
        response = self.track.authorize(16) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_offline_auth_with_convenience(self):
        response = self.track.authorize(16) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .with_convenience_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_offline_auth_with_shipping(self):
        response = self.track.authorize(16) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .with_shipping_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_offline_sale(self):
        response = self.track.charge(17) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_offline_sale_with_convenience(self):
        response = self.track.charge(17) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .with_convenience_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_offline_sale_with_shipping(self):
        response = self.track.charge(17) \
            .with_currency('USD') \
            .with_offline_auth_code('123456') \
            .with_allow_duplicates(True) \
            .with_shipping_amt(2) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_balance_inquiry(self):
        response = self.track.balance_inquiry().execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_refund(self):
        response = self.track.refund(16) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_swipe_reverse(self):
        response = self.track.charge(19) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

        reverse_response = self.track.reverse(15) \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, reverse_response)
        self.assertEqual('00', reverse_response.response_code)

    def test_credit_swipe_verify(self):
        response = self.track.verify() \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_void_from_transaction_id(self):
        response = self.card.authorize(10) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

        void_response = Transaction.from_id(response.transaction_id) \
            .void() \
            .execute()

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code)

    def test_check_crypto_gold_standard(self):
        gold_config = ServicesConfig()
        gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
        gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

        ServicesContainer.configure(gold_config, 'gold standard')
        response = self.card.authorize(10)\
            .with_currency('USD')\
            .with_allow_duplicates(True)\
            .execute('gold standard')
        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #19
0
ファイル: test_ecommerce.py プロジェクト: slogsdon/python-sdk
class IntegrationGatewaysPorticoConnectorEbtTests(unittest.TestCase):
    '''
    Ensure ecommerce transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
    config.service_url = 'https://cert.api2.heartlandportico.com'

    ServicesContainer.configure(config, 'ecommerce')

    card = CreditCardData()
    card.number = '4012002000060016'
    card.exp_month = '12'
    card.exp_year = '2025'
    card.cvn = '123'

    def test_ecom_with_moto(self):
        ecom = ECommerceInfo()
        ecom.channel = ECommerceChannel.MOTO

        response = self.card.charge(9) \
            .with_currency('USD') \
            .with_ecommerce_info(ecom) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ecom_with_direct_market_ship_date(self):
        ecom = ECommerceInfo()
        ecom.channel = ECommerceChannel.ECOM
        ecom.ship_day = '25'
        ecom.ship_month = '12'

        response = self.card.charge(9) \
            .with_currency('USD') \
            .with_ecommerce_info(ecom) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ecom_with_direct_market_invoice_no_ship_date(self):
        response = self.card.charge(9) \
            .with_currency('USD') \
            .with_ecommerce_info(ECommerceInfo()) \
            .with_invoice_number('1234567890') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ecom_with_direct_market_invoice_and_ship_date(self):
        ecom = ECommerceInfo()
        ecom.channel = ECommerceChannel.ECOM
        ecom.ship_month = '25'
        ecom.ship_month = '12'

        response = self.card.charge(9) \
            .with_currency('USD') \
            .with_ecommerce_info(ecom) \
            .with_invoice_number('1234567890') \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ecom_with_secure_ecommerce(self):
        ecom = ECommerceInfo()
        ecom.channel = ECommerceChannel.ECOM
        ecom.payment_data_source = 'ApplePay'
        ecom.cavv = 'XXXXf98AAajXbDRg3HSUMAACAAA='
        ecom.eci = '5'

        response = self.card.charge(9) \
            .with_currency('USD') \
            .with_ecommerce_info(ecom) \
            .with_allow_duplicates(True) \
            .execute('ecommerce')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #20
0
class IntegrationGatewaysPorticoConnectorACHTests(unittest.TestCase):
    '''
    Ensure check transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
    config.service_url = 'https://cert.api2.heartlandportico.com'
    config.developer_id = '000000'
    config.version_number = '0000'

    ServicesContainer.configure(config, 'ach')

    address = Address()
    address.street_address_1 = '123 Main St.'
    address.city = 'Downtown'
    address.province = 'NJ'
    address.postal_code = '12345'

    check = ECheck()
    check.account_number = '24413815'
    check.routing_number = '490000018'
    check.check_type = CheckType.Personal
    check.sec_code = SecCode.PPD
    check.account_type = AccountType.Checking
    check.entry_mode = EntryMethod.Manual
    check.check_holder_name = 'John Doe'
    check.drivers_license_number = '09876543210'
    check.drivers_license_state = 'TX'
    check.phone_number = '8003214567'
    check.birth_year = '1997'
    check.ssn_last_4 = '4321'

    def test_check_sale(self):
        response = self.check.charge(11) \
            .with_currency('USD') \
            .with_address(self.address) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_check_void_from_transaction_id(self):
        response = self.check.charge(10) \
            .with_currency('USD') \
            .with_address(self.address) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

        void_response = Transaction.from_id(response.transaction_id, PaymentMethodType.ACH) \
            .void() \
            .execute('ach')

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code)

    def test_check_crypto_gold_standard(self):
        gold_config = ServicesConfig()
        gold_config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
        gold_config.service_url = 'https://cert.api2-c.heartlandportico.com'

        ServicesContainer.configure(gold_config, 'gold standard')

        response = self.check.charge(10)\
            .with_currency('USD')\
            .with_address(self.address)\
            .with_allow_duplicates(True)\
            .execute('gold standard')
        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #21
0
class IntegrationGatewaysPorticoConnectorCertificationEcommerceCheckTests(
        unittest.TestCase):
    '''
    Ensure check transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
    config.service_url = 'https://cert.api2.heartlandportico.com'

    ServicesContainer.configure(config, 'ach')

    address = Address()
    address.street_address_1 = '123 Main St.'
    address.city = 'Downtown'
    address.province = 'NJ'
    address.postal_code = '12345'

    def check(self, sec_code, check_type, account_type, check_name=None):
        check = ECheck()
        check.account_number = '24413815'
        check.routing_number = '490000018'
        check.check_type = check_type
        check.sec_code = sec_code
        check.account_type = account_type
        check.entry_mode = EntryMethod.Manual
        check.check_holder_name = 'John Doe'
        check.drivers_license_number = '09876543210'
        check.drivers_license_state = 'TX'
        check.phone_number = '8003214567'
        check.birth_year = '1997'
        check.ssn_last_4 = '4321'
        if check_name:
            check.check_name = check_name
        return check

    # ACH Debit - WEB

    def test_001_web_personal_checking(self):
        check = self.check(SecCode.WEB, CheckType.Personal,
                           AccountType.Checking)

        response = check.charge(23.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_002_web_business_checking(self):
        check = self.check(SecCode.WEB, CheckType.Business,
                           AccountType.Checking)

        response = check.charge(24.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_003_web_personal_savings(self):
        check = self.check(SecCode.WEB, CheckType.Personal,
                           AccountType.Savings)

        response = check.charge(25.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_004_web_business_savings(self):
        check = self.check(SecCode.WEB, CheckType.Business,
                           AccountType.Savings)

        response = check.charge(5.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
コード例 #22
0
ファイル: test_check.py プロジェクト: slogsdon/python-sdk
class IntegrationGatewaysPorticoConnectorCertificationACHTests(
        unittest.TestCase):
    '''
    Ensure check transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'
    config.service_url = 'https://cert.api2.heartlandportico.com'

    ServicesContainer.configure(config, 'ach')

    address = Address()
    address.street_address_1 = '123 Main St.'
    address.city = 'Downtown'
    address.province = 'NJ'
    address.postal_code = '12345'

    def check(self, sec_code, check_type, account_type, check_name=None):
        check = ECheck()
        check.account_number = '24413815'
        check.routing_number = '490000018'
        check.check_type = check_type
        check.sec_code = sec_code
        check.account_type = account_type
        check.entry_mode = EntryMethod.Manual
        check.check_holder_name = 'John Doe'
        check.drivers_license_number = '09876543210'
        check.drivers_license_state = 'TX'
        check.phone_number = '8003214567'
        check.birth_year = '1997'
        check.ssn_last_4 = '4321'
        if check_name:
            check.check_name = check_name
        return check

    # ACH Debit - Consumer

    def test_001_consumer_personal_checking(self):
        check = self.check(SecCode.PPD, CheckType.Personal,
                           AccountType.Checking)

        response = check.charge(11.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        # test case 25
        void_response = response.void().execute('ach')

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code,
                         void_response.response_message)

    def test_002_consumer_business_checking(self):
        check = self.check(SecCode.PPD, CheckType.Business,
                           AccountType.Checking)

        response = check.charge(12.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_003_consumer_personal_savings(self):
        check = self.check(SecCode.PPD, CheckType.Personal,
                           AccountType.Savings)

        response = check.charge(13.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_004_consumer_business_savings(self):
        check = self.check(SecCode.PPD, CheckType.Business,
                           AccountType.Savings)

        response = check.charge(14.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # ACH Debit - Corporate

    def test_005_corporate_personal_checking(self):
        check = self.check(SecCode.CCD, CheckType.Personal,
                           AccountType.Checking, 'Heartland Pays')

        response = check.charge(15.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

        # test case 26
        void_response = response.void().execute('ach')

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code,
                         void_response.response_message)

    def test_006_corporate_business_checking(self):
        check = self.check(SecCode.CCD, CheckType.Business,
                           AccountType.Checking, 'Heartland Pays')

        response = check.charge(16.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_007_corporate_personal_savings(self):
        check = self.check(SecCode.CCD, CheckType.Personal,
                           AccountType.Savings, 'Heartland Pays')

        response = check.charge(17.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_008_corporate_business_savings(self):
        check = self.check(SecCode.CCD, CheckType.Business,
                           AccountType.Savings, 'Heartland Pays')

        response = check.charge(18.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # ACH Debit - eGold

    def test_009_egold_personal_checking(self):
        check = self.check(SecCode.POP, CheckType.Personal,
                           AccountType.Checking)

        response = check.charge(11.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_010_egold_business_checking(self):
        check = self.check(SecCode.POP, CheckType.Business,
                           AccountType.Checking)

        response = check.charge(12.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_011_egold_personal_savings(self):
        check = self.check(SecCode.POP, CheckType.Personal,
                           AccountType.Savings)

        response = check.charge(13.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_012_egold_business_savings(self):
        check = self.check(SecCode.POP, CheckType.Business,
                           AccountType.Savings)

        response = check.charge(14.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # ACH Debit - eSilver

    def test_013_esilver_personal_checking(self):
        check = self.check(SecCode.POP, CheckType.Personal,
                           AccountType.Checking)

        response = check.charge(15.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_014_esilver_business_checking(self):
        check = self.check(SecCode.POP, CheckType.Business,
                           AccountType.Checking)

        response = check.charge(16.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_015_esilver_personal_savings(self):
        check = self.check(SecCode.POP, CheckType.Personal,
                           AccountType.Savings)

        response = check.charge(17.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_016_esilver_business_savings(self):
        check = self.check(SecCode.POP, CheckType.Business,
                           AccountType.Savings)

        response = check.charge(18.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # ACH Debit - eBronze

    @unittest.skip('eBronze support cannot be configured with the others')
    def test_017_ebronze_personal_checking(self):
        check = self.check(SecCode.EBronze, CheckType.Personal,
                           AccountType.Checking)

        response = check.charge(19.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    @unittest.skip('eBronze support cannot be configured with the others')
    def test_018_ebronze_business_checking(self):
        check = self.check(SecCode.EBronze, CheckType.Business,
                           AccountType.Checking)

        response = check.charge(20.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    @unittest.skip('eBronze support cannot be configured with the others')
    def test_019_ebronze_personal_savings(self):
        check = self.check(SecCode.EBronze, CheckType.Personal,
                           AccountType.Savings)

        response = check.charge(21.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    @unittest.skip('eBronze support cannot be configured with the others')
    def test_020_ebronze_business_savings(self):
        check = self.check(SecCode.EBronze, CheckType.Business,
                           AccountType.Savings)

        response = check.charge(22.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    # ACH Debit - WEB

    def test_021_web_personal_checking(self):
        check = self.check(SecCode.WEB, CheckType.Personal,
                           AccountType.Checking)

        response = check.charge(23.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_022_web_business_checking(self):
        check = self.check(SecCode.WEB, CheckType.Business,
                           AccountType.Checking)

        response = check.charge(24.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_023_web_personal_savings(self):
        check = self.check(SecCode.WEB, CheckType.Personal,
                           AccountType.Savings)

        response = check.charge(25.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_024_web_business_savings(self):
        check = self.check(SecCode.WEB, CheckType.Business,
                           AccountType.Savings)

        response = check.charge(5.00) \
            .with_currency('USD') \
            .with_address(self.address) \
            .with_allow_duplicates(True) \
            .execute('ach')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)
コード例 #23
0
class AuthorizationBuilderValidationTests(unittest.TestCase):
    '''
    Ensure AuthorizationBuilder validations work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w'
    config.service_url = 'https://cert.api2.heartlandportico.com'

    ServicesContainer.configure(config)

    card = CreditCardData()
    card.number = '4111111111111111'
    card.exp_month = '12'
    card.exp_year = '2025'
    card.cvn = '123'
    card.card_holder_name = 'Joe Smith'

    def test_credit_auth_no_amount(self):
        with self.assertRaises(BuilderException):
            self.card.authorize().execute()

    def test_credit_auth_no_currency(self):
        with self.assertRaises(BuilderException):
            self.card.authorize(14).execute()

    def test_credit_auth_no_payment_method(self):
        with self.assertRaises(BuilderException):
            self.card.authorize(14) \
                .with_currency('USD') \
                .with_payment_method(None) \
                .execute()

    def test_credit_auth_no_validation_error(self):
        try:
            self.card.authorize(14) \
                .with_currency('USD') \
                .with_allow_duplicates(True) \
                .execute()
        except BuilderException:
            self.fail(
                'Properly configured auth builder should not raise exception')

    def test_credit_sale_no_amount(self):
        with self.assertRaises(BuilderException):
            self.card.charge().execute()

    def test_credit_sale_no_currency(self):
        with self.assertRaises(BuilderException):
            self.card.charge(14).execute()

    def test_credit_sale_no_payment_method(self):
        with self.assertRaises(BuilderException):
            self.card.charge(14) \
                .with_currency('USD') \
                .with_payment_method(None) \
                .execute()

    def test_credit_offline_no_amount(self):
        with self.assertRaises(BuilderException):
            self.card.authorize() \
                .with_offline_auth_code('12345') \
                .execute()

    def test_credit_offline_no_currency(self):
        with self.assertRaises(BuilderException):
            self.card.authorize(14) \
                .with_offline_auth_code('12345') \
                .execute()

    def test_credit_offline_no_auth_code(self):
        with self.assertRaises(BuilderException):
            self.card.authorize(14) \
                .with_currency('USD') \
                .with_offline_auth_code(None) \
                .execute()
コード例 #24
0
class IntegrationGatewaysPorticoConnectorEbtTests(unittest.TestCase):
    '''
    Ensure EBT transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'
    config.service_url = 'https://cert.api2.heartlandportico.com'

    ServicesContainer.configure(config, 'ebt')

    card = EBTCardData()
    card.number = '4012002000060016'
    card.exp_month = '12'
    card.exp_year = '2025'
    card.cvn = '123'
    card.pin_block = '32539F50C245A6A93D123412324000AA'

    track = EBTTrackData()
    track.value = '<E1050711%B4012001000000016^VI TEST CREDIT^251200000000000000000000?|LO04K0WFOmdkDz0um+GwUkILL8ZZOP6Zc4rCpZ9+kg2T3JBT4AEOilWTI|+++++++Dbbn04ekG|11;4012001000000016=25120000000000000000?|1u2F/aEhbdoPixyAPGyIDv3gBfF|+++++++Dbbn04ekG|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|>'
    track.pin_block = '32539F50C245A6A93D123412324000AA'
    track.encryption_data = EncryptionData()
    track.encryption_data.version = '01'

    def test_ebt_balance_inquiry(self):
        response = self.card.balance_inquiry().execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ebt_sale(self):
        response = self.card.charge(17.01) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute('ebt')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ebt_refund(self):
        response = self.card.refund(16.01) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute('ebt')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ebt_track_balance_inquiry(self):
        response = self.track.balance_inquiry().execute()

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ebt_track_sale(self):
        response = self.track.charge(17.01) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute('ebt')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ebt_track_refund(self):
        response = self.track.refund(16.01) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute('ebt')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_ebt_cannot_refund_from_transaction_id_only(self):
        with self.assertRaises(UnsupportedTransactionException):
            Transaction.from_id("1234567890", PaymentMethodType.EBT) \
                .refund() \
                .with_currency('USD') \
                .execute('ebt')
コード例 #25
0
ファイル: test_gift.py プロジェクト: sandeep-yedla/python-sdk
class IntegrationGatewaysPorticoConnectorEbtTests(unittest.TestCase):
    '''
    Ensure gift transactions work
    '''

    config = ServicesConfig()
    config.secret_api_key = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'
    config.service_url = 'https://cert.api2.heartlandportico.com'
    config.developer_id = '000000'
    config.version_number = '0000'

    ServicesContainer.configure(config, 'gift')

    card = GiftCard()
    card.number = '5022440000000000007'

    track = GiftCard()
    track.track_data = '%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?'

    def test_gift_create(self):
        new_card = GiftCard.create('2145550199', config_name='gift')

        self.assertNotEqual(None, new_card)
        self.assertNotEqual(None, new_card.number)
        self.assertNotEqual(None, new_card.alias)
        self.assertNotEqual(None, new_card.pin)

    def test_gift_add_alias(self):
        response = self.card.add_alias('2145550199').execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_add_value(self):
        response = self.card.add_value(10) \
            .with_currency('USD') \
            .execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_balance_inquiry(self):
        response = self.card.balance_inquiry().execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_sale(self):
        response = self.card.charge(10) \
            .with_currency('USD') \
            .execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_deactivate(self):
        response = self.card.deactivate().execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_remove_alias(self):
        response = self.card.remove_alias('2195550199').execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_replace(self):
        response = self.card.replace_with(self.track).execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_reverse(self):
        response = self.card.reverse(10).execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_reward(self):
        response = self.card.rewards(10).execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_add_alias(self):
        response = self.track.add_alias('2145550199').execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_add_value(self):
        response = self.track.add_value(10) \
            .with_currency('USD') \
            .execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_balance_inquiry(self):
        response = self.track.balance_inquiry().execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_sale(self):
        response = self.track.charge(10) \
            .with_currency('USD') \
            .execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_deactivate(self):
        response = self.track.deactivate().execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_remove_alias(self):
        response = self.track.remove_alias('2195550199').execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_replace(self):
        response = self.track.replace_with(self.card).execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_reverse(self):
        response = self.track.reverse(10).execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_gift_track_reward(self):
        response = self.track.rewards(10).execute('gift')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #26
0
class IntegrationGatewaysRealexConnectorCreditTests(unittest.TestCase):
    '''
    Ensure Credit transactions works
    '''

    config = ServicesConfig()
    config.merchant_id = 'heartlandgpsandbox'
    config.account_id = 'api'
    config.shared_secret = 'secret'
    config.rebate_password = '******'
    config.refund_password = '******'
    config.service_url = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'

    ServicesContainer.configure(config, "realex")

    card = CreditCardData()
    card.number = '4111111111111111'
    card.exp_month = '12'
    card.exp_year = '2025'
    card.cvn = '123'
    card.card_holder_name = 'Joe Smith'

    def test_credit_authorization(self):
        response = self.card.authorize(14) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute("realex")

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

        capture = response.capture(14).execute("realex")

        self.assertNotEqual(None, capture)
        self.assertEqual('00', capture.response_code)

    def test_credit_sale(self):
        response = self.card.charge(15) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute("realex")

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_sale_with_recurring(self):
        response = self.card.charge(15) \
            .with_currency('USD') \
            .with_recurring_info(RecurringType.Fixed, RecurringSequence.First) \
            .with_allow_duplicates(True) \
            .execute("realex")

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_refund(self):
        response = self.card.refund(16) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute("realex")

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_rebate(self):
        response = self.card.charge(17) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute("realex")

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

        rebate = response.refund(17) \
            .with_currency('USD') \
            .execute("realex")

        self.assertNotEqual(None, rebate)
        self.assertEqual('00', rebate.response_code)

    def test_credit_void(self):
        response = self.card.charge(15) \
            .with_currency('USD') \
            .with_allow_duplicates(True) \
            .execute("realex")

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

        void_response = response.void().execute("realex")

        self.assertNotEqual(None, void_response)
        self.assertEqual('00', void_response.response_code)

    def test_credit_verify(self):
        response = self.card.verify() \
            .with_allow_duplicates(True) \
            .execute("realex")

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)

    def test_credit_fraud_response(self):
        billing_address = Address()
        billing_address.street_address_1 = 'Flat 123'
        billing_address.street_address_2 = 'House 456'
        billing_address.street_address_3 = 'Cul-De-Sac'
        billing_address.city = 'Halifax'
        billing_address.province = 'West Yorkshire'
        billing_address.state = 'Yorkshire and the Humber'
        billing_address.country = 'GB'
        billing_address.postal_code = 'E77 4QJ'

        shipping_address = Address()
        shipping_address.street_address_1 = 'House 456'
        shipping_address.street_address_2 = '987 The Street'
        shipping_address.street_address_3 = 'Basement Flat'
        shipping_address.city = 'Chicago'
        shipping_address.state = 'Illinois'
        shipping_address.province = 'Mid West'
        shipping_address.country = 'US'
        shipping_address.postal_code = '5001'

        response = self.card.charge(199.99) \
            .with_currency('EUR') \
            .with_address(billing_address, AddressType.Billing) \
            .with_address(shipping_address, AddressType.Shipping) \
            .with_product_id('SID9838383') \
            .with_client_transaction_id('Car Part HV') \
            .with_customer_id('E8953893489') \
            .with_customer_ip_address('123.123.123.123') \
            .execute("realex")

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code)
コード例 #27
0
ファイル: test_recurring.py プロジェクト: pseudoGal/SDK
class IntegrationGatewaysRealexConnectorRecurringTests(unittest.TestCase):
    '''
    Ensure Recurring transactions works
    '''

    config = ServicesConfig()
    config.merchant_id = 'heartlandgpsandbox'
    config.account_id = 'api'
    config.shared_secret = 'secret'
    config.rebate_password = '******'
    config.refund_password = '******'
    config.service_url = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'

    ServicesContainer.configure(config, "realex")

    card = CreditCardData()
    card.number = '4263970000005262'
    card.exp_month = '05'
    card.exp_year = '2019'
    card.cvn = '123'
    card.card_holder_name = 'James Mason'

    new_customer = Customer()
    new_customer.key = '{}-Realex'.format(datetime.now().strftime('%Y%m%d'))
    new_customer.title = 'Mr.'
    new_customer.first_name = 'James'
    new_customer.last_name = 'Mason'
    new_customer.company = 'Realex Payments'
    new_customer.address = Address()
    new_customer.address.street_address_1 = 'Flat 123'
    new_customer.address.street_address_2 = 'House 456'
    new_customer.address.street_address_3 = 'The Cul-De-Sac'
    new_customer.address.city = 'Halifax'
    new_customer.address.province = 'West Yorkshire'
    new_customer.address.postal_code = 'W6 9HR'
    new_customer.address.country = 'United Kingdom'
    new_customer.home_phone = '+35312345678'
    new_customer.work_phone = '+3531987654321'
    new_customer.fax = '+24546871258'
    new_customer.mobile_phone = '+25544778544'
    new_customer.email = '*****@*****.**'
    new_customer.comments = 'Campaign Ref E7373G'

    def customer_id(self):
        return '{}-Realex'.format(datetime.now().strftime('%Y%m%d'))

    def payment_id(self, t):
        return '{}-Realex-{}'.format(datetime.now().strftime('%Y%m%d'), t)

    def test_001a_create_customer(self):
        try:
            customer = self.new_customer.create('realex')
            self.assertNotEqual(None, customer)
        except GatewayException as exc:
            if int(exc.response_code) != 501:
                raise exc

    def test_001b_create_payment_method(self):
        try:
            payment_method = self.new_customer.add_payment_method(
                self.payment_id('credit'), self.card).create('realex')
            self.assertNotEqual(None, payment_method)
        except GatewayException as exc:
            if int(exc.response_code) != 520:
                raise exc

    def test_002a_edit_customer(self):
        customer = Customer()
        customer.key = self.customer_id()
        customer.first_name = 'Perry'
        customer.save_changes('realex')

    def test_002b_edit_payment_method(self):
        payment_method = RecurringPaymentMethod(self.customer_id(),
                                                self.payment_id('Credit'))
        payment_method.payment_method = CreditCardData()
        payment_method.payment_method.number = '5425230000004415'
        payment_method.payment_method.exp_month = '10'
        payment_method.payment_method.exp_year = '2020'
        payment_method.payment_method.card_holder_name = 'Philip Marlowe'
        payment_method.save_changes('realex')

    def test_002c_edit_payment_method_exp_date_only(self):
        payment_method = RecurringPaymentMethod(self.customer_id(),
                                                self.payment_id('Credit'))
        payment_method.payment_method = CreditCardData()
        payment_method.payment_method.card_type = 'MC'
        payment_method.payment_method.exp_month = '10'
        payment_method.payment_method.exp_year = '2020'
        payment_method.payment_method.card_holder_name = 'Philip Marlowe'
        payment_method.save_changes('realex')

    def test_003_find_customer_throws_exception(self):
        with self.assertRaises(UnsupportedTransactionException):
            Customer.find(self.customer_id(), 'realex')

    def test_004a_charge_stored_card(self):
        payment_method = RecurringPaymentMethod(self.customer_id(),
                                                self.payment_id('Credit'))

        response = payment_method.charge(10) \
            .with_currency('USD') \
            .with_cvn('123') \
            .execute('realex')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_004b_verify_stored_card(self):
        payment_method = RecurringPaymentMethod(self.customer_id(),
                                                self.payment_id('Credit'))

        response = payment_method.verify() \
            .with_cvn('123') \
            .execute('realex')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_004c_refund_stored_card(self):
        payment_method = RecurringPaymentMethod(self.customer_id(),
                                                self.payment_id('Credit'))

        response = payment_method.refund(10.01) \
            .with_currency('USD') \
            .execute('realex')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_005_recurring_payment(self):
        payment_method = RecurringPaymentMethod(self.customer_id(),
                                                self.payment_id('Credit'))

        response = payment_method.charge(12) \
            .with_currency('USD') \
            .with_recurring_info(RecurringType.Fixed, RecurringSequence.First) \
            .execute('realex')

        self.assertNotEqual(None, response)
        self.assertEqual('00', response.response_code,
                         response.response_message)

    def test_006_delete_payment_method(self):
        payment_method = RecurringPaymentMethod(self.customer_id(),
                                                self.payment_id('Credit'))
        payment_method.delete(config_name='realex')