genesis_ruby 0.1.9 → 0.2.1

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/Gemfile.lock +4 -4
  4. data/README.md +4 -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/funding/business_application_identifier_types.rb +45 -0
  10. data/lib/genesis_ruby/api/constants/transactions/parameters/funding/identifier_types.rb +48 -0
  11. data/lib/genesis_ruby/api/constants/transactions/parameters/funding/receiver_account_types.rb +45 -0
  12. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/bank_account_types.rb +30 -0
  13. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/bank_code_currencies.rb +3 -0
  14. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/bank_codes.rb +3 -0
  15. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/payout_payment_types.rb +42 -0
  16. data/lib/genesis_ruby/api/constants/transactions.rb +4 -0
  17. data/lib/genesis_ruby/api/mixins/requests/financial/cards/credential_on_file_attributes.rb +29 -0
  18. data/lib/genesis_ruby/api/mixins/requests/financial/cards/mpi_attributes.rb +10 -0
  19. data/lib/genesis_ruby/api/mixins/requests/financial/cards/ucof_attributes.rb +33 -0
  20. data/lib/genesis_ruby/api/mixins/requests/financial/dynamic_descriptor_attributes.rb +32 -17
  21. data/lib/genesis_ruby/api/mixins/requests/financial/funding_attributes.rb +65 -0
  22. data/lib/genesis_ruby/api/mixins/requests/financial/online_banking_payments/pix_attributes.rb +28 -0
  23. data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +25 -2
  24. data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +5 -2
  25. data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +8 -3
  26. data/lib/genesis_ruby/api/requests/financial/cards/bancontact.rb +47 -0
  27. data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +5 -2
  28. data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +8 -3
  29. data/lib/genesis_ruby/api/requests/financial/cash_payments/cash.rb +56 -0
  30. data/lib/genesis_ruby/api/requests/financial/cash_payments/pix.rb +4 -8
  31. data/lib/genesis_ruby/api/requests/financial/mobile/apple_pay.rb +8 -2
  32. data/lib/genesis_ruby/api/requests/financial/mobile/google_pay.rb +9 -4
  33. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/online_banking/pay_in.rb +4 -0
  34. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/online_banking/pay_out.rb +129 -0
  35. data/lib/genesis_ruby/api/requests/wpf/create.rb +10 -7
  36. data/lib/genesis_ruby/version.rb +1 -1
  37. metadata +17 -3
@@ -0,0 +1,28 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module Financial
6
+ module OnlineBankingPayments
7
+ # PIX shared attributes
8
+ module PixAttributes
9
+
10
+ attr_accessor :company_type, :company_activity, :mothers_name
11
+
12
+ # Incorporation Date Accessor
13
+ def incorporation_date
14
+ @incorporation_date&.strftime GenesisRuby::Api::Constants::DateTimeFormats::YYYY_MM_DD_ISO_8601
15
+ end
16
+
17
+ # Incorporation Date Accessor
18
+ def incorporation_date=(value)
19
+ parse_date attribute: __method__, value: value, allow_empty: true
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -7,23 +7,46 @@ module GenesisRuby
7
7
  class CreditCard < GenesisRuby::Api::Requests::Base::Financial
8
8
 
9
9
  include Mixins::Requests::Financial::Cards::AccountOwnerAttributes
10
+ include Mixins::Requests::Financial::Cards::CredentialOnFileAttributes
10
11
  include Mixins::Requests::Financial::Cards::CreditCardAttributes
11
12
  include Mixins::Requests::Financial::Cards::TokenizationAttributes
13
+ include Mixins::Requests::Financial::Cards::UcofAttributes
12
14
  include Mixins::Requests::Financial::PaymentAttributes
13
15
 
16
+ attr_reader :scheme_tokenized
17
+
18
+ # Visa tokenization for Visa
19
+ # Digital Secure Remote Payments (DSRP) for Mastercard.
20
+ def scheme_tokenized=(value)
21
+ allowed_options attribute: __method__,
22
+ allowed: [true, false],
23
+ value: value,
24
+ allow_empty: true,
25
+ error_message: 'Accepts only boolean values'
26
+ end
27
+
14
28
  protected
15
29
 
16
30
  # Request Field validations
17
31
  def init_field_validations
18
32
  required_fields.push *%i[transaction_id amount currency]
19
- field_values.merge! currency: Api::Constants::Currencies::Iso4217.all.map(&:upcase)
33
+ field_values.merge!(
34
+ { currency: Api::Constants::Currencies::Iso4217.all.map(&:upcase) },
35
+ credential_on_file_field_validations
36
+ )
20
37
  end
21
38
 
22
39
  # Credit Card attributes
23
40
  def payment_transaction_structure
24
41
  payment_attributes_structure.merge(
25
42
  credit_card_attributes_structure, tokenization_attributes_structure,
26
- { account_owner: account_owner_attributes_structure }
43
+ {
44
+ account_owner: account_owner_attributes_structure,
45
+ credential_on_file: credential_on_file,
46
+ credential_on_file_transaction_identifier: credential_on_file_transaction_identifier,
47
+ credential_on_file_settlement_date: credential_on_file_settlement_date,
48
+ scheme_tokenized: scheme_tokenized
49
+ }
27
50
  )
28
51
  end
29
52
 
@@ -18,6 +18,7 @@ module GenesisRuby
18
18
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
19
19
  include Mixins::Requests::Financial::CryptoAttributes
20
20
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
21
+ include Mixins::Requests::Financial::FundingAttributes
21
22
  include Mixins::Requests::Financial::GamingAttributes
22
23
  include Mixins::Requests::Financial::MotoAttributes
23
24
  include Mixins::Requests::Financial::ReferenceAttributes
@@ -36,7 +37,8 @@ module GenesisRuby
36
37
  def init_field_validations
37
38
  super
38
39
 
39
- field_values.merge! managed_recurring_field_values, recurring_type_field_values_validation_structure
40
+ field_values.merge! managed_recurring_field_values, recurring_type_field_values_validation_structure,
41
+ funding_attributes_field_validations
40
42
 
41
43
  field_value_dependencies.merge! required_tokenization_fields_conditional, required_cc_fields_conditional,
42
44
  required_recurring_managed_type_field_conditional
@@ -65,7 +67,8 @@ module GenesisRuby
65
67
  recurring_category: recurring_category,
66
68
  sca_params: sca_attributes_structure,
67
69
  managed_recurring: managed_recurring_attributes_structure,
68
- travel: travel_data_attributes_structure
70
+ travel: travel_data_attributes_structure,
71
+ funding: funding_attributes_structure
69
72
  )
70
73
  end
71
74
 
@@ -20,6 +20,7 @@ module GenesisRuby
20
20
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
21
21
  include Mixins::Requests::Financial::CryptoAttributes
22
22
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
23
+ include Mixins::Requests::Financial::FundingAttributes
23
24
  include Mixins::Requests::Financial::GamingAttributes
24
25
  include Mixins::Requests::Financial::MotoAttributes
25
26
  include Mixins::Requests::Financial::NotificationAttributes
@@ -40,16 +41,19 @@ module GenesisRuby
40
41
  super
41
42
 
42
43
  field_values.merge! managed_recurring_field_values,
43
- recurring_type_initial_field_values_validation_structure, threeds_field_validations
44
+ recurring_type_initial_field_values_validation_structure, threeds_field_validations,
45
+ funding_attributes_field_validations
44
46
 
45
47
  field_value_dependencies.merge! required_tokenization_fields_conditional, required_cc_fields_conditional,
46
48
  required_recurring_managed_type_field_conditional,
47
- threeds_field_conditional_validations
49
+ threeds_field_conditional_validations, mpi_attributes_field_dependencies
48
50
  end
49
51
 
50
52
  # Special validations upon document building
51
53
  def check_requirements
52
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
53
57
 
54
58
  super
55
59
  end
@@ -78,7 +82,8 @@ module GenesisRuby
78
82
  sca_params: sca_attributes_structure,
79
83
  threeds_v2_params: threeds_v2_common_attributes_structure,
80
84
  managed_recurring: managed_recurring_attributes_structure,
81
- travel: travel_data_attributes_structure
85
+ travel: travel_data_attributes_structure,
86
+ funding: funding_attributes_structure
82
87
  )
83
88
  end
84
89
 
@@ -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
@@ -17,6 +17,7 @@ module GenesisRuby
17
17
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
18
18
  include Mixins::Requests::Financial::CryptoAttributes
19
19
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
20
+ include Mixins::Requests::Financial::FundingAttributes
20
21
  include Mixins::Requests::Financial::GamingAttributes
21
22
  include Mixins::Requests::Financial::MotoAttributes
22
23
  include Mixins::Requests::Financial::ReferenceAttributes
@@ -35,7 +36,8 @@ module GenesisRuby
35
36
  def init_field_validations
36
37
  super
37
38
 
38
- field_values.merge! managed_recurring_field_values, recurring_type_field_values_validation_structure
39
+ field_values.merge! managed_recurring_field_values, recurring_type_field_values_validation_structure,
40
+ funding_attributes_field_validations
39
41
 
40
42
  field_value_dependencies.merge! required_tokenization_fields_conditional, required_cc_fields_conditional,
41
43
  required_recurring_managed_type_field_conditional
@@ -64,7 +66,8 @@ module GenesisRuby
64
66
  recurring_category: recurring_category,
65
67
  sca_params: sca_attributes_structure,
66
68
  managed_recurring: managed_recurring_attributes_structure,
67
- travel: travel_data_attributes_structure
69
+ travel: travel_data_attributes_structure,
70
+ funding: funding_attributes_structure
68
71
  )
69
72
  end
70
73
 
@@ -19,6 +19,7 @@ module GenesisRuby
19
19
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
20
20
  include Mixins::Requests::Financial::CryptoAttributes
21
21
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
22
+ include Mixins::Requests::Financial::FundingAttributes
22
23
  include Mixins::Requests::Financial::GamingAttributes
23
24
  include Mixins::Requests::Financial::MotoAttributes
24
25
  include Mixins::Requests::Financial::NotificationAttributes
@@ -39,16 +40,19 @@ module GenesisRuby
39
40
  super
40
41
 
41
42
  field_values.merge! managed_recurring_field_values,
42
- recurring_type_initial_field_values_validation_structure, threeds_field_validations
43
+ recurring_type_initial_field_values_validation_structure, threeds_field_validations,
44
+ funding_attributes_field_validations
43
45
 
44
46
  field_value_dependencies.merge! required_tokenization_fields_conditional, required_cc_fields_conditional,
45
47
  required_recurring_managed_type_field_conditional,
46
- threeds_field_conditional_validations
48
+ threeds_field_conditional_validations, mpi_attributes_field_dependencies
47
49
  end
48
50
 
49
51
  # Special validations upon document building
50
52
  def check_requirements
51
53
  validate_threeds_card_holder_dates
54
+ # MPI Directory Server ID is optional when Scheme Tokenized with MPI Protocol Version 2
55
+ field_value_dependencies.delete :mpi_protocol_version if scheme_tokenized
52
56
 
53
57
  super
54
58
  end
@@ -77,7 +81,8 @@ module GenesisRuby
77
81
  sca_params: sca_attributes_structure,
78
82
  threeds_v2_params: threeds_v2_common_attributes_structure,
79
83
  managed_recurring: managed_recurring_attributes_structure,
80
- travel: travel_data_attributes_structure
84
+ travel: travel_data_attributes_structure,
85
+ funding: funding_attributes_structure
81
86
  )
82
87
  end
83
88
 
@@ -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
@@ -12,8 +12,10 @@ module GenesisRuby
12
12
  include Mixins::Requests::BirthDateAttributes
13
13
  include Mixins::Requests::DocumentAttributes
14
14
  include Mixins::Requests::Financial::Business::BusinessAttributes
15
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
15
16
  include Mixins::Requests::Financial::CryptoAttributes
16
17
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
18
+ include Mixins::Requests::Financial::FundingAttributes
17
19
  include Mixins::Requests::Financial::Mobile::ApplePayTokenAttributes
18
20
  include Mixins::Requests::Financial::PaymentAttributes
19
21
 
@@ -40,7 +42,9 @@ module GenesisRuby
40
42
 
41
43
  field_values.merge! currency: Api::Constants::Currencies::Iso4217.all.map(&:upcase),
42
44
  payment_subtype: Api::Constants::Transactions::Parameters::Mobile::ApplePay::
43
- PaymentSubtypes.all
45
+ PaymentSubtypes.all,
46
+ recurring_type: [Api::Constants::Transactions::Parameters::Recurring::Types::INITIAL]
47
+ field_values.merge! funding_attributes_field_validations
44
48
  end
45
49
 
46
50
  # Apple Pay payment transaction structure
@@ -56,8 +60,10 @@ module GenesisRuby
56
60
  shipping_address: shipping_address_parameters_structure,
57
61
  document_id: document_id,
58
62
  crypto: crypto,
63
+ recurring_type: recurring_type,
59
64
  business_attributes: business_attributes_structure,
60
- dynamic_descriptor_params: dynamic_descriptor_structure
65
+ dynamic_descriptor_params: dynamic_descriptor_structure,
66
+ funding: funding_attributes_structure
61
67
  }
62
68
  )
63
69
  end
@@ -15,7 +15,9 @@ module GenesisRuby
15
15
  include Mixins::Requests::DocumentAttributes
16
16
  include Mixins::Requests::Financial::AsyncAttributes
17
17
  include Mixins::Requests::Financial::Business::BusinessAttributes
18
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
18
19
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
20
+ include Mixins::Requests::Financial::FundingAttributes
19
21
  include Mixins::Requests::Financial::Mobile::GooglePayTokenAttributes
20
22
  include Mixins::Requests::Financial::NotificationAttributes
21
23
  include Mixins::Requests::Financial::PaymentAttributes
@@ -44,8 +46,9 @@ module GenesisRuby
44
46
 
45
47
  field_values.merge! currency: Constants::Currencies::Iso4217.all.map(&:upcase),
46
48
  payment_subtype: Constants::Transactions::Parameters::Mobile::GooglePay::
47
- PaymentSubtypes.all
48
- field_values.merge! threeds_field_validations
49
+ PaymentSubtypes.all,
50
+ recurring_type: [Api::Constants::Transactions::Parameters::Recurring::Types::INITIAL]
51
+ field_values.merge! threeds_field_validations, funding_attributes_field_validations
49
52
 
50
53
  field_value_dependencies.merge! threeds_field_conditional_validations
51
54
  end
@@ -58,7 +61,7 @@ module GenesisRuby
58
61
  end
59
62
 
60
63
  # Google Pay Payment Transaction Structure
61
- def payment_transaction_structure # rubocop:disable Metrics/MethodLength
64
+ def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
62
65
  payment_attributes_structure.merge(
63
66
  {
64
67
  payment_subtype: payment_subtype,
@@ -74,7 +77,9 @@ module GenesisRuby
74
77
  business_attributes: business_attributes_structure,
75
78
  dynamic_descriptor_params: dynamic_descriptor_structure,
76
79
  document_id: document_id,
77
- threeds_v2_params: threeds_v2_common_attributes_structure
80
+ recurring_type: recurring_type,
81
+ threeds_v2_params: threeds_v2_common_attributes_structure,
82
+ funding: funding_attributes_structure
78
83
  }
79
84
  )
80
85
  end
@@ -121,6 +121,10 @@ module GenesisRuby
121
121
  GBP: {
122
122
  bank_code: Api::Constants::Transactions::Parameters::OnlineBanking::BankCodeCurrencies
123
123
  .bank_codes_per_currency('GBP')
124
+ },
125
+ NZD: {
126
+ bank_code: Api::Constants::Transactions::Parameters::OnlineBanking::BankCodeCurrencies
127
+ .bank_codes_per_currency('NZD')
124
128
  }
125
129
  }
126
130
  }
@@ -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
@@ -10,17 +10,18 @@ module GenesisRuby
10
10
  # Web-Payment Form Request
11
11
  class Create < Request # rubocop:disable Metrics/ClassLength
12
12
 
13
- include Mixins::Requests::Financial::PaymentAttributes
14
13
  include Mixins::Requests::AddressInfoAttributes
15
14
  include Mixins::Requests::Financial::AsyncAttributes
16
- include Mixins::Requests::Financial::NotificationAttributes
17
- include Mixins::Requests::Financial::PendingPaymentAttributes
18
- include Mixins::Requests::Financial::Threeds::Version2::WpfAttributes
15
+ include Mixins::Requests::Financial::Business::BusinessAttributes
19
16
  include Mixins::Requests::Financial::Cards::AccountOwnerAttributes
20
17
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
21
18
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
19
+ include Mixins::Requests::Financial::FundingAttributes
20
+ include Mixins::Requests::Financial::NotificationAttributes
21
+ include Mixins::Requests::Financial::PaymentAttributes
22
+ include Mixins::Requests::Financial::PendingPaymentAttributes
22
23
  include Mixins::Requests::Financial::RiskAttributes
23
- include Mixins::Requests::Financial::Business::BusinessAttributes
24
+ include Mixins::Requests::Financial::Threeds::Version2::WpfAttributes
24
25
  include Mixins::Requests::WpfRemindersAttributes
25
26
 
26
27
  attr_reader :locale, :sca_preference, :sca_exemption
@@ -122,7 +123,8 @@ module GenesisRuby
122
123
 
123
124
  field_values.merge!(
124
125
  { currency: Api::Constants::Currencies::Iso4217.all.map(&:upcase) },
125
- threeds_field_validations
126
+ threeds_field_validations,
127
+ funding_attributes_field_validations
126
128
  )
127
129
  end
128
130
 
@@ -168,7 +170,8 @@ module GenesisRuby
168
170
  risk_params: risk_parameters_structure,
169
171
  account_owner: account_owner_attributes_structure,
170
172
  pay_later: pay_later,
171
- reminders: pay_later ? reminders_structure : []
173
+ reminders: pay_later ? reminders_structure : [],
174
+ funding: funding_attributes_structure
172
175
  }
173
176
  }
174
177
  end
@@ -1,5 +1,5 @@
1
1
  module GenesisRuby
2
2
 
3
- VERSION = '0.1.9'.freeze
3
+ VERSION = '0.2.1'.freeze
4
4
 
5
5
  end