genesis_ruby 0.1.7 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/Gemfile.lock +45 -39
  4. data/README.md +246 -0
  5. data/VERSION +1 -1
  6. data/lib/genesis_ruby/api/constants/transactions/parameters/cash_payments/company_types.rb +45 -0
  7. data/lib/genesis_ruby/api/constants/transactions/parameters/cash_payments/genders.rb +27 -0
  8. data/lib/genesis_ruby/api/constants/transactions/parameters/cash_payments/marital_statuses.rb +39 -0
  9. data/lib/genesis_ruby/api/constants/transactions/parameters/mobile/apple_pay/payment_subtypes.rb +29 -0
  10. data/lib/genesis_ruby/api/constants/transactions/parameters/mobile/google_pay/payment_subtypes.rb +29 -0
  11. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/bank_code_currencies.rb +128 -0
  12. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/bank_codes.rb +600 -0
  13. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/payment_types.rb +36 -0
  14. data/lib/genesis_ruby/api/constants/transactions/parameters/wallets/pay_pal/payment_types.rb +31 -0
  15. data/lib/genesis_ruby/api/mixins/requests/attribute_validation.rb +138 -4
  16. data/lib/genesis_ruby/api/mixins/requests/birth_date_attributes.rb +22 -0
  17. data/lib/genesis_ruby/api/mixins/requests/customer_address/billing_info_attributes.rb +11 -10
  18. data/lib/genesis_ruby/api/mixins/requests/customer_address/customer_info_attributes.rb +1 -1
  19. data/lib/genesis_ruby/api/mixins/requests/customer_address/shipping_info_attributes.rb +11 -10
  20. data/lib/genesis_ruby/api/mixins/requests/financial/cards/credit_card_attributes.rb +7 -0
  21. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_attributes.rb +21 -20
  22. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_indian_card_attributes.rb +15 -39
  23. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/recurring_type_attributes.rb +15 -9
  24. data/lib/genesis_ruby/api/mixins/requests/financial/cards/tokenization_attributes.rb +9 -0
  25. data/lib/genesis_ruby/api/mixins/requests/financial/consumer_identifier_attributes.rb +26 -0
  26. data/lib/genesis_ruby/api/mixins/requests/financial/mobile/apple_pay_token_attributes.rb +51 -0
  27. data/lib/genesis_ruby/api/mixins/requests/financial/mobile/google_pay_token_attributes.rb +50 -0
  28. data/lib/genesis_ruby/api/mixins/requests/financial/online_banking_payments/virtual_payment_address_attributes.rb +27 -0
  29. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/browser.rb +11 -22
  30. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/card_holder_account.rb +81 -49
  31. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/common_attributes.rb +23 -0
  32. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/control.rb +13 -26
  33. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/merchant_risk.rb +21 -58
  34. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/purchase.rb +8 -11
  35. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/sdk.rb +10 -10
  36. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/wpf_attributes.rb +9 -0
  37. data/lib/genesis_ruby/api/request.rb +4 -2
  38. data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +6 -4
  39. data/lib/genesis_ruby/api/requests/base/financials/south_american_payments.rb +59 -0
  40. data/lib/genesis_ruby/api/requests/base/reference.rb +3 -2
  41. data/lib/genesis_ruby/api/requests/financial/cards/argencard.rb +26 -0
  42. data/lib/genesis_ruby/api/requests/financial/cards/aura.rb +26 -0
  43. data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +10 -2
  44. data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +19 -10
  45. data/lib/genesis_ruby/api/requests/financial/cards/cabal.rb +26 -0
  46. data/lib/genesis_ruby/api/requests/financial/cards/cencosud.rb +26 -0
  47. data/lib/genesis_ruby/api/requests/financial/cards/elo.rb +26 -0
  48. data/lib/genesis_ruby/api/requests/financial/cards/naranja.rb +26 -0
  49. data/lib/genesis_ruby/api/requests/financial/cards/nativa.rb +26 -0
  50. data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +10 -2
  51. data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +19 -10
  52. data/lib/genesis_ruby/api/requests/financial/cards/tarjeta_shopping.rb +26 -0
  53. data/lib/genesis_ruby/api/requests/financial/cards/threeds/v2/method_continue.rb +2 -2
  54. data/lib/genesis_ruby/api/requests/financial/cash_payments/baloto.rb +26 -0
  55. data/lib/genesis_ruby/api/requests/financial/cash_payments/banco_de_occidente.rb +26 -0
  56. data/lib/genesis_ruby/api/requests/financial/cash_payments/boleto.rb +26 -0
  57. data/lib/genesis_ruby/api/requests/financial/cash_payments/efecty.rb +26 -0
  58. data/lib/genesis_ruby/api/requests/financial/cash_payments/oxxo.rb +26 -0
  59. data/lib/genesis_ruby/api/requests/financial/cash_payments/pago_facil.rb +26 -0
  60. data/lib/genesis_ruby/api/requests/financial/cash_payments/pix.rb +92 -0
  61. data/lib/genesis_ruby/api/requests/financial/cash_payments/redpagos.rb +26 -0
  62. data/lib/genesis_ruby/api/requests/financial/mobile/apple_pay.rb +91 -0
  63. data/lib/genesis_ruby/api/requests/financial/mobile/google_pay.rb +108 -0
  64. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/bancomer.rb +33 -0
  65. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/bradesco.rb +33 -0
  66. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/davivienda.rb +34 -0
  67. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/itau.rb +33 -0
  68. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/online_banking/pay_in.rb +157 -0
  69. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/pse.rb +33 -0
  70. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/rapi_pago.rb +33 -0
  71. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/santander.rb +33 -0
  72. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/webpay.rb +33 -0
  73. data/lib/genesis_ruby/api/requests/financial/void.rb +2 -2
  74. data/lib/genesis_ruby/api/requests/financial/wallets/pay_pay.rb +65 -0
  75. data/lib/genesis_ruby/api/requests/non_financial/reconcile/date_range.rb +2 -2
  76. data/lib/genesis_ruby/api/requests/wpf/create.rb +11 -15
  77. data/lib/genesis_ruby/api/requests/wpf/reconcile.rb +2 -2
  78. data/lib/genesis_ruby/dependencies.rb +1 -0
  79. data/lib/genesis_ruby/utils/common.rb +26 -0
  80. data/lib/genesis_ruby/version.rb +1 -1
  81. metadata +46 -3
@@ -6,13 +6,15 @@ module GenesisRuby
6
6
  module Requests
7
7
  # Request Class attribute validations
8
8
  # Reads the pre-set `validation_<attribute>` and perform validation on the fields
9
- module AttributeValidation
9
+ module AttributeValidation # rubocop:disable Metrics/ModuleLength
10
10
 
11
11
  protected
12
12
 
13
13
  # Perform validation
14
14
  def validate
15
- validate_required_fields
15
+ validate_required_fields required_fields
16
+ validate_field_values field_values
17
+ validate_field_value_dependencies field_value_dependencies
16
18
  end
17
19
 
18
20
  # Required Fields Accessor
@@ -22,15 +24,41 @@ module GenesisRuby
22
24
 
23
25
  # Required Fields Accessor
24
26
  def required_fields=(value)
25
- raise RequestError, 'Invalid value given for Required Fields! Allowed type Array.' unless value.is_a? Array
27
+ raise RequestError, 'Invalid value given for Required Fields! Allowed: Array.' unless value.is_a? Array
26
28
 
27
29
  @required_fields = value
28
30
  end
29
31
 
32
+ # Field Values Accessor
33
+ def field_values
34
+ @field_values ||= {}
35
+ end
36
+
37
+ # Field Values Accessor
38
+ def field_values=(value)
39
+ raise RequestError, 'Invalid value given for Field Values! Allowed: Hash.' unless value.is_a? Hash
40
+
41
+ @field_values = value
42
+ end
43
+
44
+ # Field Value Dependencies Accessor
45
+ def field_value_dependencies
46
+ @field_value_dependencies ||= {}
47
+ end
48
+
49
+ # Field Value Dependencies Accessor
50
+ def field_value_dependencies=(value)
51
+ unless value.is_a? Hash
52
+ raise RequestError, 'Invalid value given for Required Field Conditional! Allowed: Hash.'
53
+ end
54
+
55
+ @field_value_dependencies = value
56
+ end
57
+
30
58
  private
31
59
 
32
60
  # Validated Required fields
33
- def validate_required_fields
61
+ def validate_required_fields(required_fields)
34
62
  required_fields.each do |field_name|
35
63
  if null_or_empty_field?(field_name)
36
64
  raise ParameterError, "Empty (nil) for required parameter: #{field_name}"
@@ -38,6 +66,41 @@ module GenesisRuby
38
66
  end
39
67
  end
40
68
 
69
+ # Validate Required Field Values
70
+ def validate_field_values(field_values)
71
+ field_values.each do |field_name, field_value|
72
+ # Allow optional attributes by bypassing null or empty field values
73
+ next if null_or_empty_field? field_name
74
+
75
+ # Validate against Array set of values
76
+ next if allowed_array field_name, field_value
77
+
78
+ # Validate against a value
79
+ allowed_value field_name, field_value
80
+ end
81
+ end
82
+
83
+ # Validate Required Field Conditional
84
+ # Validates if given field
85
+ def validate_field_value_dependencies(required_field_conditional) # rubocop:disable Metrics/MethodLength
86
+ required_field_conditional.each do |field_name, value_dependencies|
87
+ # Allow optional attributes
88
+ next if null_or_empty_field? field_name
89
+
90
+ unless value_dependencies.is_a?(Hash) || value_dependencies.is_a?(Array)
91
+ raise RequestError, 'Invalid value given for Required Field Conditional Dependencies! Allowed: Hash.'
92
+ end
93
+
94
+ if value_dependencies.is_a? Array
95
+ group_field_dependencies field_name, value_dependencies
96
+
97
+ next
98
+ end
99
+
100
+ loop_field_value_dependencies field_name, value_dependencies
101
+ end
102
+ end
103
+
41
104
  # Validate if the given field_name is null or empty
42
105
  def null_or_empty_field?(field_name)
43
106
  field_value = __send__ field_name.to_sym
@@ -47,6 +110,77 @@ module GenesisRuby
47
110
  field_value.nil? || field_value.empty?
48
111
  end
49
112
 
113
+ # Validates Field accessor against allowed values
114
+ def allowed_array(field_name, allowed_values)
115
+ return nil unless allowed_values.is_a? Array
116
+
117
+ unless allowed_values.include?(__send__(field_name))
118
+ raise ParameterError, format(
119
+ 'Parameter %{field} is set to %{field_value}, but expected to be one of (%{allowed})',
120
+ field: field_name,
121
+ field_value: __send__(field_name),
122
+ allowed: allowed_values.join(', ')
123
+ )
124
+ end
125
+
126
+ true
127
+ end
128
+
129
+ # Validates Field accessor against allowed value
130
+ def allowed_value(field_name, allowed_value)
131
+ return nil if __send__(field_name) == allowed_value
132
+
133
+ raise ParameterError, format(
134
+ 'Required parameter %{field_name} is set to %{field_value}, but expected to be %{allowed_value}',
135
+ field_name: field_name,
136
+ field_value: __send__(field_name),
137
+ allowed_value: allowed_value
138
+ )
139
+ end
140
+
141
+ # Validate if given dependencies based on the field value satisfy the request
142
+ def loop_field_value_dependencies(field_name, value_dependencies)
143
+ value_dependencies.each do |value_depend, dependencies|
144
+ next if __send__(field_name).to_s != value_depend.to_s
145
+
146
+ group_field_dependencies field_name, dependencies if dependencies.is_a? Array
147
+ group_field_value_dependencies field_name, dependencies if dependencies.is_a? Hash
148
+ end
149
+ end
150
+
151
+ # Validates Group field dependencies
152
+ # Check if all of the given array of attributes are set (not null or empty fields)
153
+ def group_field_dependencies(field_name, fields)
154
+ fields.each do |field|
155
+ next unless null_or_empty_field? field
156
+
157
+ raise ParameterError, format(
158
+ '%{field_name} is depending on: %{field}, which is empty (null)!',
159
+ field_name: field_name,
160
+ field: field
161
+ )
162
+ end
163
+ end
164
+
165
+ # Validates Group of attributes against given allowed values
166
+ def group_field_value_dependencies(field_name, dependencies) # rubocop:disable Metrics/MethodLength
167
+ dependencies.each do |field_depend, allowed_values|
168
+ next if null_or_empty_field? field_depend
169
+
170
+ next if allowed_values.include? __send__(field_depend)
171
+
172
+ raise ParameterError, format(
173
+ '%{field} with value %{field_value} is depending on: %{field_depend}, which is ' \
174
+ 'expected to be one of (%{allowed})! Please refer the official documentation for %{trx_type} type.',
175
+ field: field_name,
176
+ field_value: __send__(field_name),
177
+ field_depend: field_depend,
178
+ allowed: allowed_values.join(', '),
179
+ trx_type: self.class.name
180
+ )
181
+ end
182
+ end
183
+
50
184
  end
51
185
  end
52
186
  end
@@ -0,0 +1,22 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ # Birth Date Attributes mixin
6
+ module BirthDateAttributes
7
+
8
+ # Birth Date Accessor
9
+ def birth_date
10
+ @birth_date&.strftime GenesisRuby::Api::Constants::DateTimeFormats::DD_MM_YYYY_L_HYPHENS
11
+ end
12
+
13
+ # Birth Date Accessor
14
+ def birth_date=(value)
15
+ parse_date attribute: __method__, value: value, allow_empty: true
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -7,21 +7,22 @@ module GenesisRuby
7
7
  module BillingInfoAttributes
8
8
 
9
9
  attr_accessor :billing_first_name, :billing_last_name, :billing_address1, :billing_address2,
10
- :billing_zip_code, :billing_city, :billing_state, :billing_country
10
+ :billing_zip_code, :billing_city, :billing_state, :billing_country, :billing_neighborhood
11
11
 
12
12
  protected
13
13
 
14
14
  # Build Hash with all parameters
15
- def billing_address_parameters_structure
15
+ def billing_address_parameters_structure # rubocop:disable Metrics/MethodLength
16
16
  {
17
- first_name: billing_first_name,
18
- last_name: billing_last_name,
19
- address1: billing_address1,
20
- address2: billing_address2,
21
- zip_code: billing_zip_code,
22
- city: billing_city,
23
- state: billing_state,
24
- country: billing_country
17
+ first_name: billing_first_name,
18
+ last_name: billing_last_name,
19
+ address1: billing_address1,
20
+ address2: billing_address2,
21
+ zip_code: billing_zip_code,
22
+ city: billing_city,
23
+ state: billing_state,
24
+ neighborhood: billing_neighborhood,
25
+ country: billing_country
25
26
  }
26
27
  end
27
28
 
@@ -13,7 +13,7 @@ module GenesisRuby
13
13
 
14
14
  # Email of the customer
15
15
  def customer_email=(value)
16
- raise GenesisRuby::ParameterError unless value =~ /\A.+@.+\..+\Z/
16
+ raise GenesisRuby::ParameterError unless value.nil? || value =~ /\A.+@.+\..+\Z/
17
17
 
18
18
  @customer_email = value
19
19
  end
@@ -7,21 +7,22 @@ module GenesisRuby
7
7
  module ShippingInfoAttributes
8
8
 
9
9
  attr_accessor :shipping_first_name, :shipping_last_name, :shipping_address1, :shipping_address2,
10
- :shipping_zip_code, :shipping_city, :shipping_state, :shipping_country
10
+ :shipping_zip_code, :shipping_city, :shipping_state, :shipping_country, :shipping_neighborhood
11
11
 
12
12
  protected
13
13
 
14
14
  # Build Hash with all parameters
15
- def shipping_address_parameters_structure
15
+ def shipping_address_parameters_structure # rubocop:disable Metrics/MethodLength
16
16
  {
17
- first_name: shipping_first_name,
18
- last_name: shipping_last_name,
19
- address1: shipping_address1,
20
- address2: shipping_address2,
21
- zip_code: shipping_zip_code,
22
- city: shipping_city,
23
- state: shipping_state,
24
- country: shipping_country
17
+ first_name: shipping_first_name,
18
+ last_name: shipping_last_name,
19
+ address1: shipping_address1,
20
+ address2: shipping_address2,
21
+ zip_code: shipping_zip_code,
22
+ city: shipping_city,
23
+ state: shipping_state,
24
+ neighborhood: shipping_neighborhood,
25
+ country: shipping_country
25
26
  }
26
27
  end
27
28
 
@@ -11,6 +11,13 @@ module GenesisRuby
11
11
 
12
12
  protected
13
13
 
14
+ # Credit Card Fields validation structure
15
+ def required_cc_fields_conditional
16
+ {
17
+ card_number: %i[card_holder expiration_month expiration_year]
18
+ }
19
+ end
20
+
14
21
  # Credit Card Attributes Structure
15
22
  def credit_card_attributes_structure
16
23
  {
@@ -15,26 +15,8 @@ module GenesisRuby
15
15
 
16
16
  include Recurring::ManagedRecurringIndianCardAttributes
17
17
 
18
- attr_reader :managed_recurring_mode, :managed_recurring_interval, :managed_recurring_time_of_day,
19
- :managed_recurring_period, :managed_recurring_max_count
20
- attr_accessor :managed_recurring_amount
21
-
22
- # This indicates that the gateway will automatically manage the subsequent recurring transactions.
23
- def managed_recurring_mode=(value)
24
- allowed_options attribute: __method__,
25
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
26
- Modes.all,
27
- value: value
28
- end
29
-
30
- # The interval type for the period: days or months. The default value is days
31
- def managed_recurring_interval=(value)
32
- allowed_options attribute: __method__,
33
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
34
- Intervals.all,
35
- value: value,
36
- allow_empty: true
37
- end
18
+ attr_reader :managed_recurring_time_of_day, :managed_recurring_period, :managed_recurring_max_count
19
+ attr_accessor :managed_recurring_amount, :managed_recurring_mode, :managed_recurring_interval
38
20
 
39
21
  # Specifies the date of the first recurring event in the future
40
22
  # default value is date of creation + period.
@@ -67,6 +49,25 @@ module GenesisRuby
67
49
 
68
50
  protected
69
51
 
52
+ # Managed Recurring field values validation structure
53
+ def managed_recurring_field_values
54
+ {
55
+ managed_recurring_mode: Api::Constants::Transactions::Parameters::ManagedRecurring::Modes.all,
56
+ managed_recurring_interval: Api::Constants::Transactions::Parameters::ManagedRecurring::Intervals
57
+ .all
58
+ }.merge managed_recurring_indian_card_field_values
59
+ end
60
+
61
+ # Managed Recurring Field validation structure
62
+ def required_recurring_managed_type_field_conditional
63
+ {
64
+ recurring_type: Hash[
65
+ Api::Constants::Transactions::Parameters::Recurring::Types::MANAGED,
66
+ %i[managed_recurring_mode]
67
+ ]
68
+ }
69
+ end
70
+
70
71
  # Managed Recurring attributes structure
71
72
  def managed_recurring_attributes_structure
72
73
  amount = managed_recurring_amount
@@ -14,49 +14,25 @@ module GenesisRuby
14
14
  # India (RBI) regulations.
15
15
  module ManagedRecurringIndianCardAttributes
16
16
 
17
- attr_reader :managed_recurring_payment_type, :managed_recurring_amount_type,
18
- :managed_recurring_frequency, :managed_recurring_validated
17
+ attr_accessor :managed_recurring_registration_reference_number, :managed_recurring_max_amount,
18
+ :managed_recurring_payment_type, :managed_recurring_amount_type,
19
+ :managed_recurring_frequency, :managed_recurring_validated
19
20
 
20
- attr_accessor :managed_recurring_registration_reference_number, :managed_recurring_max_amount
21
-
22
- # Payment Type of the current recurring transaction
23
- def managed_recurring_payment_type=(value)
24
- allowed_options attribute: __method__,
25
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
26
- PaymentTypes.all,
27
- value: value.to_s,
28
- allow_empty: true
29
- end
30
-
31
- # Amount Type of the current recurring transaction
32
- def managed_recurring_amount_type=(value)
33
- allowed_options attribute: __method__,
34
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
35
- AmountTypes.all,
36
- value: value.to_s,
37
- allow_empty: true
38
- end
39
-
40
- # Frequencies of the Frequency of the subsequent transactions
41
- def managed_recurring_frequency=(value)
42
- allowed_options attribute: __method__,
43
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
44
- Frequencies.all,
45
- value: value.to_s,
46
- allow_empty: true
47
- end
21
+ protected
48
22
 
49
- # Indicates if the current transaction is valid as per the registered agreement. Values: true, false
50
- def managed_recurring_validated=(value)
51
- allowed_options attribute: __method__,
52
- allowed: [true, false],
53
- value: value,
54
- allow_empty: true,
55
- error_message: 'Accepts only boolean values'
23
+ # Managed Recurring Indian Card field values validation structure
24
+ def managed_recurring_indian_card_field_values
25
+ {
26
+ managed_recurring_payment_type: Api::Constants::Transactions::Parameters::ManagedRecurring::
27
+ PaymentTypes.all,
28
+ managed_recurring_amount_type: Api::Constants::Transactions::Parameters::ManagedRecurring::
29
+ AmountTypes.all,
30
+ managed_recurring_frequency: Api::Constants::Transactions::Parameters::ManagedRecurring::
31
+ Frequencies.all,
32
+ managed_recurring_validated: [true, false]
33
+ }
56
34
  end
57
35
 
58
- protected
59
-
60
36
  # Managed Recurring Indian Card attributes structure
61
37
  def managed_recurring_indian_card_attributes_structure
62
38
  max_amount = managed_recurring_max_amount
@@ -10,18 +10,24 @@ module GenesisRuby
10
10
  # Recurring Type Attributes
11
11
  module RecurringTypeAttributes
12
12
 
13
- attr_reader :recurring_type
13
+ attr_accessor :recurring_type
14
14
 
15
- # Specifies the recurring type of transaction
16
- def recurring_type=(value)
17
- allowed_options attribute: __method__,
18
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::Recurring::
19
- Types.all,
20
- value: value,
21
- allow_empty: true
15
+ protected
16
+
17
+ # Recurring Type for Initial transaction types validation structure
18
+ def recurring_type_initial_field_values_validation_structure
19
+ {
20
+ recurring_type: Api::Constants::Transactions::Parameters::Recurring::Types.all -
21
+ [Api::Constants::Transactions::Parameters::Recurring::Types::SUBSEQUENT]
22
+ }
22
23
  end
23
24
 
24
- protected
25
+ # Recurring Type Field Value validation structure
26
+ def recurring_type_field_values_validation_structure
27
+ {
28
+ recurring_type: Api::Constants::Transactions::Parameters::Recurring::Types.all
29
+ }
30
+ end
25
31
 
26
32
  # Minimum required fields with recurring_type subsequent request
27
33
  def recurring_type_subsequent_required_request_attributes
@@ -21,6 +21,15 @@ module GenesisRuby
21
21
 
22
22
  protected
23
23
 
24
+ # Tokenization Attributes validation structure
25
+ def required_tokenization_fields_conditional
26
+ {
27
+ token: %i[consumer_id customer_email],
28
+ remember_card: { true => %i[customer_email card_number] },
29
+ consumer_id: %i[customer_email]
30
+ }
31
+ end
32
+
24
33
  # Tokenization Attributes Structure
25
34
  def tokenization_attributes_structure
26
35
  {
@@ -0,0 +1,26 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module Financial
6
+ # Consumer Identifier Attributes
7
+ module ConsumerIdentifierAttributes
8
+
9
+ attr_reader :consumer_reference, :national_id
10
+
11
+ # Consumer reference is a unique consumer identifier
12
+ def consumer_reference=(value)
13
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 20
14
+ end
15
+
16
+ # National Id of the consumer
17
+ def national_id=(value)
18
+ limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 20
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,51 @@
1
+ require 'json'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Mixins
6
+ module Requests
7
+ module Financial
8
+ module Mobile
9
+ # Apple Pay Token Attributes mixin
10
+ module ApplePayTokenAttributes
11
+
12
+ attr_accessor :token_version, :token_data, :token_signature,
13
+ :token_ephemeral_public_key, :token_public_key_hash, :token_transaction_id,
14
+ :token_display_name, :token_network, :token_type, :token_transaction_identifier,
15
+ :token_application_data, :token_wrapped_key
16
+
17
+ # Apple Pay token structure
18
+ def payment_token_structure # rubocop:disable Metrics/MethodLength
19
+ structure = {
20
+ paymentData: {
21
+ version: token_version,
22
+ data: token_data,
23
+ signature: token_signature,
24
+ header: {
25
+ applicationData: token_application_data,
26
+ ephemeralPublicKey: token_ephemeral_public_key,
27
+ wrappedKey: token_wrapped_key,
28
+ publicKeyHash: token_public_key_hash,
29
+ transactionId: token_transaction_id
30
+ }
31
+ },
32
+ paymentMethod: {
33
+ displayName: token_display_name,
34
+ network: token_network,
35
+ type: token_type
36
+ },
37
+ transactionIdentifier: token_transaction_identifier
38
+ }
39
+
40
+ GenesisRuby::Utils::Common.deep_compact!(structure)
41
+
42
+ structure.to_json
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,50 @@
1
+ require 'json'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Mixins
6
+ module Requests
7
+ module Financial
8
+ module Mobile
9
+ # Google Pay Token Attributes
10
+ module GooglePayTokenAttributes
11
+
12
+ attr_accessor :token_signature, :token_signed_key, :token_protocol_version, :token_signed_message
13
+
14
+ # Google Pay Token Signatures accessor
15
+ def token_signatures
16
+ @token_signatures ||= []
17
+ end
18
+
19
+ # Google Pay Token Signatures accessor
20
+ def token_signatures=(value)
21
+ if !value.is_a?(Array) && !value.nil?
22
+ raise InvalidArgumentError, 'Invalid value given for Token Signatures. Accept array'
23
+ end
24
+
25
+ @token_signatures = value
26
+ end
27
+
28
+ def google_pay_token_structure # rubocop:disable Metrics/MethodLength
29
+ structure = {
30
+ signature: token_signature,
31
+ protocolVersion: token_protocol_version,
32
+ signedMessage: token_signed_message,
33
+ intermediateSigningKey: {
34
+ signedKey: token_signed_key,
35
+ signatures: token_signatures
36
+ }
37
+ }
38
+
39
+ GenesisRuby::Utils::Common.deep_compact!(structure)
40
+
41
+ structure.to_json
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,27 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module Financial
6
+ module OnlineBankingPayments
7
+ # Virtual Payment Address Attributes
8
+ module VirtualPaymentAddressAttributes
9
+
10
+ attr_reader :virtual_payment_address
11
+
12
+ # Virtual Payment Address (VPA) of the customer, format: someone@bank
13
+ def virtual_payment_address=(value)
14
+ @virtual_payment_address = value.to_s
15
+
16
+ return if value.to_s.empty? || value =~ /\A.+@.+\Z/
17
+
18
+ raise InvalidArgumentError, 'Virtual Payment Address has invalid format. Correct format: someone@bank'
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end