genesis_ruby 0.1.6 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/Gemfile.lock +42 -38
  4. data/README.md +305 -3
  5. data/VERSION +1 -1
  6. data/lib/genesis_ruby/api/constants/transactions/parameters/mobile/apple_pay/payment_subtypes.rb +29 -0
  7. data/lib/genesis_ruby/api/constants/transactions/parameters/mobile/google_pay/payment_subtypes.rb +29 -0
  8. data/lib/genesis_ruby/api/constants/transactions/parameters/mpi_protocol_sub_versions.rb +43 -0
  9. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/bank_code_currencies.rb +128 -0
  10. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/bank_codes.rb +600 -0
  11. data/lib/genesis_ruby/api/constants/transactions/parameters/online_banking/payment_types.rb +36 -0
  12. data/lib/genesis_ruby/api/constants/transactions/parameters/travel_data/ancillary_charges_types.rb +43 -0
  13. data/lib/genesis_ruby/api/constants/transactions.rb +1 -5
  14. data/lib/genesis_ruby/api/mixins/requests/attribute_validation.rb +138 -4
  15. data/lib/genesis_ruby/api/mixins/requests/birth_date_attributes.rb +22 -0
  16. data/lib/genesis_ruby/api/mixins/requests/customer_address/customer_info_attributes.rb +1 -1
  17. data/lib/genesis_ruby/api/mixins/requests/financial/cards/credit_card_attributes.rb +7 -0
  18. data/lib/genesis_ruby/api/mixins/requests/financial/cards/mpi_attributes.rb +14 -4
  19. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_attributes.rb +23 -20
  20. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_indian_card_attributes.rb +19 -39
  21. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/recurring_type_attributes.rb +15 -9
  22. data/lib/genesis_ruby/api/mixins/requests/financial/cards/tokenization_attributes.rb +9 -0
  23. data/lib/genesis_ruby/api/mixins/requests/financial/mobile/apple_pay_token_attributes.rb +51 -0
  24. data/lib/genesis_ruby/api/mixins/requests/financial/mobile/google_pay_token_attributes.rb +50 -0
  25. data/lib/genesis_ruby/api/mixins/requests/financial/online_banking_payments/virtual_payment_address_attributes.rb +27 -0
  26. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/browser.rb +11 -22
  27. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/card_holder_account.rb +81 -49
  28. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/common_attributes.rb +23 -0
  29. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/control.rb +13 -26
  30. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/merchant_risk.rb +21 -58
  31. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/purchase.rb +8 -11
  32. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/sdk.rb +10 -10
  33. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/wpf_attributes.rb +9 -0
  34. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/airline_itinerary_attributes.rb +166 -0
  35. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/car_rental_attributes.rb +119 -0
  36. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/hotel_rental_attributes.rb +77 -0
  37. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/reference_ticket_attributes.rb +75 -0
  38. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/travel_attributes.rb +34 -0
  39. data/lib/genesis_ruby/api/request.rb +4 -2
  40. data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +6 -4
  41. data/lib/genesis_ruby/api/requests/base/reference.rb +3 -2
  42. data/lib/genesis_ruby/api/requests/financial/capture.rb +3 -1
  43. data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +13 -3
  44. data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +22 -11
  45. data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +13 -3
  46. data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +22 -11
  47. data/lib/genesis_ruby/api/requests/financial/cards/threeds/v2/method_continue.rb +2 -2
  48. data/lib/genesis_ruby/api/requests/financial/mobile/apple_pay.rb +91 -0
  49. data/lib/genesis_ruby/api/requests/financial/mobile/google_pay.rb +108 -0
  50. data/lib/genesis_ruby/api/requests/financial/online_banking_payments/online_banking/pay_in.rb +157 -0
  51. data/lib/genesis_ruby/api/requests/financial/void.rb +2 -2
  52. data/lib/genesis_ruby/api/requests/non_financial/reconcile/date_range.rb +2 -2
  53. data/lib/genesis_ruby/api/requests/wpf/create.rb +11 -15
  54. data/lib/genesis_ruby/api/requests/wpf/reconcile.rb +2 -2
  55. data/lib/genesis_ruby/builders/xml.rb +6 -0
  56. data/lib/genesis_ruby/utils/common.rb +26 -0
  57. data/lib/genesis_ruby/utils/transactions/financial_types.rb +1 -1
  58. data/lib/genesis_ruby/utils/transactions/references/refundable_types.rb +1 -1
  59. data/lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/base.rb +33 -0
  60. data/lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/leg.rb +97 -0
  61. data/lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/tax.rb +42 -0
  62. data/lib/genesis_ruby/utils/transactions/wpf_types.rb +1 -1
  63. data/lib/genesis_ruby/version.rb +1 -1
  64. metadata +24 -2
@@ -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
@@ -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
@@ -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
  {
@@ -1,4 +1,5 @@
1
1
  require 'genesis_ruby/api/constants/transactions/parameters/mpi_protocol_versions'
2
+ require 'genesis_ruby/api/constants/transactions/parameters/mpi_protocol_sub_versions'
2
3
 
3
4
  module GenesisRuby
4
5
  module Api
@@ -9,9 +10,8 @@ module GenesisRuby
9
10
  # Mixin Mpi Attributes
10
11
  module MpiAttributes
11
12
 
12
- attr_reader :mpi_threeds_challenge_indicator, :mpi_protocol_version
13
- attr_accessor :mpi_cavv, :mpi_eci, :mpi_xid, :mpi_directory_server_id,
14
- :mpi_asc_transaction_id
13
+ attr_reader :mpi_threeds_challenge_indicator, :mpi_protocol_version, :mpi_protocol_sub_version
14
+ attr_accessor :mpi_cavv, :mpi_eci, :mpi_xid, :mpi_directory_server_id, :mpi_asc_transaction_id
15
15
 
16
16
  # The used 3DS protocol version. Default is 1 if not supplied.
17
17
  def mpi_protocol_version=(value)
@@ -31,6 +31,15 @@ module GenesisRuby
31
31
  allowed_options attribute: __method__, allowed: allowed_indicators, value: value, allow_empty: true
32
32
  end
33
33
 
34
+ # The used 3DSv2 authentication protocol.
35
+ def mpi_protocol_sub_version=(value)
36
+ allowed_options attribute: __method__,
37
+ allowed: GenesisRuby::Api::Constants::Transactions::Parameters::
38
+ MpiProtocolSubVersions.all,
39
+ value: value.to_i,
40
+ allow_empty: true
41
+ end
42
+
34
43
  protected
35
44
 
36
45
  # Mpi Attributes Structure
@@ -41,7 +50,8 @@ module GenesisRuby
41
50
  protocol_version: mpi_protocol_version,
42
51
  directory_server_id: mpi_directory_server_id,
43
52
  acs_transaction_id: mpi_asc_transaction_id,
44
- threeds_challenge_indicator: mpi_threeds_challenge_indicator
53
+ threeds_challenge_indicator: mpi_threeds_challenge_indicator,
54
+ protocol_sub_version: mpi_protocol_sub_version
45
55
  }
46
56
  end
47
57
 
@@ -1,3 +1,5 @@
1
+ require 'genesis_ruby/api/constants/transactions/parameters/managed_recurring/modes'
2
+ require 'genesis_ruby/api/constants/transactions/parameters/managed_recurring/intervals'
1
3
  require 'genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_indian_card_attributes'
2
4
 
3
5
  module GenesisRuby
@@ -13,26 +15,8 @@ module GenesisRuby
13
15
 
14
16
  include Recurring::ManagedRecurringIndianCardAttributes
15
17
 
16
- attr_reader :managed_recurring_mode, :managed_recurring_interval, :managed_recurring_time_of_day,
17
- :managed_recurring_period, :managed_recurring_max_count
18
- attr_accessor :managed_recurring_amount
19
-
20
- # This indicates that the gateway will automatically manage the subsequent recurring transactions.
21
- def managed_recurring_mode=(value)
22
- allowed_options attribute: __method__,
23
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
24
- Modes.all,
25
- value: value
26
- end
27
-
28
- # The interval type for the period: days or months. The default value is days
29
- def managed_recurring_interval=(value)
30
- allowed_options attribute: __method__,
31
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
32
- Intervals.all,
33
- value: value,
34
- allow_empty: true
35
- 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
36
20
 
37
21
  # Specifies the date of the first recurring event in the future
38
22
  # default value is date of creation + period.
@@ -65,6 +49,25 @@ module GenesisRuby
65
49
 
66
50
  protected
67
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
+
68
71
  # Managed Recurring attributes structure
69
72
  def managed_recurring_attributes_structure
70
73
  amount = managed_recurring_amount
@@ -1,3 +1,7 @@
1
+ require 'genesis_ruby/api/constants/transactions/parameters/managed_recurring/payment_types'
2
+ require 'genesis_ruby/api/constants/transactions/parameters/managed_recurring/amount_types'
3
+ require 'genesis_ruby/api/constants/transactions/parameters/managed_recurring/frequencies'
4
+
1
5
  module GenesisRuby
2
6
  module Api
3
7
  module Mixins
@@ -10,49 +14,25 @@ module GenesisRuby
10
14
  # India (RBI) regulations.
11
15
  module ManagedRecurringIndianCardAttributes
12
16
 
13
- attr_reader :managed_recurring_payment_type, :managed_recurring_amount_type,
14
- :managed_recurring_frequency, :managed_recurring_validated
15
-
16
- attr_accessor :managed_recurring_registration_reference_number, :managed_recurring_max_amount
17
-
18
- # Payment Type of the current recurring transaction
19
- def managed_recurring_payment_type=(value)
20
- allowed_options attribute: __method__,
21
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
22
- PaymentTypes.all,
23
- value: value.to_s,
24
- allow_empty: true
25
- end
26
-
27
- # Amount Type of the current recurring transaction
28
- def managed_recurring_amount_type=(value)
29
- allowed_options attribute: __method__,
30
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
31
- AmountTypes.all,
32
- value: value.to_s,
33
- allow_empty: true
34
- end
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
35
20
 
36
- # Frequencies of the Frequency of the subsequent transactions
37
- def managed_recurring_frequency=(value)
38
- allowed_options attribute: __method__,
39
- allowed: GenesisRuby::Api::Constants::Transactions::Parameters::ManagedRecurring::
40
- Frequencies.all,
41
- value: value.to_s,
42
- allow_empty: true
43
- end
21
+ protected
44
22
 
45
- # Indicates if the current transaction is valid as per the registered agreement. Values: true, false
46
- def managed_recurring_validated=(value)
47
- allowed_options attribute: __method__,
48
- allowed: [true, false],
49
- value: value,
50
- allow_empty: true,
51
- 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
+ }
52
34
  end
53
35
 
54
- protected
55
-
56
36
  # Managed Recurring Indian Card attributes structure
57
37
  def managed_recurring_indian_card_attributes_structure
58
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,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
@@ -11,10 +11,10 @@ module GenesisRuby
11
11
  # Mixin ThreedsV2 Browser Attributes
12
12
  module Browser
13
13
 
14
- attr_reader :threeds_v2_browser_accept_header, :threeds_v2_browser_java_enabled,
15
- :threeds_v2_browser_language, :threeds_v2_browser_color_depth,
14
+ attr_reader :threeds_v2_browser_accept_header, :threeds_v2_browser_language,
16
15
  :threeds_v2_browser_screen_height, :threeds_v2_browser_screen_width,
17
16
  :threeds_v2_browser_time_zone_offset, :threeds_v2_browser_user_agent
17
+ attr_accessor :threeds_v2_browser_color_depth, :threeds_v2_browser_java_enabled
18
18
 
19
19
  # Exact content of the HTTP accept headers as sent to the 3DS Requester from the Cardholder browser
20
20
  def threeds_v2_browser_accept_header=(value)
@@ -26,17 +26,6 @@ module GenesisRuby
26
26
  limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 8
27
27
  end
28
28
 
29
- # Value representing the bit depth of the colour palette for displaying images, in bits per pixel
30
- def threeds_v2_browser_color_depth=(value)
31
- allowed_depths = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
32
- Browser::ColorDepths.all
33
-
34
- allowed_options attribute: __method__,
35
- allowed: allowed_depths,
36
- value: value.to_s.empty? ? nil : value.to_i,
37
- allow_empty: true
38
- end
39
-
40
29
  # Total height of the Cardholder's screen in pixels
41
30
  def threeds_v2_browser_screen_height=(value)
42
31
  parse_int attribute: __method__, value: value, allow_empty: true
@@ -47,15 +36,6 @@ module GenesisRuby
47
36
  parse_int attribute: __method__, value: value, allow_empty: true
48
37
  end
49
38
 
50
- # Boolean that represents the ability of the cardholder browser to execute Java
51
- def threeds_v2_browser_java_enabled=(value)
52
- allowed_options attribute: __method__,
53
- allowed: [true, false],
54
- value: value,
55
- allow_empty: true,
56
- error_message: 'Accepts only boolean values'
57
- end
58
-
59
39
  # Time difference between UTC time and the Cardholder browser local time, in minutes
60
40
  def threeds_v2_browser_time_zone_offset=(value)
61
41
  limited_string attribute: __method__, value: value.to_s.empty? ? nil : value.to_s, max: 5
@@ -68,6 +48,15 @@ module GenesisRuby
68
48
 
69
49
  protected
70
50
 
51
+ # Browser filed validations structure
52
+ def threeds_browser_field_validations
53
+ {
54
+ threeds_v2_browser_color_depth: Api::Constants::Transactions::Parameters::Threeds::Version2::
55
+ Browser::ColorDepths.all,
56
+ threeds_v2_browser_java_enabled: [true, false]
57
+ }
58
+ end
59
+
71
60
  # Request Browser Attributes structure
72
61
  def browser_attributes
73
62
  {