Skip to content

Commit dbe56b4

Browse files
Update Payment Context And Properties (#132)
- Update payment request for payment contexts - Update giropay source - Update properties and tests
1 parent 3362ce3 commit dbe56b4

File tree

6 files changed

+52
-5
lines changed

6 files changed

+52
-5
lines changed

lib/checkout_sdk/payments/payment_request.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module CheckoutSdk
44
module Payments
5+
# @!attribute payment_context_id
6+
# @return [String]
57
# @!attribute source
68
# @return [PaymentSource]
79
# @!attribute amount
@@ -28,6 +30,8 @@ module Payments
2830
# @return [BillingDescriptor]
2931
# @!attribute shipping
3032
# @return [ShippingDetails]
33+
# @!attribute segment
34+
# @return [PaymentSegment]
3135
# @!attribute three_ds
3236
# @return [ThreeDSRequest]
3337
# @!attribute processing_channel_id
@@ -55,10 +59,13 @@ module Payments
5559
# @return [ProcessingSettings]
5660
# @!attribute items
5761
# @return [Array(Product)]
62+
# @!attribute retry
63+
# @return [PaymentRetryRequest]
5864
# @!attribute metadata
5965
# @return [Hash{String => Object}]
6066
class PaymentRequest
61-
attr_accessor :source,
67+
attr_accessor :payment_context_id,
68+
:source,
6269
:amount,
6370
:currency,
6471
:payment_type,
@@ -71,6 +78,7 @@ class PaymentRequest
7178
:customer,
7279
:billing_descriptor,
7380
:shipping,
81+
:segment,
7482
:three_ds,
7583
:processing_channel_id,
7684
:previous_payment_id,
@@ -84,6 +92,7 @@ class PaymentRequest
8492
:amount_allocations,
8593
:processing,
8694
:items,
95+
:retry,
8796
:metadata
8897
end
8998
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module CheckoutSdk
4+
module Payments
5+
# @!attribute enabled
6+
# @return [TrueClass, FalseClass]
7+
# @!attribute max_attempts
8+
# @return [Integer]
9+
# @!attribute end_after_days
10+
# @return [Integer]
11+
class PaymentRetryRequest
12+
attr_accessor :enabled,
13+
:max_attempts,
14+
:end_after_day
15+
end
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module CheckoutSdk
4+
module Payments
5+
# @!attribute brand
6+
# @return [String]
7+
# @!attribute business_category
8+
# @return [String]
9+
# @!attribute market
10+
# @return [String]
11+
class PaymentSegment
12+
attr_accessor :brand,
13+
:business_category,
14+
:market
15+
end
16+
end
17+
end

lib/checkout_sdk/payments/source/apm/giropay_source.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
module CheckoutSdk
44
module Payments
5+
# @!attribute account_holder
6+
# @return [CheckoutSdk::Common::AccountHolder]
57
class GiropaySource < PaymentSource
8+
attr_accessor :account_holder
9+
610
def initialize
711
super CheckoutSdk::Common::PaymentSourceType::GIROPAY
812
end

spec/checkout_sdk/forex/forex_integration_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
RSpec.describe CheckoutSdk::Forex do
22

33
skip 'Skipping because processing_channel_id is invalid' do
4-
describe '.request_quote' do
4+
describe '.request_quote', skip: 'unavailable' do
55
context 'when requesting a quote with valid parameters' do
66
it 'retrieves valid quotes' do
77
request = CheckoutSdk::Forex::QuoteRequest.new

spec/checkout_sdk/payments/request_apm_payments_integration_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
end
353353

354354
context 'when requesting Klarna source payment' do
355-
it 'raises an error (payee_not_onboarded)' do
355+
it 'raises an error (amount_and_item_total_amounts_mismatch)' do
356356
source = CheckoutSdk::Payments::KlarnaSource.new
357357
source.account_holder = common_account_holder
358358

@@ -366,7 +366,7 @@
366366
request.failure_url = 'https://testing.checkout.com/failure'
367367

368368
expect { default_sdk.payments.request_payment(request) }
369-
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'custom_data_required' }
369+
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'amount_and_item_total_amounts_mismatch' }
370370
end
371371
end
372372

@@ -507,7 +507,7 @@
507507

508508
expect { default_sdk.payments.request_payment(request) }
509509
.to raise_error(CheckoutSdk::CheckoutApiException) { |e|
510-
expect(e.error_details[:error_codes].first).to eq 'payment_type_required' }
510+
expect(e.error_details[:error_codes].first).to eq 'apm_service_unavailable' }
511511
end
512512
end
513513

0 commit comments

Comments
 (0)