diff --git a/checkout_sdk/common/enums.py b/checkout_sdk/common/enums.py index 6b6fbd66..160ee0e5 100644 --- a/checkout_sdk/common/enums.py +++ b/checkout_sdk/common/enums.py @@ -484,6 +484,7 @@ class InstrumentType(str, Enum): BANK_ACCOUNT = 'bank_account' TOKEN = 'token' CARD = 'card' + SEPA = 'sepa' CARD_TOKEN = 'card_token' diff --git a/checkout_sdk/instruments/instruments.py b/checkout_sdk/instruments/instruments.py index 3b4926c5..6c8a6f45 100644 --- a/checkout_sdk/instruments/instruments.py +++ b/checkout_sdk/instruments/instruments.py @@ -1,7 +1,9 @@ +from datetime import datetime from enum import Enum from checkout_sdk.common.common import BankDetails, UpdateCustomerRequest, AccountHolder, Phone from checkout_sdk.common.enums import AccountType, AccountHolderType, Currency, Country, InstrumentType +from checkout_sdk.payments.payments import PaymentType # Create @@ -29,6 +31,24 @@ def __init__(self): super().__init__(InstrumentType.TOKEN) +class InstrumentData: + account_number: str + country: Country + currency: Currency + payment_type: PaymentType + mandate_id: str + date_of_signature: datetime + + +class CreateSepaInstrumentRequest(CreateInstrumentRequest): + token: str + instrument_data: InstrumentData + account_holder: AccountHolder + + def __init__(self): + super().__init__(InstrumentType.SEPA) + + class CreateBankAccountInstrumentRequest(CreateInstrumentRequest): account_type: AccountType account_number: str @@ -41,6 +61,7 @@ class CreateBankAccountInstrumentRequest(CreateInstrumentRequest): processing_channel_id: str account_holder: AccountHolder bank_details: BankDetails + bank: BankDetails def __init__(self): super().__init__(InstrumentType.BANK_ACCOUNT) diff --git a/checkout_sdk/payments/payments.py b/checkout_sdk/payments/payments.py index 4f98a6e5..a5e662ef 100644 --- a/checkout_sdk/payments/payments.py +++ b/checkout_sdk/payments/payments.py @@ -471,6 +471,7 @@ class PaymentRequest: metadata: dict items: list # payments.Product retry: PaymentRetryRequest + instruction: PaymentInstruction # Payout Request Source diff --git a/tests/instruments/instruments_integration_test.py b/tests/instruments/instruments_integration_test.py index 1860f6fa..6eaf5b0a 100644 --- a/tests/instruments/instruments_integration_test.py +++ b/tests/instruments/instruments_integration_test.py @@ -6,12 +6,37 @@ from checkout_sdk.common.enums import AccountHolderType, Country, Currency from checkout_sdk.exception import CheckoutApiException from checkout_sdk.instruments.instruments import CreateTokenInstrumentRequest, CreateCustomerInstrumentRequest, \ - UpdateCardInstrumentRequest, BankAccountFieldQuery, PaymentNetwork + UpdateCardInstrumentRequest, BankAccountFieldQuery, PaymentNetwork, CreateSepaInstrumentRequest, InstrumentData +from checkout_sdk.payments.payments import PaymentType from checkout_sdk.tokens.tokens import CardTokenRequest from tests.checkout_test_utils import assert_response, phone, VisaCard, address, random_email, FIRST_NAME, LAST_NAME, \ NAME +def test_should_create_sepa_instrument(default_api): + instruments_data = InstrumentData + instruments_data.account_number = "FR7630006000011234567890189" + instruments_data.country = Country.FR + instruments_data.currency = Currency.EUR + instruments_data.payment_type = PaymentType.RECURRING + + account_holder = AccountHolder() + account_holder.first_name = "John" + account_holder.last_name = "Smith" + account_holder.phone = phone() + account_holder.billing_address = address() + + instruments_sepa_request = CreateSepaInstrumentRequest() + instruments_sepa_request.instrument_data = instruments_data + instruments_sepa_request.account_holder = account_holder + + create_instrument_response = default_api.instruments.create(instruments_sepa_request) + assert_response(create_instrument_response, + 'id', + 'type', + 'fingerprint') + + def test_should_create_and_get_instrument(default_api): create_instrument_response = create_token_instrument(default_api) assert_response(create_instrument_response, diff --git a/tests/payments/request_apm_payments_integration_test.py b/tests/payments/request_apm_payments_integration_test.py index 02151e2c..f9fbea8f 100644 --- a/tests/payments/request_apm_payments_integration_test.py +++ b/tests/payments/request_apm_payments_integration_test.py @@ -460,7 +460,6 @@ def test_should_make_trustly_payment(default_api): payment_request=payment_request) -@pytest.mark.skip(reason='unstable') def test_should_make_sepa_payment(default_api): payment_request = PaymentRequest() payment_request.source = RequestSepaSource()