Skip to content

Commit 2672d6e

Browse files
Add SEPA Direct Debit Core Support (#159)
1 parent f676cf3 commit 2672d6e

File tree

5 files changed

+49
-2
lines changed

5 files changed

+49
-2
lines changed

checkout_sdk/common/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ class InstrumentType(str, Enum):
484484
BANK_ACCOUNT = 'bank_account'
485485
TOKEN = 'token'
486486
CARD = 'card'
487+
SEPA = 'sepa'
487488
CARD_TOKEN = 'card_token'
488489

489490

checkout_sdk/instruments/instruments.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from datetime import datetime
12
from enum import Enum
23

34
from checkout_sdk.common.common import BankDetails, UpdateCustomerRequest, AccountHolder, Phone
45
from checkout_sdk.common.enums import AccountType, AccountHolderType, Currency, Country, InstrumentType
6+
from checkout_sdk.payments.payments import PaymentType
57

68

79
# Create
@@ -29,6 +31,24 @@ def __init__(self):
2931
super().__init__(InstrumentType.TOKEN)
3032

3133

34+
class InstrumentData:
35+
account_number: str
36+
country: Country
37+
currency: Currency
38+
payment_type: PaymentType
39+
mandate_id: str
40+
date_of_signature: datetime
41+
42+
43+
class CreateSepaInstrumentRequest(CreateInstrumentRequest):
44+
token: str
45+
instrument_data: InstrumentData
46+
account_holder: AccountHolder
47+
48+
def __init__(self):
49+
super().__init__(InstrumentType.SEPA)
50+
51+
3252
class CreateBankAccountInstrumentRequest(CreateInstrumentRequest):
3353
account_type: AccountType
3454
account_number: str
@@ -41,6 +61,7 @@ class CreateBankAccountInstrumentRequest(CreateInstrumentRequest):
4161
processing_channel_id: str
4262
account_holder: AccountHolder
4363
bank_details: BankDetails
64+
bank: BankDetails
4465

4566
def __init__(self):
4667
super().__init__(InstrumentType.BANK_ACCOUNT)

checkout_sdk/payments/payments.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ class PaymentRequest:
471471
metadata: dict
472472
items: list # payments.Product
473473
retry: PaymentRetryRequest
474+
instruction: PaymentInstruction
474475

475476

476477
# Payout Request Source

tests/instruments/instruments_integration_test.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,37 @@
66
from checkout_sdk.common.enums import AccountHolderType, Country, Currency
77
from checkout_sdk.exception import CheckoutApiException
88
from checkout_sdk.instruments.instruments import CreateTokenInstrumentRequest, CreateCustomerInstrumentRequest, \
9-
UpdateCardInstrumentRequest, BankAccountFieldQuery, PaymentNetwork
9+
UpdateCardInstrumentRequest, BankAccountFieldQuery, PaymentNetwork, CreateSepaInstrumentRequest, InstrumentData
10+
from checkout_sdk.payments.payments import PaymentType
1011
from checkout_sdk.tokens.tokens import CardTokenRequest
1112
from tests.checkout_test_utils import assert_response, phone, VisaCard, address, random_email, FIRST_NAME, LAST_NAME, \
1213
NAME
1314

1415

16+
def test_should_create_sepa_instrument(default_api):
17+
instruments_data = InstrumentData
18+
instruments_data.account_number = "FR7630006000011234567890189"
19+
instruments_data.country = Country.FR
20+
instruments_data.currency = Currency.EUR
21+
instruments_data.payment_type = PaymentType.RECURRING
22+
23+
account_holder = AccountHolder()
24+
account_holder.first_name = "John"
25+
account_holder.last_name = "Smith"
26+
account_holder.phone = phone()
27+
account_holder.billing_address = address()
28+
29+
instruments_sepa_request = CreateSepaInstrumentRequest()
30+
instruments_sepa_request.instrument_data = instruments_data
31+
instruments_sepa_request.account_holder = account_holder
32+
33+
create_instrument_response = default_api.instruments.create(instruments_sepa_request)
34+
assert_response(create_instrument_response,
35+
'id',
36+
'type',
37+
'fingerprint')
38+
39+
1540
def test_should_create_and_get_instrument(default_api):
1641
create_instrument_response = create_token_instrument(default_api)
1742
assert_response(create_instrument_response,

tests/payments/request_apm_payments_integration_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ def test_should_make_trustly_payment(default_api):
460460
payment_request=payment_request)
461461

462462

463-
@pytest.mark.skip(reason='unstable')
464463
def test_should_make_sepa_payment(default_api):
465464
payment_request = PaymentRequest()
466465
payment_request.source = RequestSepaSource()

0 commit comments

Comments
 (0)