diff --git a/lib/checkout_sdk/payments/setups/bacs_payment_method.rb b/lib/checkout_sdk/payments/setups/bacs_payment_method.rb index 83fe5c7..bc1f5df 100644 --- a/lib/checkout_sdk/payments/setups/bacs_payment_method.rb +++ b/lib/checkout_sdk/payments/setups/bacs_payment_method.rb @@ -5,7 +5,8 @@ module Payments # Bacs payment method configuration on a Payment Setup. Maps swagger `Bacs`. # # @!attribute status - # @return [String] (response-only) Payment method status. + # @return [String] (response-only) Payment method status, one of + # {PaymentSetupPaymentMethodStatus} (e.g. "ready"). # @!attribute flags # @return [Array(String)] (response-only) Diagnostic flags returned by the API. # @!attribute initialization diff --git a/lib/checkout_sdk/payments/setups/blik_payment_method.rb b/lib/checkout_sdk/payments/setups/blik_payment_method.rb index 6ee1d26..0c471a1 100644 --- a/lib/checkout_sdk/payments/setups/blik_payment_method.rb +++ b/lib/checkout_sdk/payments/setups/blik_payment_method.rb @@ -2,10 +2,11 @@ module CheckoutSdk module Payments - # Blik payment method configuration on a Payment Setup. + # Blik payment method configuration on a Payment Setup. Maps swagger `Blik`. # # @!attribute status - # @return [String] (response-only) Payment method status (e.g. "available"). + # @return [String] (response-only) Payment method status, one of + # {PaymentSetupPaymentMethodStatus} (e.g. "ready"). # @!attribute flags # @return [Array(String)] (response-only) Diagnostic flags returned by the API. # @!attribute partner_code diff --git a/lib/checkout_sdk/payments/setups/card_present_payment_method.rb b/lib/checkout_sdk/payments/setups/card_present_payment_method.rb index 2679164..a566d01 100644 --- a/lib/checkout_sdk/payments/setups/card_present_payment_method.rb +++ b/lib/checkout_sdk/payments/setups/card_present_payment_method.rb @@ -5,7 +5,8 @@ module Payments # Card Present payment method configuration on a Payment Setup. Maps swagger `CardPresent`. # # @!attribute status - # @return [String] (response-only) Payment method status. + # @return [String] (response-only) Payment method status, one of + # {PaymentSetupPaymentMethodStatus} (e.g. "ready"). # @!attribute flags # @return [Array(String)] (response-only) Diagnostic flags returned by the API. # @!attribute track2 diff --git a/lib/checkout_sdk/payments/setups/payment_setups_client.rb b/lib/checkout_sdk/payments/setups/payment_setups_client.rb index aceb343..d451fa4 100644 --- a/lib/checkout_sdk/payments/setups/payment_setups_client.rb +++ b/lib/checkout_sdk/payments/setups/payment_setups_client.rb @@ -39,6 +39,38 @@ def initialize(api_client, configuration) # `paybybank`; the API ignores `pay_by_bank` without an error), a Hash with the keys documented # on {PayByBankPaymentMethod}; you send :bank_id (the identifier of the bank the customer has # selected for the payment). + # :payment_methods may also include (every key is optional unless marked required): + # - :card - :token (a Hash with :id, String, the Checkout.com card token), :details (the card + # data: :number (String, write-only), :expiry_month (Integer), :expiry_year (Integer), :name + # (String, write-only), :cvv (String, write-only), :stored (Boolean, write-only) and + # :allow_update (Boolean)), :store_for_future_use (Boolean, write-only), :phone + # (:country_code, String, min 1 character, max 7 characters, and :number, String, min 6 + # characters, max 25 characters), :account_holder (:type, one of "individual", "government" + # or "corporate", :first_name, :last_name, :middle_name, :company_name (Strings) and + # :account_name_inquiry (Boolean)) and :preferred_scheme ("visa", "mastercard" or + # "cartes_bancaires"). The card data goes under :details; the API ignores it at the top level + # of :card. + # - :applepay - :token_data (write-only: :version, :data and :signature (Strings) and :header, + # a Hash with :ephemeral_public_key, :public_key_hash and :transaction_id (Strings)), :token (a + # Hash with :id, String, required, pattern ^(tok)_(\w{26})$, and :expires_on, date-time, + # ISO 8601; a String token is not accepted), :store_for_future_use (Boolean, write-only), + # :phone and :account_holder as on :card, and :preferred_scheme ("visa", "mastercard" or + # "cartes_bancaires"). Apple Pay has no :details. + # - :googlepay - :token_data (write-only: :protocol_version, :signature, :signed_message and + # :tokenization_key (Strings)), :token, :store_for_future_use, :phone and :account_holder as + # on :applepay, and :preferred_scheme ("visa" or "mastercard" only). Google Pay has no + # :details. + # - :instrument - :id (String, the unique identifier of the instrument to use). + # - :auto_confirm - String, the payment method that automatically confirms the payment when it + # is ready, for example "card". + # :settings may include :success_url and :failure_url (String, format uri, max 255 + # characters), :capture (Boolean, whether to capture the payment immediately, default true) and + # :excluded_payment_methods (Array of Strings, payment method names, for example ["klarna"]). + # :order may include :sub_merchants, an Array of Hashes with :id (String), :product_category + # (String), :number_of_sales (Integer; the API does not define number_of_trades) and + # :registration_date (String, format date, yyyy-MM-dd). + # :metadata - A Hash of key/value pairs to attach to the payment (max 20 keys); each value is a + # String (max 255 characters), a Number or a Boolean. # :risk {PaymentSetupRisk} - Risk assessment settings for the Payment Setup: :enabled # (Boolean, whether a risk assessment should be performed, default true). # :customer may include: @@ -66,7 +98,10 @@ def initialize(api_client, configuration) # @return [Hash] The Payment Setup (swagger `PaymentSetup`, 200). For Cash App Pay, read # payment_methods.cashapp.action.redirect_url, payment_methods.cashapp.reference and, once only, # payment_methods.cashapp.customer_profile. For Pay by Bank, read - # payment_methods.paybybank.action.banks. + # payment_methods.paybybank.action.banks. Card, Apple Pay and Google Pay return the read-only + # :schemes (supported card scheme names; Google Pay never lists cartes_bancaires) and card + # details :last4, :bin, :scheme (Strings) and :expires_on (date-time); instrument returns the + # read-only :type (String) and :action (:type, "set_instrument"). def create_payment_setup(payment_setups_request) api_client.invoke_post( build_path(PAYMENTS_PATH, SETUPS_PATH), @@ -100,6 +135,38 @@ def create_payment_setup(payment_setups_request) # `paybybank`; the API ignores `pay_by_bank` without an error), a Hash with the keys documented # on {PayByBankPaymentMethod}; you send :bank_id (the identifier of the bank the customer has # selected for the payment). + # :payment_methods may also include (every key is optional unless marked required): + # - :card - :token (a Hash with :id, String, the Checkout.com card token), :details (the card + # data: :number (String, write-only), :expiry_month (Integer), :expiry_year (Integer), :name + # (String, write-only), :cvv (String, write-only), :stored (Boolean, write-only) and + # :allow_update (Boolean)), :store_for_future_use (Boolean, write-only), :phone + # (:country_code, String, min 1 character, max 7 characters, and :number, String, min 6 + # characters, max 25 characters), :account_holder (:type, one of "individual", "government" + # or "corporate", :first_name, :last_name, :middle_name, :company_name (Strings) and + # :account_name_inquiry (Boolean)) and :preferred_scheme ("visa", "mastercard" or + # "cartes_bancaires"). The card data goes under :details; the API ignores it at the top level + # of :card. + # - :applepay - :token_data (write-only: :version, :data and :signature (Strings) and :header, + # a Hash with :ephemeral_public_key, :public_key_hash and :transaction_id (Strings)), :token (a + # Hash with :id, String, required, pattern ^(tok)_(\w{26})$, and :expires_on, date-time, + # ISO 8601; a String token is not accepted), :store_for_future_use (Boolean, write-only), + # :phone and :account_holder as on :card, and :preferred_scheme ("visa", "mastercard" or + # "cartes_bancaires"). Apple Pay has no :details. + # - :googlepay - :token_data (write-only: :protocol_version, :signature, :signed_message and + # :tokenization_key (Strings)), :token, :store_for_future_use, :phone and :account_holder as + # on :applepay, and :preferred_scheme ("visa" or "mastercard" only). Google Pay has no + # :details. + # - :instrument - :id (String, the unique identifier of the instrument to use). + # - :auto_confirm - String, the payment method that automatically confirms the payment when it + # is ready, for example "card". + # :settings may include :success_url and :failure_url (String, format uri, max 255 + # characters), :capture (Boolean, whether to capture the payment immediately, default true) and + # :excluded_payment_methods (Array of Strings, payment method names, for example ["klarna"]). + # :order may include :sub_merchants, an Array of Hashes with :id (String), :product_category + # (String), :number_of_sales (Integer; the API does not define number_of_trades) and + # :registration_date (String, format date, yyyy-MM-dd). + # :metadata - A Hash of key/value pairs to attach to the payment (max 20 keys); each value is a + # String (max 255 characters), a Number or a Boolean. # :risk {PaymentSetupRisk} - Risk assessment settings for the Payment Setup: :enabled # (Boolean, whether a risk assessment should be performed, default true). # :customer may include: @@ -127,7 +194,10 @@ def create_payment_setup(payment_setups_request) # @return [Hash] The Payment Setup (swagger `PaymentSetup`, 200). For Cash App Pay, read # payment_methods.cashapp.action.redirect_url, payment_methods.cashapp.reference and, once only, # payment_methods.cashapp.customer_profile. For Pay by Bank, read - # payment_methods.paybybank.action.banks. + # payment_methods.paybybank.action.banks. Card, Apple Pay and Google Pay return the read-only + # :schemes (supported card scheme names; Google Pay never lists cartes_bancaires) and card + # details :last4, :bin, :scheme (Strings) and :expires_on (date-time); instrument returns the + # read-only :type (String) and :action (:type, "set_instrument"). def update_payment_setup(id, payment_setups_request) api_client.invoke_put( build_path(PAYMENTS_PATH, SETUPS_PATH, id), @@ -143,7 +213,10 @@ def update_payment_setup(id, payment_setups_request) # @return [Hash] The Payment Setup (swagger `PaymentSetup`, 200). For Cash App Pay, read # payment_methods.cashapp.action.redirect_url, payment_methods.cashapp.reference and, once only, # payment_methods.cashapp.customer_profile. For Pay by Bank, read - # payment_methods.paybybank.action.banks. + # payment_methods.paybybank.action.banks. Card, Apple Pay and Google Pay return the read-only + # :schemes (supported card scheme names; Google Pay never lists cartes_bancaires) and card + # details :last4, :bin, :scheme (Strings) and :expires_on (date-time); instrument returns the + # read-only :type (String) and :action (:type, "set_instrument"). def get_payment_setup(id) api_client.invoke_get( build_path(PAYMENTS_PATH, SETUPS_PATH, id), @@ -161,7 +234,10 @@ def get_payment_setup(id) # @return [Hash] The Payment Setup (swagger `PaymentSetup`, 200). For Cash App Pay, read # payment_methods.cashapp.action.redirect_url, payment_methods.cashapp.reference and, once only, # payment_methods.cashapp.customer_profile. For Pay by Bank, read - # payment_methods.paybybank.action.banks. + # payment_methods.paybybank.action.banks. Card, Apple Pay and Google Pay return the read-only + # :schemes (supported card scheme names; Google Pay never lists cartes_bancaires) and card + # details :last4, :bin, :scheme (Strings) and :expires_on (date-time); instrument returns the + # read-only :type (String) and :action (:type, "set_instrument"). def confirm_payment_setup(id, payment_method_name) api_client.invoke_post( build_path(PAYMENTS_PATH, SETUPS_PATH, id, CONFIRM_PATH, payment_method_name), diff --git a/lib/checkout_sdk/payments/setups/stablecoin_payment_method.rb b/lib/checkout_sdk/payments/setups/stablecoin_payment_method.rb index cce50c0..5c7570f 100644 --- a/lib/checkout_sdk/payments/setups/stablecoin_payment_method.rb +++ b/lib/checkout_sdk/payments/setups/stablecoin_payment_method.rb @@ -5,7 +5,8 @@ module Payments # Stablecoin payment method configuration on a Payment Setup. Maps swagger `Stablecoin`. # # @!attribute status - # @return [String] (response-only) Payment method status. + # @return [String] (response-only) Payment method status, one of + # {PaymentSetupPaymentMethodStatus} (e.g. "ready"). # @!attribute flags # @return [Array(String)] (response-only) Diagnostic flags returned by the API. class StablecoinPaymentMethod diff --git a/spec/checkout_sdk/payments/setups/setup_payment_methods_serialization_spec.rb b/spec/checkout_sdk/payments/setups/setup_payment_methods_serialization_spec.rb index 72126cd..31c5b12 100644 --- a/spec/checkout_sdk/payments/setups/setup_payment_methods_serialization_spec.rb +++ b/spec/checkout_sdk/payments/setups/setup_payment_methods_serialization_spec.rb @@ -4,10 +4,10 @@ describe CheckoutSdk::Payments::BacsPaymentMethod do it 'serializes its fields to their swagger keys' do pm = described_class.new - pm.status = 'available' + pm.status = 'ready' pm.flags = %w[flag_a] pm.instrument_id = 'src_wkq7552u245upl5h75x24554xy' - pm.initialization = 'setup' + pm.initialization = 'enabled' pm.account_holder = { 'type' => 'individual', 'first_name' => 'John' } pm.account_number = '12345678' pm.bank_code = '200000' @@ -17,10 +17,10 @@ hash = CheckoutSdk::JsonSerializer.to_custom_hash(pm) - expect(hash['status']).to eq('available') + expect(hash['status']).to eq('ready') expect(hash['flags']).to eq(%w[flag_a]) expect(hash['instrument_id']).to eq('src_wkq7552u245upl5h75x24554xy') - expect(hash['initialization']).to eq('setup') + expect(hash['initialization']).to eq('enabled') expect(hash['account_holder']).to eq({ 'type' => 'individual', 'first_name' => 'John' }) expect(hash['account_number']).to eq('12345678') expect(hash['bank_code']).to eq('200000') @@ -33,7 +33,7 @@ describe CheckoutSdk::Payments::CardPresentPaymentMethod do it 'serializes its fields to their swagger keys' do pm = described_class.new - pm.status = 'available' + pm.status = 'ready' pm.flags = %w[flag_a] pm.track2 = 'track2-data' pm.emv = 'emv-data' @@ -44,7 +44,7 @@ hash = CheckoutSdk::JsonSerializer.to_custom_hash(pm) - expect(hash['status']).to eq('available') + expect(hash['status']).to eq('ready') expect(hash['flags']).to eq(%w[flag_a]) expect(hash['track2']).to eq('track2-data') expect(hash['emv']).to eq('emv-data') @@ -59,14 +59,14 @@ it 'serializes bank_id, status, flags and action' do pm = described_class.new pm.bank_id = 'ob-natwest' - pm.status = 'available' + pm.status = 'ready' pm.flags = %w[flag_a] pm.action = { 'type' => 'select_bank', 'banks' => [{ 'bank_id' => 'ob-natwest' }] } hash = CheckoutSdk::JsonSerializer.to_custom_hash(pm) expect(hash['bank_id']).to eq('ob-natwest') - expect(hash['status']).to eq('available') + expect(hash['status']).to eq('ready') expect(hash['flags']).to eq(%w[flag_a]) expect(hash['action']).to eq({ 'type' => 'select_bank', 'banks' => [{ 'bank_id' => 'ob-natwest' }] }) end @@ -140,15 +140,28 @@ end end + describe CheckoutSdk::Payments::BlikPaymentMethod do + it 'serializes its fields to their swagger keys' do + pm = described_class.new + pm.status = 'ready' + pm.flags = %w[flag_a] + pm.partner_code = '777123' + + hash = CheckoutSdk::JsonSerializer.to_custom_hash(pm) + + expect(hash).to eq({ 'status' => 'ready', 'flags' => %w[flag_a], 'partner_code' => '777123' }) + end + end + describe CheckoutSdk::Payments::StablecoinPaymentMethod do it 'serializes its response fields' do pm = described_class.new - pm.status = 'available' + pm.status = 'ready' pm.flags = %w[flag_a] hash = CheckoutSdk::JsonSerializer.to_custom_hash(pm) - expect(hash['status']).to eq('available') + expect(hash['status']).to eq('ready') expect(hash['flags']).to eq(%w[flag_a]) end end