Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEPA Direct Debit Core Support #159

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions checkout_sdk/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ class InstrumentType(str, Enum):
BANK_ACCOUNT = 'bank_account'
TOKEN = 'token'
CARD = 'card'
SEPA = 'sepa'
CARD_TOKEN = 'card_token'


Expand Down
21 changes: 21 additions & 0 deletions checkout_sdk/instruments/instruments.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions checkout_sdk/payments/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ class PaymentRequest:
metadata: dict
items: list # payments.Product
retry: PaymentRetryRequest
instruction: PaymentInstruction


# Payout Request Source
Expand Down
27 changes: 26 additions & 1 deletion tests/instruments/instruments_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion tests/payments/request_apm_payments_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading