Exemple #1
0
    def test_token(self):
        billing_address = Address()
        billing_address.country_code = "NL"
        customer = CustomerToken()
        customer.billing_address = billing_address
        card_without_ccv = CardWithoutCvv()
        card_without_ccv.cardholder_name = "Jan"
        card_without_ccv.issue_number = "12"
        card_without_ccv.card_number = "4567350000427977"
        card_without_ccv.expiry_date = "0820"
        card_data = TokenCardData()
        card_data.card_without_cvv = card_without_ccv
        card = TokenCard()
        card.customer = customer
        card.data = card_data
        create_token_request = CreateTokenRequest()
        create_token_request.payment_product_id = 1
        create_token_request.card = card

        with init_utils.create_client() as client:
            token_response = client.merchant(MERCHANT_ID).tokens().create(
                create_token_request)

            self.assertIsNotNone(token_response.token)

            client.merchant(MERCHANT_ID).tokens().delete(
                token_response.token, DeleteTokenParams())
    def test_payment_products(self):
        """Test if products function"""
        params = FindProductsParams()
        params.country_code = "NL"
        params.currency_code = "EUR"

        with init_utils.create_client() as client:
            response = client.merchant(MERCHANT_ID).products().find(params)
        self.assertGreater(len(response.payment_products), 0)
Exemple #3
0
    def test_payment_product_groups(self):
        """Test if product groups function"""
        params = GetProductgroupParams()
        params.country_code = "NL"
        params.currency_code = "EUR"

        with init_utils.create_client() as client:
            response = client.merchant(MERCHANT_ID).productgroups().get(
                "cards", params)
        self.assertEqual("cards", response.id)
    def test_payment_product_directories(self):
        """Test if product directories function"""
        params = DirectoryParams()
        params.country_code = "NL"
        params.currency_code = "EUR"

        with init_utils.create_client() as client:
            response = client.merchant(MERCHANT_ID).products().directory(
                809, params)
        self.assertGreater(len(response.entries), 0)
Exemple #5
0
    def test_payment_product_groups(self):
        """Test if product groups function"""
        params = GetProductGroupsParams()
        params.country_code = "BE"
        params.currency_code = "EUR"

        with init_utils.create_client() as client:
            response = client.merchant(MERCHANT_ID).product_groups().get_product_groups(params)
        self.assertIsNotNone(response.payment_product_groups)
        self.assertGreater(len(response.payment_product_groups), 0)
    def test_convert_amount(self):
        """Test if the convert amount service can connect to the server"""
        request = ConvertAmountParams()
        request.amount = 123L
        request.source = "USD"
        request.target = "EUR"

        with init_utils.create_client() as client:
            response = client.merchant(MERCHANT_ID).services().convert_amount(
                request)
        # actual convert amount may vary due to changing rates, so simply check if there is an amount
        self.assertIsNotNone(response.converted_amount)
        self.assertGreater(int(response.converted_amount), 0)
Exemple #7
0
    def test_idempotence(self):
        """Test that the client can successfully detect that an idempotent request is sent twice"""

        amount_of_money = AmountOfMoney()
        amount_of_money.currency_code = "EUR"
        amount_of_money.amount = 100L
        billing_address = Address()
        billing_address.country_code = "NL"
        customer = Customer()
        customer.locale = "en"
        customer.billing_address = billing_address
        order = Order()
        order.amount_of_money = amount_of_money
        order.customer = customer
        payment_product_input = RedirectPaymentProduct809SpecificInput()
        payment_product_input.issuer_id = "INGBNL2A"
        payment_method_input = RedirectPaymentMethodSpecificInput()
        payment_method_input.return_url = "http://example.com"
        payment_method_input.payment_product_id = 809
        payment_method_input.payment_product809_specific_input = payment_product_input
        body = CreatePaymentRequest()
        body.order = order
        body.redirect_payment_method_specific_input = payment_method_input
        idempotence_key = str(uuid.uuid4())
        context = CallContext(idempotence_key)

        with init_utils.create_client() as client:
            def do_create_payment():
                # For this test it doesn't matter if the response is successful or declined,
                # as long as idempotence is handled correctly
                try:
                    return client.merchant(MERCHANT_ID).payments().create(body, context)
                except DeclinedPaymentException as e:
                    return e.create_payment_result

            result = do_create_payment()

            payment_id = result.payment.id
            status = result.payment.status

            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNone(context.idempotence_request_timestamp)

            result_2 = do_create_payment()

            payment_id_2 = result_2.payment.id
            status_2 = result_2.payment.status
            self.assertEqual(payment_id, payment_id_2)
            self.assertEqual(status, status_2)
            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNotNone(context.idempotence_request_timestamp)
Exemple #8
0
    def test_idempotence(self):
        """Test that the client can successfully detect that an idempotent request is sent twice"""

        amount_of_money = AmountOfMoney()
        amount_of_money.currency_code = "EUR"
        amount_of_money.amount = 100

        billing_address = Address()
        billing_address.country_code = "BE"

        customer = Customer()
        customer.locale = "en"
        customer.billing_address = billing_address

        order = Order()
        order.amount_of_money = amount_of_money
        order.customer = customer

        card = Card()
        card.card_number = "4567350000427977"
        card.cardholder_name = "Wile E. Coyote"
        card.cvv = "123"
        card.expiry_date = "1234"

        payment_method_input = CardPaymentMethodSpecificInput()
        payment_method_input.return_url = "http://example.com"
        payment_method_input.payment_product_id = 1
        payment_method_input.card = card

        body = CreatePaymentRequest()
        body.order = order
        body.card_payment_method_specific_input = payment_method_input
        idempotence_key = str(uuid.uuid4())
        context = CallContext(idempotence_key)

        with init_utils.create_client() as client:
            response = client.merchant(MERCHANT_ID).payments().create_payment(
                body, context)

            payment_id = response.payment.id
            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNone(context.idempotence_request_timestamp)

            response_2 = client.merchant(
                MERCHANT_ID).payments().create_payment(body, context)

            payment_id_2 = response_2.payment.id
            self.assertEqual(payment_id, payment_id_2)
            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNotNone(context.idempotence_request_timestamp)
Exemple #9
0
    def test_idempotence(self):
        """Test that the client can successfully detect that an idempotent request is sent twice"""

        amount_of_money = AmountOfMoney()
        amount_of_money.currency_code = "EUR"
        amount_of_money.amount = 100L
        billing_address = Address()
        billing_address.country_code = "NL"
        customer = Customer()
        customer.locale = "en"
        customer.billing_address = billing_address
        order = Order()
        order.amount_of_money = amount_of_money
        order.customer = customer
        payment_product_input = RedirectPaymentProduct809SpecificInput()
        payment_product_input.issuer_id = "INGBNL2A"
        payment_method_input = RedirectPaymentMethodSpecificInput()
        payment_method_input.return_url = "http://example.com"
        payment_method_input.payment_product_id = 809
        payment_method_input.payment_product809_specific_input = payment_product_input
        body = CreatePaymentRequest()
        body.order = order
        body.redirect_payment_method_specific_input = payment_method_input
        idempotence_key = str(uuid.uuid4())
        context = CallContext(idempotence_key)

        with init_utils.create_client() as client:
            response = client.merchant(MERCHANT_ID).payments().create(
                body, context)

            payment_id = response.payment.id
            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNone(context.idempotence_request_timestamp)

            response_2 = client.merchant(MERCHANT_ID).payments().create(
                body, context)

            payment_id_2 = response_2.payment.id
            self.assertEqual(payment_id, payment_id_2)
            self.assertEqual(idempotence_key, context.idempotence_key)
            self.assertIsNotNone(context.idempotence_request_timestamp)
    def test_risk_assessments(self):
        """Test if the risk assessments service functions"""
        bank_account_bban = BankAccountBban()
        bank_account_bban.country_code = "DE"
        bank_account_bban.account_number = "0532013000"
        bank_account_bban.bank_code = "37040044"
        amount_of_money = AmountOfMoney()
        amount_of_money.amount = 100
        amount_of_money.currency_code = "EUR"
        customer = CustomerRiskAssessment()
        customer.locale = "en_GB"
        order = OrderRiskAssessment()
        order.amount_of_money = amount_of_money
        order.customer = customer
        body = RiskAssessmentBankAccount()
        body.order = order
        body.bank_account_bban = bank_account_bban

        with init_utils.create_client() as client:
            response = client.merchant(
                MERCHANT_ID).riskassessments().bankaccounts(body)
        self.assertGreater(len(response.results), 0)
Exemple #11
0
    def test_services(self):
        with init_utils.create_client() as client:
            response = client.merchant(
                MERCHANT_ID).services().test_connection()

            self.assertIsNotNone(response.result)