genesis_ruby 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/Gemfile.lock +4 -4
  4. data/README.md +8 -0
  5. data/VERSION +1 -1
  6. data/lib/genesis_ruby/api/constants/date_time_formats.rb +4 -0
  7. data/lib/genesis_ruby/api/constants/transactions/parameters/cash_payments/cash_payment_types.rb +36 -0
  8. data/lib/genesis_ruby/api/constants/transactions/parameters/credential_on_files.rb +29 -0
  9. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/bank_account_types.rb +30 -0
  10. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/payout_payment_types.rb +42 -0
  11. data/lib/genesis_ruby/api/constants/transactions/parameters/refund/credit_reason_indicators.rb +30 -0
  12. data/lib/genesis_ruby/api/constants/transactions/parameters/refund/ticket_change_indicators.rb +24 -0
  13. data/lib/genesis_ruby/api/constants/transactions.rb +4 -0
  14. data/lib/genesis_ruby/api/mixins/requests/financial/cards/credential_on_file_attributes.rb +29 -0
  15. data/lib/genesis_ruby/api/mixins/requests/financial/cards/installment_attributes.rb +18 -0
  16. data/lib/genesis_ruby/api/mixins/requests/financial/cards/mpi_attributes.rb +10 -0
  17. data/lib/genesis_ruby/api/mixins/requests/financial/cards/ucof_attributes.rb +33 -0
  18. data/lib/genesis_ruby/api/mixins/requests/financial/online_banking_payments/pix_attributes.rb +28 -0
  19. data/lib/genesis_ruby/api/request.rb +6 -1
  20. data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +25 -2
  21. data/lib/genesis_ruby/api/requests/base/versioned.rb +88 -0
  22. data/lib/genesis_ruby/api/requests/financial/capture.rb +6 -3
  23. data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +22 -19
  24. data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +29 -24
  25. data/lib/genesis_ruby/api/requests/financial/cards/bancontact.rb +47 -0
  26. data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +22 -19
  27. data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +29 -24
  28. data/lib/genesis_ruby/api/requests/financial/cash_payments/cash.rb +56 -0
  29. data/lib/genesis_ruby/api/requests/financial/cash_payments/pix.rb +4 -8
  30. data/lib/genesis_ruby/api/requests/financial/mobile/apple_pay.rb +4 -1
  31. data/lib/genesis_ruby/api/requests/financial/mobile/google_pay.rb +5 -3
  32. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/online_banking/pay_out.rb +129 -0
  33. data/lib/genesis_ruby/api/requests/financial/refund.rb +32 -12
  34. data/lib/genesis_ruby/api/requests/non_financial/installments/fetch.rb +59 -0
  35. data/lib/genesis_ruby/api/requests/non_financial/installments/show.rb +58 -0
  36. data/lib/genesis_ruby/builder.rb +2 -0
  37. data/lib/genesis_ruby/builders/json.rb +30 -0
  38. data/lib/genesis_ruby/dependencies.rb +1 -0
  39. data/lib/genesis_ruby/network/adapter/net_http_adapter.rb +13 -8
  40. data/lib/genesis_ruby/parser.rb +3 -0
  41. data/lib/genesis_ruby/parsers/json.rb +18 -0
  42. data/lib/genesis_ruby/utils/options/api_config.rb +9 -0
  43. data/lib/genesis_ruby/version.rb +1 -1
  44. metadata +21 -3
@@ -13,6 +13,7 @@ module GenesisRuby
13
13
  include Mixins::Requests::DocumentAttributes
14
14
  include Mixins::Requests::Financial::Business::BusinessAttributes
15
15
  include Mixins::Requests::Financial::Cards::FxRateAttributes
16
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
16
17
  include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
17
18
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
18
19
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
@@ -50,25 +51,27 @@ module GenesisRuby
50
51
 
51
52
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
52
53
  super.merge(
53
- gaming: gaming,
54
- moto: moto,
55
- crypto: crypto,
56
- customer_email: customer_email,
57
- customer_phone: customer_phone,
58
- reference_id: reference_id,
59
- document_id: document_id,
60
- fx_rate_id: fx_rate_id,
61
- billing_address: billing_address_parameters_structure,
62
- shipping_address: shipping_address_parameters_structure,
63
- risk_params: risk_parameters_structure,
64
- dynamic_descriptor_params: dynamic_descriptor_structure,
65
- business_attributes: business_attributes_structure,
66
- recurring_type: recurring_type,
67
- recurring_category: recurring_category,
68
- sca_params: sca_attributes_structure,
69
- managed_recurring: managed_recurring_attributes_structure,
70
- travel: travel_data_attributes_structure,
71
- funding: funding_attributes_structure
54
+ gaming: gaming,
55
+ moto: moto,
56
+ crypto: crypto,
57
+ customer_email: customer_email,
58
+ customer_phone: customer_phone,
59
+ reference_id: reference_id,
60
+ document_id: document_id,
61
+ fx_rate_id: fx_rate_id,
62
+ billing_address: billing_address_parameters_structure,
63
+ shipping_address: shipping_address_parameters_structure,
64
+ risk_params: risk_parameters_structure,
65
+ dynamic_descriptor_params: dynamic_descriptor_structure,
66
+ business_attributes: business_attributes_structure,
67
+ recurring_type: recurring_type,
68
+ recurring_category: recurring_category,
69
+ sca_params: sca_attributes_structure,
70
+ managed_recurring: managed_recurring_attributes_structure,
71
+ travel: travel_data_attributes_structure,
72
+ funding: funding_attributes_structure,
73
+ installment_plan_id: installment_plan_id,
74
+ installment_plan_reference: installment_plan_reference
72
75
  )
73
76
  end
74
77
 
@@ -14,6 +14,7 @@ module GenesisRuby
14
14
  include Mixins::Requests::Financial::AsyncAttributes
15
15
  include Mixins::Requests::Financial::Business::BusinessAttributes
16
16
  include Mixins::Requests::Financial::Cards::FxRateAttributes
17
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
17
18
  include Mixins::Requests::Financial::Cards::MpiAttributes
18
19
  include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
19
20
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
@@ -46,12 +47,14 @@ module GenesisRuby
46
47
 
47
48
  field_value_dependencies.merge! required_tokenization_fields_conditional, required_cc_fields_conditional,
48
49
  required_recurring_managed_type_field_conditional,
49
- threeds_field_conditional_validations
50
+ threeds_field_conditional_validations, mpi_attributes_field_dependencies
50
51
  end
51
52
 
52
53
  # Special validations upon document building
53
54
  def check_requirements
54
55
  validate_threeds_card_holder_dates
56
+ # MPI Directory Server ID is optional when Scheme Tokenized with MPI Protocol Version 2
57
+ field_value_dependencies.delete :mpi_protocol_version if scheme_tokenized
55
58
 
56
59
  super
57
60
  end
@@ -59,29 +62,31 @@ module GenesisRuby
59
62
  # Authorize 3D transaction request parameters
60
63
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
61
64
  super.merge(
62
- notification_url: notification_url,
63
- return_success_url: return_success_url,
64
- return_failure_url: return_failure_url,
65
- gaming: gaming,
66
- moto: moto,
67
- crypto: crypto,
68
- customer_email: customer_email,
69
- customer_phone: customer_phone,
70
- document_id: document_id,
71
- fx_rate_id: fx_rate_id,
72
- billing_address: billing_address_parameters_structure,
73
- shipping_address: shipping_address_parameters_structure,
74
- mpi_params: mpi_attributes_structure,
75
- risk_params: risk_parameters_structure,
76
- dynamic_descriptor_params: dynamic_descriptor_structure,
77
- business_attributes: business_attributes_structure,
78
- recurring_type: recurring_type,
79
- recurring_category: recurring_category,
80
- sca_params: sca_attributes_structure,
81
- threeds_v2_params: threeds_v2_common_attributes_structure,
82
- managed_recurring: managed_recurring_attributes_structure,
83
- travel: travel_data_attributes_structure,
84
- funding: funding_attributes_structure
65
+ notification_url: notification_url,
66
+ return_success_url: return_success_url,
67
+ return_failure_url: return_failure_url,
68
+ gaming: gaming,
69
+ moto: moto,
70
+ crypto: crypto,
71
+ customer_email: customer_email,
72
+ customer_phone: customer_phone,
73
+ document_id: document_id,
74
+ fx_rate_id: fx_rate_id,
75
+ billing_address: billing_address_parameters_structure,
76
+ shipping_address: shipping_address_parameters_structure,
77
+ mpi_params: mpi_attributes_structure,
78
+ risk_params: risk_parameters_structure,
79
+ dynamic_descriptor_params: dynamic_descriptor_structure,
80
+ business_attributes: business_attributes_structure,
81
+ recurring_type: recurring_type,
82
+ recurring_category: recurring_category,
83
+ sca_params: sca_attributes_structure,
84
+ threeds_v2_params: threeds_v2_common_attributes_structure,
85
+ managed_recurring: managed_recurring_attributes_structure,
86
+ travel: travel_data_attributes_structure,
87
+ funding: funding_attributes_structure,
88
+ installment_plan_id: installment_plan_id,
89
+ installment_plan_reference: installment_plan_reference
85
90
  )
86
91
  end
87
92
 
@@ -0,0 +1,47 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Requests
4
+ module Financial
5
+ module Cards
6
+ # Bancontact is a local Belgian debit card scheme. All Belgian debit cards are co-branded
7
+ # Bancontact and Maestro.
8
+ class Bancontact < Requests::Base::Financial
9
+
10
+ include Api::Mixins::Requests::CustomerAddress::BillingInfoAttributes
11
+ include Api::Mixins::Requests::CustomerAddress::ShippingInfoAttributes
12
+ include Api::Mixins::Requests::Financial::AsyncAttributes
13
+ include Api::Mixins::Requests::Financial::PaymentAttributes
14
+
15
+ protected
16
+
17
+ # BCMC transaction type
18
+ def transaction_type
19
+ Api::Constants::Transactions::BANCONTACT
20
+ end
21
+
22
+ # Bancontact field validations
23
+ def init_field_validations
24
+ required_fields.push *%i[transaction_id amount currency return_success_url return_failure_url
25
+ billing_country]
26
+ field_values.merge! currency: 'EUR',
27
+ billing_country: 'BE'
28
+ end
29
+
30
+ # Bancontact transaction structure
31
+ def payment_transaction_structure
32
+ payment_attributes_structure.merge(
33
+ {
34
+ return_success_url: return_success_url,
35
+ return_failure_url: return_failure_url,
36
+ billing_address: billing_address_parameters_structure,
37
+ shipping_address: shipping_address_parameters_structure
38
+ }
39
+ )
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -12,6 +12,7 @@ module GenesisRuby
12
12
  include Mixins::Requests::DocumentAttributes
13
13
  include Mixins::Requests::Financial::Business::BusinessAttributes
14
14
  include Mixins::Requests::Financial::Cards::FxRateAttributes
15
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
15
16
  include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
16
17
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
17
18
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
@@ -49,25 +50,27 @@ module GenesisRuby
49
50
 
50
51
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
51
52
  super.merge(
52
- gaming: gaming,
53
- moto: moto,
54
- crypto: crypto,
55
- customer_email: customer_email,
56
- customer_phone: customer_phone,
57
- reference_id: reference_id,
58
- document_id: document_id,
59
- fx_rate_id: fx_rate_id,
60
- billing_address: billing_address_parameters_structure,
61
- shipping_address: shipping_address_parameters_structure,
62
- risk_params: risk_parameters_structure,
63
- dynamic_descriptor_params: dynamic_descriptor_structure,
64
- business_attributes: business_attributes_structure,
65
- recurring_type: recurring_type,
66
- recurring_category: recurring_category,
67
- sca_params: sca_attributes_structure,
68
- managed_recurring: managed_recurring_attributes_structure,
69
- travel: travel_data_attributes_structure,
70
- funding: funding_attributes_structure
53
+ gaming: gaming,
54
+ moto: moto,
55
+ crypto: crypto,
56
+ customer_email: customer_email,
57
+ customer_phone: customer_phone,
58
+ reference_id: reference_id,
59
+ document_id: document_id,
60
+ fx_rate_id: fx_rate_id,
61
+ billing_address: billing_address_parameters_structure,
62
+ shipping_address: shipping_address_parameters_structure,
63
+ risk_params: risk_parameters_structure,
64
+ dynamic_descriptor_params: dynamic_descriptor_structure,
65
+ business_attributes: business_attributes_structure,
66
+ recurring_type: recurring_type,
67
+ recurring_category: recurring_category,
68
+ sca_params: sca_attributes_structure,
69
+ managed_recurring: managed_recurring_attributes_structure,
70
+ travel: travel_data_attributes_structure,
71
+ funding: funding_attributes_structure,
72
+ installment_plan_id: installment_plan_id,
73
+ installment_plan_reference: installment_plan_reference
71
74
  )
72
75
  end
73
76
 
@@ -13,6 +13,7 @@ module GenesisRuby
13
13
  include Mixins::Requests::Financial::AsyncAttributes
14
14
  include Mixins::Requests::Financial::Business::BusinessAttributes
15
15
  include Mixins::Requests::Financial::Cards::FxRateAttributes
16
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
16
17
  include Mixins::Requests::Financial::Cards::MpiAttributes
17
18
  include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
18
19
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
@@ -45,12 +46,14 @@ module GenesisRuby
45
46
 
46
47
  field_value_dependencies.merge! required_tokenization_fields_conditional, required_cc_fields_conditional,
47
48
  required_recurring_managed_type_field_conditional,
48
- threeds_field_conditional_validations
49
+ threeds_field_conditional_validations, mpi_attributes_field_dependencies
49
50
  end
50
51
 
51
52
  # Special validations upon document building
52
53
  def check_requirements
53
54
  validate_threeds_card_holder_dates
55
+ # MPI Directory Server ID is optional when Scheme Tokenized with MPI Protocol Version 2
56
+ field_value_dependencies.delete :mpi_protocol_version if scheme_tokenized
54
57
 
55
58
  super
56
59
  end
@@ -58,29 +61,31 @@ module GenesisRuby
58
61
  # Sale 3D transaction request parameters
59
62
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
60
63
  super.merge(
61
- notification_url: notification_url,
62
- return_success_url: return_success_url,
63
- return_failure_url: return_failure_url,
64
- gaming: gaming,
65
- moto: moto,
66
- crypto: crypto,
67
- customer_email: customer_email,
68
- customer_phone: customer_phone,
69
- document_id: document_id,
70
- fx_rate_id: fx_rate_id,
71
- billing_address: billing_address_parameters_structure,
72
- shipping_address: shipping_address_parameters_structure,
73
- mpi_params: mpi_attributes_structure,
74
- risk_params: risk_parameters_structure,
75
- dynamic_descriptor_params: dynamic_descriptor_structure,
76
- business_attributes: business_attributes_structure,
77
- recurring_type: recurring_type,
78
- recurring_category: recurring_category,
79
- sca_params: sca_attributes_structure,
80
- threeds_v2_params: threeds_v2_common_attributes_structure,
81
- managed_recurring: managed_recurring_attributes_structure,
82
- travel: travel_data_attributes_structure,
83
- funding: funding_attributes_structure
64
+ notification_url: notification_url,
65
+ return_success_url: return_success_url,
66
+ return_failure_url: return_failure_url,
67
+ gaming: gaming,
68
+ moto: moto,
69
+ crypto: crypto,
70
+ customer_email: customer_email,
71
+ customer_phone: customer_phone,
72
+ document_id: document_id,
73
+ fx_rate_id: fx_rate_id,
74
+ billing_address: billing_address_parameters_structure,
75
+ shipping_address: shipping_address_parameters_structure,
76
+ mpi_params: mpi_attributes_structure,
77
+ risk_params: risk_parameters_structure,
78
+ dynamic_descriptor_params: dynamic_descriptor_structure,
79
+ business_attributes: business_attributes_structure,
80
+ recurring_type: recurring_type,
81
+ recurring_category: recurring_category,
82
+ sca_params: sca_attributes_structure,
83
+ threeds_v2_params: threeds_v2_common_attributes_structure,
84
+ managed_recurring: managed_recurring_attributes_structure,
85
+ travel: travel_data_attributes_structure,
86
+ funding: funding_attributes_structure,
87
+ installment_plan_id: installment_plan_id,
88
+ installment_plan_reference: installment_plan_reference
84
89
  )
85
90
  end
86
91
 
@@ -0,0 +1,56 @@
1
+ require 'genesis_ruby/api/constants/transactions/parameters/cash_payments/cash_payment_types'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Requests
6
+ module Financial
7
+ module CashPayments
8
+ # Cash payment methods allow customers to pay bills and online purchases in cash at convenient
9
+ # physical locations such as stores, banks, ATMs, even pharmacies in some countries.
10
+ class Cash < Requests::Base::Financial
11
+
12
+ include Api::Mixins::Requests::AddressInfoAttributes
13
+ include Api::Mixins::Requests::DocumentAttributes
14
+ include Api::Mixins::Requests::Financial::AsyncAttributes
15
+ include Api::Mixins::Requests::Financial::PaymentAttributes
16
+
17
+ attr_accessor :payment_type
18
+
19
+ protected
20
+
21
+ # Cash transaction type
22
+ def transaction_type
23
+ Api::Constants::Transactions::CASH
24
+ end
25
+
26
+ # Cash field validations
27
+ def init_field_validations
28
+ required_fields.push *%i[transaction_id return_success_url return_failure_url amount currency
29
+ payment_type document_id billing_country]
30
+
31
+ field_values.merge! currency: %w(MXN),
32
+ payment_type: Constants::Transactions::Parameters::CashPayments::CashPaymentTypes.all
33
+ end
34
+
35
+ # Cash request attributes structure
36
+ def payment_transaction_structure # rubocop:disable Metrics/MethodLength
37
+ payment_attributes_structure.merge(
38
+ {
39
+ return_success_url: return_success_url,
40
+ return_failure_url: return_failure_url,
41
+ customer_email: customer_email,
42
+ customer_phone: customer_phone,
43
+ payment_type: payment_type,
44
+ document_id: document_id,
45
+ billing_address: billing_address_parameters_structure,
46
+ shipping_address: shipping_address_parameters_structure
47
+ }
48
+ )
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -15,11 +15,12 @@ module GenesisRuby
15
15
  include Api::Mixins::Requests::BirthDateAttributes
16
16
  include Api::Mixins::Requests::DocumentAttributes
17
17
  include Api::Mixins::Requests::Financial::AsyncAttributes
18
+ include Api::Mixins::Requests::Financial::OnlineBankingPayments::PixAttributes
18
19
  include Api::Mixins::Requests::Financial::PaymentAttributes
19
20
  include Api::Mixins::Requests::Financial::PendingPaymentAttributes
20
21
 
21
22
  attr_accessor :gender, :marital_status, :sender_occupation, :nationality, :country_of_origin, :birth_city,
22
- :birth_state, :company_type, :company_activity, :mothers_name
23
+ :birth_state
23
24
 
24
25
  # Billing Country custom accessor
25
26
  def billing_country
@@ -28,14 +29,9 @@ module GenesisRuby
28
29
  @billing_country.to_s.upcase
29
30
  end
30
31
 
31
- # Incorporation date
32
+ # Override incorpocation date with specific format for Pix request
32
33
  def incorporation_date
33
- @incorporation_date&.strftime GenesisRuby::Api::Constants::DateTimeFormats::DD_MM_YYYY_L_HYPHENS
34
- end
35
-
36
- # Incorporation date
37
- def incorporation_date=(value)
38
- parse_date attribute: __method__, value: value, allow_empty: true
34
+ @incorporation_date&.strftime Api::Constants::DateTimeFormats::DD_MM_YYYY_L_HYPHENS
39
35
  end
40
36
 
41
37
  protected
@@ -15,6 +15,7 @@ module GenesisRuby
15
15
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
16
16
  include Mixins::Requests::Financial::CryptoAttributes
17
17
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
18
+ include Mixins::Requests::Financial::FundingAttributes
18
19
  include Mixins::Requests::Financial::Mobile::ApplePayTokenAttributes
19
20
  include Mixins::Requests::Financial::PaymentAttributes
20
21
 
@@ -43,6 +44,7 @@ module GenesisRuby
43
44
  payment_subtype: Api::Constants::Transactions::Parameters::Mobile::ApplePay::
44
45
  PaymentSubtypes.all,
45
46
  recurring_type: [Api::Constants::Transactions::Parameters::Recurring::Types::INITIAL]
47
+ field_values.merge! funding_attributes_field_validations
46
48
  end
47
49
 
48
50
  # Apple Pay payment transaction structure
@@ -60,7 +62,8 @@ module GenesisRuby
60
62
  crypto: crypto,
61
63
  recurring_type: recurring_type,
62
64
  business_attributes: business_attributes_structure,
63
- dynamic_descriptor_params: dynamic_descriptor_structure
65
+ dynamic_descriptor_params: dynamic_descriptor_structure,
66
+ funding: funding_attributes_structure
64
67
  }
65
68
  )
66
69
  end
@@ -17,6 +17,7 @@ module GenesisRuby
17
17
  include Mixins::Requests::Financial::Business::BusinessAttributes
18
18
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
19
19
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
20
+ include Mixins::Requests::Financial::FundingAttributes
20
21
  include Mixins::Requests::Financial::Mobile::GooglePayTokenAttributes
21
22
  include Mixins::Requests::Financial::NotificationAttributes
22
23
  include Mixins::Requests::Financial::PaymentAttributes
@@ -47,7 +48,7 @@ module GenesisRuby
47
48
  payment_subtype: Constants::Transactions::Parameters::Mobile::GooglePay::
48
49
  PaymentSubtypes.all,
49
50
  recurring_type: [Api::Constants::Transactions::Parameters::Recurring::Types::INITIAL]
50
- field_values.merge! threeds_field_validations
51
+ field_values.merge! threeds_field_validations, funding_attributes_field_validations
51
52
 
52
53
  field_value_dependencies.merge! threeds_field_conditional_validations
53
54
  end
@@ -60,7 +61,7 @@ module GenesisRuby
60
61
  end
61
62
 
62
63
  # Google Pay Payment Transaction Structure
63
- def payment_transaction_structure # rubocop:disable Metrics/MethodLength
64
+ def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
64
65
  payment_attributes_structure.merge(
65
66
  {
66
67
  payment_subtype: payment_subtype,
@@ -77,7 +78,8 @@ module GenesisRuby
77
78
  dynamic_descriptor_params: dynamic_descriptor_structure,
78
79
  document_id: document_id,
79
80
  recurring_type: recurring_type,
80
- threeds_v2_params: threeds_v2_common_attributes_structure
81
+ threeds_v2_params: threeds_v2_common_attributes_structure,
82
+ funding: funding_attributes_structure
81
83
  }
82
84
  )
83
85
  end
@@ -0,0 +1,129 @@
1
+ require 'genesis_ruby/api/constants/transactions/parameters/online_banking/bank_account_types'
2
+ require 'genesis_ruby/api/constants/transactions/parameters/online_banking/payout_payment_types'
3
+
4
+ module GenesisRuby
5
+ module Api
6
+ module Requests
7
+ module Financial
8
+ module OnlineBankingPayments
9
+ module OnlineBanking
10
+ # Bank Pay-out option allows merchants to transfer funds directly to their consumers' bank account.
11
+ class PayOut < Base::Financial
12
+
13
+ include Api::Mixins::Requests::AddressInfoAttributes
14
+ include Api::Mixins::Requests::BirthDateAttributes
15
+ include Api::Mixins::Requests::DocumentAttributes
16
+ include Api::Mixins::Requests::Financial::AsyncAttributes
17
+ include Api::Mixins::Requests::Financial::NotificationAttributes
18
+ include Api::Mixins::Requests::Financial::OnlineBankingPayments::PixAttributes
19
+ include Api::Mixins::Requests::Financial::PaymentAttributes
20
+
21
+ attr_reader :id_card_number, :payer_bank_phone_number, :document_type, :account_id, :user_id
22
+ attr_accessor :bank_name, :bank_code, :bank_branch, :bank_account_name, :bank_account_number, :pix_key,
23
+ :bank_province, :bank_account_type, :bank_account_verification_digit, :payment_type
24
+
25
+ # Id Card Number
26
+ def id_card_number=(value)
27
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 30
28
+ end
29
+
30
+ # Payer bank phone Number
31
+ def payer_bank_phone_number=(value)
32
+ limited_string attribute: __method__, value: value.to_s, min: 11, max: 14
33
+ end
34
+
35
+ # ID card/document type
36
+ def document_type=(value)
37
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 10
38
+ end
39
+
40
+ # Unique account identifier in Trustly's system
41
+ def account_id=(value)
42
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 255
43
+ end
44
+
45
+ # Unique user identifier defined by merchant in their own system
46
+ def user_id=(value)
47
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 255
48
+ end
49
+
50
+ protected
51
+
52
+ # Bank Payout transaction type
53
+ def transaction_type
54
+ Api::Constants::Transactions::ONLINE_BANKING_PAYOUT
55
+ end
56
+
57
+ # Set field validations
58
+ def init_field_validations
59
+ required_fields.push *%i[transaction_id amount currency notification_url return_success_url
60
+ return_failure_url billing_first_name billing_last_name billing_state billing_country]
61
+
62
+ field_values.merge! currency: %w(CNY MYR THB IDR INR ARS BRL CAD CLP COP MXN PEN UYU),
63
+ bank_account_type: Constants::Transactions::Parameters::OnlineBanking::
64
+ BankAccountTypes.all,
65
+ payment_type: Constants::Transactions::Parameters::OnlineBanking::
66
+ PayoutPaymentTypes.all
67
+ end
68
+
69
+ # Custom validations
70
+ def check_requirements
71
+ validate_brl_currency
72
+
73
+ super
74
+ end
75
+
76
+ # Bank Payout payment transaction structure
77
+ def payment_transaction_structure # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
78
+ payment_attributes_structure.merge(
79
+ {
80
+ return_success_url: return_success_url,
81
+ return_failure_url: return_failure_url,
82
+ notification_url: notification_url,
83
+ customer_email: customer_email,
84
+ customer_phone: customer_phone,
85
+ bank_name: bank_name,
86
+ bank_code: bank_code,
87
+ bank_account_name: bank_account_name,
88
+ bank_account_number: bank_account_number,
89
+ bank_account_type: bank_account_type,
90
+ bank_account_verification_digit: bank_account_verification_digit,
91
+ bank_province: bank_province,
92
+ bank_branch: bank_branch,
93
+ id_card_number: id_card_number,
94
+ payer_bank_phone_number: payer_bank_phone_number,
95
+ document_type: document_type,
96
+ document_id: document_id,
97
+ account_id: account_id,
98
+ user_id: user_id,
99
+ birth_date: birth_date,
100
+ payment_type: payment_type,
101
+ company_type: company_type,
102
+ company_activity: company_activity,
103
+ incorporation_date: incorporation_date,
104
+ mothers_name: mothers_name,
105
+ pix_key: pix_key,
106
+ billing_address: billing_address_parameters_structure,
107
+ shipping_address: shipping_address_parameters_structure
108
+ }
109
+ )
110
+ end
111
+
112
+ private
113
+
114
+ # Specific validations for BRL currency
115
+ def validate_brl_currency
116
+ return unless @currency == 'BRL'
117
+ return if bank_code || bank_name
118
+
119
+ raise ParameterError, 'Please verify the following attributes: BRL currency requires one of: ' \
120
+ 'bank_code and/or bank_name'
121
+ end
122
+
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end