コード例 #1
0
    def test_purchase_with_test_cards(self):
        # This test requires valid test numbers
        gateway = GlobalIrisGateway()
        if not gateway.test_mode:
            self.fail("MERCHANT_TEST_MODE must be true for running tests")

        for card in self._get_test_cards():
            received_signals = []

            def success(sender, **kwargs):
                received_signals.append(kwargs.get("signal"))

            transaction_was_successful.connect(success)

            def fail(sender, **kwargs):
                received_signals.append(kwargs.get("signal"))

            transaction_was_unsuccessful.connect(fail)

            # Cards with invalid numbers will get caught by billing code, not by
            # the gateway itself.
            try:
                gateway.validate_card(card)
            except CardNotSupported:
                self.assertNotEqual(card.expected_response_code, "00")
                continue  # skip the rest

            response = gateway.purchase(Decimal("45.00"),
                                        card,
                                        options={
                                            'order_id': self.get_order_id(),
                                        })

            actual_rc = response['response_code']
            expected_rc = card.expected_response_code

            self.assertEqual(
                actual_rc, expected_rc, "%s != %s - card %s, message: %s" %
                (actual_rc, expected_rc, card.number, response['message']))
            if card.expected_response_code == "00":
                self.assertEqual(response['status'], 'SUCCESS')
                self.assertEqual(received_signals,
                                 [transaction_was_successful])
            else:
                self.assertEqual(response['status'], 'FAILURE')
                self.assertEqual(received_signals,
                                 [transaction_was_unsuccessful])
コード例 #2
0
ファイル: global_iris_tests.py プロジェクト: akn/merchant
    def test_config_for_card_type(self):
        """
        Test that the GateWay object can pick the correct config depending on the card type.
        """
        gateway = GlobalIrisGateway(config={
                'LIVE': dict(SHARED_SECRET="mysecret",
                             MERCHANT_ID="thestore",
                             ACCOUNT="theaccount"),
                'LIVE_AMEX': dict(SHARED_SECRET="mysecret2",
                                  MERCHANT_ID="thestore",
                                  ACCOUNT="theaccountamex"),
                }, test_mode=False)

        vc = self.get_visa_card()
        self.assertTrue(gateway.validate_card(vc)) # needed for side effects

        ac = self.get_amex_card()
        self.assertTrue(gateway.validate_card(ac))

        self.assertEqual("theaccount", gateway.get_config(vc).account)
        self.assertEqual("theaccountamex", gateway.get_config(ac).account)
コード例 #3
0
    def test_config_for_card_type(self):
        """
        Test that the GateWay object can pick the correct config depending on the card type.
        """
        gateway = GlobalIrisGateway(config={
                'LIVE': dict(SHARED_SECRET="mysecret",
                             MERCHANT_ID="thestore",
                             ACCOUNT="theaccount"),
                'LIVE_AMEX': dict(SHARED_SECRET="mysecret2",
                                  MERCHANT_ID="thestore",
                                  ACCOUNT="theaccountamex"),
                }, test_mode=False)

        vc = self.get_visa_card()
        self.assertTrue(gateway.validate_card(vc)) # needed for side effects

        ac = self.get_amex_card()
        self.assertTrue(gateway.validate_card(ac))

        self.assertEqual("theaccount", gateway.get_config(vc).account)
        self.assertEqual("theaccountamex", gateway.get_config(ac).account)
コード例 #4
0
ファイル: global_iris_tests.py プロジェクト: akn/merchant
    def test_purchase_with_test_cards(self):
        # This test requires valid test numbers
        gateway = GlobalIrisGateway()
        if not gateway.test_mode:
            self.fail("MERCHANT_TEST_MODE must be true for running tests")

        for card in self._get_test_cards():
            received_signals = []
            def success(sender, **kwargs):
                received_signals.append(kwargs.get("signal"))
            transaction_was_successful.connect(success)

            def fail(sender, **kwargs):
                received_signals.append(kwargs.get("signal"))
            transaction_was_unsuccessful.connect(fail)

            # Cards with invalid numbers will get caught by billing code, not by
            # the gateway itself.
            try:
                gateway.validate_card(card)
            except CardNotSupported:
                self.assertNotEqual(card.expected_response_code, "00")
                continue # skip the rest


            response = gateway.purchase(Decimal("45.00"), card,
                                        options={'order_id': self.get_order_id(),
                                                 })

            actual_rc = response['response_code']
            expected_rc = card.expected_response_code

            self.assertEqual(actual_rc, expected_rc,
                             "%s != %s - card %s, message: %s" % (actual_rc, expected_rc, card.number, response['message']))
            if card.expected_response_code == "00":
                self.assertEqual(response['status'], 'SUCCESS')
                self.assertEqual(received_signals, [transaction_was_successful])
            else:
                self.assertEqual(response['status'], 'FAILURE')
                self.assertEqual(received_signals, [transaction_was_unsuccessful])