Skip to content

Commit

Permalink
Update Payment Context And Properties (#132)
Browse files Browse the repository at this point in the history
- Update payment request for payment contexts
- Update giropay source
- Update properties and tests
  • Loading branch information
armando-rodriguez-cko authored Feb 8, 2024
1 parent 3362ce3 commit dbe56b4
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 deletions.
11 changes: 10 additions & 1 deletion lib/checkout_sdk/payments/payment_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module CheckoutSdk
module Payments
# @!attribute payment_context_id
# @return [String]
# @!attribute source
# @return [PaymentSource]
# @!attribute amount
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -71,6 +78,7 @@ class PaymentRequest
:customer,
:billing_descriptor,
:shipping,
:segment,
:three_ds,
:processing_channel_id,
:previous_payment_id,
Expand All @@ -84,6 +92,7 @@ class PaymentRequest
:amount_allocations,
:processing,
:items,
:retry,
:metadata
end
end
Expand Down
17 changes: 17 additions & 0 deletions lib/checkout_sdk/payments/payment_retry_request.rb
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions lib/checkout_sdk/payments/payment_segment.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions lib/checkout_sdk/payments/source/apm/giropay_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/checkout_sdk/forex/forex_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit dbe56b4

Please sign in to comment.