diff --git a/lib/checkout_sdk/payments/payments.rb b/lib/checkout_sdk/payments/payments.rb index 179cd50..3cae103 100644 --- a/lib/checkout_sdk/payments/payments.rb +++ b/lib/checkout_sdk/payments/payments.rb @@ -161,3 +161,8 @@ # Payment Sessions require 'checkout_sdk/payments/sessions/payment_sessions_client' +require 'checkout_sdk/payments/sessions/payment_sessions_request' +require 'checkout_sdk/payments/sessions/payment_methods_type' +require 'checkout_sdk/payments/sessions/payment_method_configuration' +require 'checkout_sdk/payments/sessions/card' +require 'checkout_sdk/payments/sessions/store_payment_details_type' diff --git a/lib/checkout_sdk/payments/sessions/card.rb b/lib/checkout_sdk/payments/sessions/card.rb new file mode 100644 index 0000000..9315528 --- /dev/null +++ b/lib/checkout_sdk/payments/sessions/card.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Payments + # @!attribute store_payment_details + # @return [String] {StorePaymentDetailsType} + class Card + attr_accessor :store_payment_details + end + end +end diff --git a/lib/checkout_sdk/payments/sessions/payment_method_configuration.rb b/lib/checkout_sdk/payments/sessions/payment_method_configuration.rb new file mode 100644 index 0000000..7e3e22b --- /dev/null +++ b/lib/checkout_sdk/payments/sessions/payment_method_configuration.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Payments + # @!attribute card + # @return [Card] + class PaymentMethodConfiguration + attr_accessor :card + end + end +end diff --git a/lib/checkout_sdk/payments/sessions/payment_methods_type.rb b/lib/checkout_sdk/payments/sessions/payment_methods_type.rb new file mode 100644 index 0000000..7209098 --- /dev/null +++ b/lib/checkout_sdk/payments/sessions/payment_methods_type.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Payments + module PaymentMethodsType + APPLEPAY = 'applepay' + BANCONTACT = 'bancontact' + CARD = 'card' + EPS = 'eps' + GIROPAY = 'giropay' + GOOGLEPAY = 'googlepay' + IDEAL = 'ideal' + KNET = 'knet' + MULTIBANCO = 'multibanco' + PRZELEWY24 = 'p24' + PAYPAL = 'paypal' + SOFORT = 'sofort' + end + end +end diff --git a/lib/checkout_sdk/payments/sessions/payment_sessions_client.rb b/lib/checkout_sdk/payments/sessions/payment_sessions_client.rb index bfacc5d..d66f7a3 100644 --- a/lib/checkout_sdk/payments/sessions/payment_sessions_client.rb +++ b/lib/checkout_sdk/payments/sessions/payment_sessions_client.rb @@ -11,7 +11,7 @@ def initialize(api_client, configuration) super api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY end - # @param [Hash] payment_sessions + # @param [Hash, PaymentSessionsRequest] payment_sessions def create_payment_sessions(payment_sessions) api_client.invoke_post(PAYMENT_SESSIONS, sdk_authorization, payment_sessions) end diff --git a/lib/checkout_sdk/payments/sessions/payment_sessions_request.rb b/lib/checkout_sdk/payments/sessions/payment_sessions_request.rb new file mode 100644 index 0000000..50d3ea1 --- /dev/null +++ b/lib/checkout_sdk/payments/sessions/payment_sessions_request.rb @@ -0,0 +1,98 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Payments + # @!attribute amount + # @return [Integer] + # @!attribute currency + # @return [String] {CheckoutSdk::Common::Currency} + # @!attribute payment_type + # @return [TrueClass, FalseClass] + # @!attribute billing + # @return [BillingInformation] + # @!attribute billing_descriptor + # @return [BillingDescriptor] + # @!attribute reference + # @return [String] + # @!attribute description + # @return [String] + # @!attribute customer + # @return [CheckoutSdk::Common::CustomerRequest] + # @!attribute shipping + # @return [ShippingDetails] + # @!attribute recipient + # @return [PaymentRecipient] + # @!attribute processing + # @return [ProcessingSettings] + # @!attribute processing_channel_id + # @return [String] + # @!attribute expires_on + # @return [Time] + # @!attribute payment_method_configuration + # @return [PaymentMethodConfiguration] + # @!attribute enabled_payment_methods + # @return [Array(PaymentMethodsType)] + # @!attribute disabled_payment_methods + # @return [Array(PaymentMethodsType)] + # @!attribute items + # @return [Array(Product)] + # @!attribute amount_allocations + # @return [Array(CheckoutSdk::Common::AmountAllocations)] + # @!attribute risk + # @return [RiskRequest] + # @!attribute retry + # @return [PaymentRetryRequest] + # @!attribute display_name + # @return [String] + # @!attribute success_url + # @return [String] + # @!attribute failure_url + # @return [String] + # @!attribute metadata + # @return [Hash{String => Object}] + # @!attribute locale + # @return [String] + # @!attribute three_ds + # @return [ThreeDSRequest] + # @!attribute sender + # @return [Sender] + # @!attribute capture + # @return [TrueClass, FalseClass] + # @!attribute ip_address + # @return [String] + # @!attribute tax_amount + # @return [Integer] + class PaymentSessionsRequest + attr_accessor :amount, + :currency, + :payment_type, + :billing, + :billing_descriptor, + :reference, + :description, + :customer, + :shipping, + :recipient, + :processing, + :processing_channel_id, + :expires_on, + :payment_method_configuration, + :enabled_payment_methods, + :disabled_payment_methods, + :items, + :amount_allocations, + :risk, + :retry, + :display_name, + :success_url, + :failure_url, + :metadata, + :locale, + :three_ds, + :sender, + :capture, + :ip_address, + :tax_amount + end + end +end diff --git a/lib/checkout_sdk/payments/sessions/store_payment_details_type.rb b/lib/checkout_sdk/payments/sessions/store_payment_details_type.rb new file mode 100644 index 0000000..5c89bf1 --- /dev/null +++ b/lib/checkout_sdk/payments/sessions/store_payment_details_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module CheckoutSdk + module Payments + module StorePaymentDetailsType + DISABLED = 'disabled' + ENABLED = 'enabled' + end + end +end diff --git a/spec/checkout_sdk/payments/sessions/sessions_integration_spec.rb b/spec/checkout_sdk/payments/sessions/sessions_integration_spec.rb index 297de9b..dfa4e0e 100644 --- a/spec/checkout_sdk/payments/sessions/sessions_integration_spec.rb +++ b/spec/checkout_sdk/payments/sessions/sessions_integration_spec.rb @@ -16,6 +16,7 @@ def is_valid_payment_sessions(payment_sessions) assert_response payment_sessions, %w[id + payment_session_token _links _links.self]