From 34f91850366d9d2438e77ba2990c1735db9bc2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Rodr=C3=ADguez?= <127134616+armando-rodriguez-cko@users.noreply.github.com> Date: Fri, 19 Jun 2026 11:31:27 +0200 Subject: [PATCH] Add authorization_type and payment_plan to payment link, hosted, and session requests Swagger added authorization_type and payment_plan to HostedPaymentsRequest, PaymentLinksRequest, and CreatePaymentSessionsBaseRequest. The Ruby SDK uses explicit attr_accessor, so these fields must be declared to pass through. - PaymentLink, HostedPaymentsSession, PaymentSessionsRequest: add both accessors and RDOC comments (AuthorizationType enum, PaymentPlan class, both pre-existing) - Add unit spec covering the new accessors on all three classes --- .../hosted/hosted_payments_session.rb | 8 ++++- .../payments/links/payment_link.rb | 8 ++++- .../sessions/payment_sessions_request.rb | 8 ++++- .../payments/payment_plan_fields_spec.rb | 30 +++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 spec/checkout_sdk/payments/payment_plan_fields_spec.rb diff --git a/lib/checkout_sdk/payments/hosted/hosted_payments_session.rb b/lib/checkout_sdk/payments/hosted/hosted_payments_session.rb index 29f1b0b..3e35369 100644 --- a/lib/checkout_sdk/payments/hosted/hosted_payments_session.rb +++ b/lib/checkout_sdk/payments/hosted/hosted_payments_session.rb @@ -66,6 +66,10 @@ module Payments # @return [HostedPaymentInstruction] # @!attribute payment_method_configuration # @return [PaymentMethodConfiguration] + # @!attribute authorization_type + # @return [String] {AuthorizationType} + # @!attribute payment_plan + # @return [PaymentPlan] class HostedPaymentsSession attr_accessor :currency, :billing, @@ -97,7 +101,9 @@ class HostedPaymentsSession :capture, :capture_on, :instruction, - :payment_method_configuration + :payment_method_configuration, + :authorization_type, + :payment_plan def initialize(payment_type: CheckoutSdk::Payments::PaymentType::REGULAR) @payment_type = payment_type diff --git a/lib/checkout_sdk/payments/links/payment_link.rb b/lib/checkout_sdk/payments/links/payment_link.rb index ef39c6e..c4c4697 100644 --- a/lib/checkout_sdk/payments/links/payment_link.rb +++ b/lib/checkout_sdk/payments/links/payment_link.rb @@ -60,6 +60,10 @@ module Payments # @return [TrueClass, FalseClass] # @!attribute capture_on # @return [Time] + # @!attribute authorization_type + # @return [String] {AuthorizationType} + # @!attribute payment_plan + # @return [PaymentPlan] class PaymentLink attr_accessor :amount, :currency, @@ -88,7 +92,9 @@ class PaymentLink :return_url, :locale, :capture, - :capture_on + :capture_on, + :authorization_type, + :payment_plan def initialize(payment_type: CheckoutSdk::Payments::PaymentType::REGULAR) @payment_type = payment_type diff --git a/lib/checkout_sdk/payments/sessions/payment_sessions_request.rb b/lib/checkout_sdk/payments/sessions/payment_sessions_request.rb index a73b07e..12333f5 100644 --- a/lib/checkout_sdk/payments/sessions/payment_sessions_request.rb +++ b/lib/checkout_sdk/payments/sessions/payment_sessions_request.rb @@ -64,6 +64,10 @@ module Payments # @return [Time] # @!attribute tax_amount # @return [Integer] + # @!attribute authorization_type + # @return [String] {AuthorizationType} + # @!attribute payment_plan + # @return [PaymentPlan] class PaymentSessionsRequest attr_accessor :amount, :currency, @@ -95,7 +99,9 @@ class PaymentSessionsRequest :capture, :ip_address, :capture_on, - :tax_amount + :tax_amount, + :authorization_type, + :payment_plan end end end diff --git a/spec/checkout_sdk/payments/payment_plan_fields_spec.rb b/spec/checkout_sdk/payments/payment_plan_fields_spec.rb new file mode 100644 index 0000000..afaec7e --- /dev/null +++ b/spec/checkout_sdk/payments/payment_plan_fields_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +RSpec.describe 'authorization_type and payment_plan request fields' do + let(:payment_plan) do + plan = CheckoutSdk::Payments::PaymentPlan.new + plan.amount_variability = 'Fixed' + plan.name = 'Monthly subscription' + plan + end + let(:authorization_type) { 'Estimated' } + + shared_examples 'supports authorization_type and payment_plan' do |klass| + it "#{klass} exposes authorization_type" do + obj = klass.new + obj.authorization_type = authorization_type + expect(obj.authorization_type).to eq(authorization_type) + end + + it "#{klass} exposes payment_plan" do + obj = klass.new + obj.payment_plan = payment_plan + expect(obj.payment_plan).to eq(payment_plan) + expect(obj.payment_plan.amount_variability).to eq('Fixed') + end + end + + include_examples 'supports authorization_type and payment_plan', CheckoutSdk::Payments::PaymentLink + include_examples 'supports authorization_type and payment_plan', CheckoutSdk::Payments::HostedPaymentsSession + include_examples 'supports authorization_type and payment_plan', CheckoutSdk::Payments::PaymentSessionsRequest +end