From dbe56b455416c26982111de4272946b872b92fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Rodr=C3=ADguez?= <127134616+armando-rodriguez-cko@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:31:16 +0100 Subject: [PATCH] Update Payment Context And Properties (#132) - Update payment request for payment contexts - Update giropay source - Update properties and tests --- lib/checkout_sdk/payments/payment_request.rb | 11 ++++++++++- .../payments/payment_retry_request.rb | 17 +++++++++++++++++ lib/checkout_sdk/payments/payment_segment.rb | 17 +++++++++++++++++ .../payments/source/apm/giropay_source.rb | 4 ++++ .../forex/forex_integration_spec.rb | 2 +- .../request_apm_payments_integration_spec.rb | 6 +++--- 6 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 lib/checkout_sdk/payments/payment_retry_request.rb create mode 100644 lib/checkout_sdk/payments/payment_segment.rb diff --git a/lib/checkout_sdk/payments/payment_request.rb b/lib/checkout_sdk/payments/payment_request.rb index bf303ad..259a810 100644 --- a/lib/checkout_sdk/payments/payment_request.rb +++ b/lib/checkout_sdk/payments/payment_request.rb @@ -2,6 +2,8 @@ module CheckoutSdk module Payments + # @!attribute payment_context_id + # @return [String] # @!attribute source # @return [PaymentSource] # @!attribute amount @@ -28,6 +30,8 @@ module Payments # @return [BillingDescriptor] # @!attribute shipping # @return [ShippingDetails] + # @!attribute segment + # @return [PaymentSegment] # @!attribute three_ds # @return [ThreeDSRequest] # @!attribute processing_channel_id @@ -55,10 +59,13 @@ module Payments # @return [ProcessingSettings] # @!attribute items # @return [Array(Product)] + # @!attribute retry + # @return [PaymentRetryRequest] # @!attribute metadata # @return [Hash{String => Object}] class PaymentRequest - attr_accessor :source, + attr_accessor :payment_context_id, + :source, :amount, :currency, :payment_type, @@ -71,6 +78,7 @@ class PaymentRequest :customer, :billing_descriptor, :shipping, + :segment, :three_ds, :processing_channel_id, :previous_payment_id, @@ -84,6 +92,7 @@ class PaymentRequest :amount_allocations, :processing, :items, + :retry, :metadata end end diff --git a/lib/checkout_sdk/payments/payment_retry_request.rb b/lib/checkout_sdk/payments/payment_retry_request.rb new file mode 100644 index 0000000..b8fb06e --- /dev/null +++ b/lib/checkout_sdk/payments/payment_retry_request.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Payments + # @!attribute enabled + # @return [TrueClass, FalseClass] + # @!attribute max_attempts + # @return [Integer] + # @!attribute end_after_days + # @return [Integer] + class PaymentRetryRequest + attr_accessor :enabled, + :max_attempts, + :end_after_day + end + end +end diff --git a/lib/checkout_sdk/payments/payment_segment.rb b/lib/checkout_sdk/payments/payment_segment.rb new file mode 100644 index 0000000..7e77619 --- /dev/null +++ b/lib/checkout_sdk/payments/payment_segment.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Payments + # @!attribute brand + # @return [String] + # @!attribute business_category + # @return [String] + # @!attribute market + # @return [String] + class PaymentSegment + attr_accessor :brand, + :business_category, + :market + end + end +end diff --git a/lib/checkout_sdk/payments/source/apm/giropay_source.rb b/lib/checkout_sdk/payments/source/apm/giropay_source.rb index c269d16..d21b311 100644 --- a/lib/checkout_sdk/payments/source/apm/giropay_source.rb +++ b/lib/checkout_sdk/payments/source/apm/giropay_source.rb @@ -2,7 +2,11 @@ module CheckoutSdk module Payments + # @!attribute account_holder + # @return [CheckoutSdk::Common::AccountHolder] class GiropaySource < PaymentSource + attr_accessor :account_holder + def initialize super CheckoutSdk::Common::PaymentSourceType::GIROPAY end diff --git a/spec/checkout_sdk/forex/forex_integration_spec.rb b/spec/checkout_sdk/forex/forex_integration_spec.rb index 08880f6..73c8ec8 100644 --- a/spec/checkout_sdk/forex/forex_integration_spec.rb +++ b/spec/checkout_sdk/forex/forex_integration_spec.rb @@ -1,7 +1,7 @@ RSpec.describe CheckoutSdk::Forex do skip 'Skipping because processing_channel_id is invalid' do - describe '.request_quote' do + describe '.request_quote', skip: 'unavailable' do context 'when requesting a quote with valid parameters' do it 'retrieves valid quotes' do request = CheckoutSdk::Forex::QuoteRequest.new diff --git a/spec/checkout_sdk/payments/request_apm_payments_integration_spec.rb b/spec/checkout_sdk/payments/request_apm_payments_integration_spec.rb index 46a5b72..8005a3f 100644 --- a/spec/checkout_sdk/payments/request_apm_payments_integration_spec.rb +++ b/spec/checkout_sdk/payments/request_apm_payments_integration_spec.rb @@ -352,7 +352,7 @@ end context 'when requesting Klarna source payment' do - it 'raises an error (payee_not_onboarded)' do + it 'raises an error (amount_and_item_total_amounts_mismatch)' do source = CheckoutSdk::Payments::KlarnaSource.new source.account_holder = common_account_holder @@ -366,7 +366,7 @@ request.failure_url = 'https://testing.checkout.com/failure' expect { default_sdk.payments.request_payment(request) } - .to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'custom_data_required' } + .to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'amount_and_item_total_amounts_mismatch' } end end @@ -507,7 +507,7 @@ expect { default_sdk.payments.request_payment(request) } .to raise_error(CheckoutSdk::CheckoutApiException) { |e| - expect(e.error_details[:error_codes].first).to eq 'payment_type_required' } + expect(e.error_details[:error_codes].first).to eq 'apm_service_unavailable' } end end