diff --git a/lib/checkout_sdk/common/instrument_type.rb b/lib/checkout_sdk/common/instrument_type.rb index d926ede..484f3c5 100644 --- a/lib/checkout_sdk/common/instrument_type.rb +++ b/lib/checkout_sdk/common/instrument_type.rb @@ -6,6 +6,7 @@ module InstrumentType BANK_ACCOUNT = 'bank_account' TOKEN = 'token' CARD = 'card' + SEPA = 'sepa' CARD_TOKEN = 'card_token' end end diff --git a/lib/checkout_sdk/instruments/create/instrument_data.rb b/lib/checkout_sdk/instruments/create/instrument_data.rb new file mode 100644 index 0000000..0f80634 --- /dev/null +++ b/lib/checkout_sdk/instruments/create/instrument_data.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Instruments + # @!attribute account_number + # @return [String] + # @!attribute country + # @return [String] {CheckoutSdk::Common::Country} + # @!attribute currency + # @return [String] {CheckoutSdk::Common::Currency} + # @!attribute payment_type + # @return [String] {CheckoutSdk::Payments::PaymentType} + # @!attribute mandate_id + # @return [String] + # @!attribute date_of_signature + # @return [DateTime] + class InstrumentData + attr_accessor :account_number, + :country, + :currency, + :payment_type, + :mandate_id, + :date_of_signature + end + end +end diff --git a/lib/checkout_sdk/instruments/create/instrument_sepa.rb b/lib/checkout_sdk/instruments/create/instrument_sepa.rb new file mode 100644 index 0000000..0f53a4e --- /dev/null +++ b/lib/checkout_sdk/instruments/create/instrument_sepa.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Instruments + # @!attribute instrument_data + # @return [InstrumentData] + # @!attribute account_holder + # @return [CheckoutSdk::Common::AccountHolder] + class InstrumentSepa < Instrument + attr_accessor :instrument_data, + :account_holder + + def initialize + super CheckoutSdk::Common::InstrumentType::SEPA + end + end + end +end diff --git a/lib/checkout_sdk/instruments/instruments.rb b/lib/checkout_sdk/instruments/instruments.rb index f907093..35a1eb2 100644 --- a/lib/checkout_sdk/instruments/instruments.rb +++ b/lib/checkout_sdk/instruments/instruments.rb @@ -12,6 +12,8 @@ require 'checkout_sdk/instruments/create/instrument' require 'checkout_sdk/instruments/create/instrument_token' require 'checkout_sdk/instruments/create/instrument_bank_account' +require 'checkout_sdk/instruments/create/instrument_sepa' +require 'checkout_sdk/instruments/create/instrument_data' # Client require 'checkout_sdk/instruments/base_instruments_client' require 'checkout_sdk/instruments/instruments_client' diff --git a/lib/checkout_sdk/payments/payment_request.rb b/lib/checkout_sdk/payments/payment_request.rb index 259a810..56d795e 100644 --- a/lib/checkout_sdk/payments/payment_request.rb +++ b/lib/checkout_sdk/payments/payment_request.rb @@ -63,6 +63,8 @@ module Payments # @return [PaymentRetryRequest] # @!attribute metadata # @return [Hash{String => Object}] + # @!attribute instruction + # @return [PaymentInstruction] class PaymentRequest attr_accessor :payment_context_id, :source, @@ -93,7 +95,8 @@ class PaymentRequest :processing, :items, :retry, - :metadata + :metadata, + :instruction end end end diff --git a/spec/checkout_sdk/instruments/instruments_integration_spec.rb b/spec/checkout_sdk/instruments/instruments_integration_spec.rb index e14415b..2c24ac0 100644 --- a/spec/checkout_sdk/instruments/instruments_integration_spec.rb +++ b/spec/checkout_sdk/instruments/instruments_integration_spec.rb @@ -30,6 +30,33 @@ end end + context 'when requesting a sepa instrument' do + it 'returns a sepa instrument response' do + instruments_data = CheckoutSdk::Instruments::InstrumentData.new + instruments_data.account_number = "FR7630006000011234567890189" + instruments_data.country = CheckoutSdk::Common::Country::FR + instruments_data.currency = CheckoutSdk::Common::Currency::EUR + instruments_data.payment_type = CheckoutSdk::Payments::PaymentType::RECURRING + + account_holder = CheckoutSdk::Common::AccountHolder.new + account_holder.first_name = 'John' + account_holder.last_name = 'Smith' + account_holder.billing_address = address + account_holder.phone = phone + + request = CheckoutSdk::Instruments::InstrumentSepa.new + request.instrument_data = instruments_data + request.account_holder = account_holder + + response = default_sdk.instruments.create(request) + + expect(response).not_to be nil + expect(response.id).not_to be nil + expect(response.fingerprint).not_to be nil + + end + end + context 'when requesting card token instrument with missing data' do it 'raises an error' do request = CheckoutSdk::Instruments::InstrumentToken.new