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
@@ -17,15 +17,15 @@ module GenesisRuby
17
17
  # Mixin ThreedsV2 Card holder Account
18
18
  module CardHolderAccount # rubocop:disable Metrics/ModuleLength
19
19
 
20
- attr_reader :threeds_v2_card_holder_account_update_indicator,
21
- :threeds_v2_card_holder_account_password_change_indicator,
22
- :threeds_v2_card_holder_account_shipping_address_usage_indicator,
23
- :threeds_v2_card_holder_account_transactions_activity_last24_hours,
20
+ attr_reader :threeds_v2_card_holder_account_transactions_activity_last24_hours,
24
21
  :threeds_v2_card_holder_account_transactions_activity_previous_year,
25
22
  :threeds_v2_card_holder_account_provision_attempts_last24_hours,
26
- :threeds_v2_card_holder_account_purchases_count_last6_months,
27
- :threeds_v2_card_holder_account_suspicious_activity_indicator,
28
- :threeds_v2_card_holder_account_registration_indicator
23
+ :threeds_v2_card_holder_account_purchases_count_last6_months
24
+ attr_accessor :threeds_v2_card_holder_account_update_indicator,
25
+ :threeds_v2_card_holder_account_password_change_indicator,
26
+ :threeds_v2_card_holder_account_shipping_address_usage_indicator,
27
+ :threeds_v2_card_holder_account_suspicious_activity_indicator,
28
+ :threeds_v2_card_holder_account_registration_indicator
29
29
 
30
30
  # Date that the cardholder opened the account with the 3DS Requester.
31
31
  def threeds_v2_card_holder_account_creation_date
@@ -39,14 +39,6 @@ module GenesisRuby
39
39
  parse_date attribute: __method__, value: value, allow_empty: true
40
40
  end
41
41
 
42
- # Length of time since the cardholder’s account information with the 3DS Requester was last changed
43
- def threeds_v2_card_holder_account_update_indicator=(value)
44
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
45
- CardHolderAccount::UpdateIndicators.all
46
-
47
- allowed_options attribute: __method__, allowed: allowed_indicators, value: value, allow_empty: true
48
- end
49
-
50
42
  # Date that the cardholder’s account with the 3DS Requester was last changed
51
43
  def threeds_v2_card_holder_account_last_change_date
52
44
  @threeds_v2_card_holder_account_last_change_date&.strftime(
@@ -59,15 +51,6 @@ module GenesisRuby
59
51
  parse_date attribute: __method__, value: value, allow_empty: true
60
52
  end
61
53
 
62
- # Length of time since the cardholder account with the 3DS Requester had a password change or
63
- # account reset
64
- def threeds_v2_card_holder_account_password_change_indicator=(value)
65
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
66
- CardHolderAccount::PasswordChangeIndicators.all
67
-
68
- allowed_options attribute: __method__, allowed: allowed_indicators, value: value, allow_empty: true
69
- end
70
-
71
54
  # Date that cardholder’s account with the 3DS Requester had a password change or account reset
72
55
  def threeds_v2_card_holder_account_password_change_date
73
56
  @threeds_v2_card_holder_account_password_change_date&.strftime(
@@ -80,14 +63,6 @@ module GenesisRuby
80
63
  parse_date attribute: __method__, value: value, allow_empty: true
81
64
  end
82
65
 
83
- # Indicates when the shipping address used for this transaction was first used with the 3DS Requester
84
- def threeds_v2_card_holder_account_shipping_address_usage_indicator=(value)
85
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
86
- CardHolderAccount::ShippingAddressUsageIndicators.all
87
-
88
- allowed_options attribute: __method__, allowed: allowed_indicators, value: value, allow_empty: true
89
- end
90
-
91
66
  # Date when the shipping address used for this transaction was first used with the 3DS Requester
92
67
  def threeds_v2_card_holder_account_shipping_address_date_first_used
93
68
  @threeds_v2_card_holder_account_shipping_address_date_first_used&.strftime(
@@ -120,23 +95,6 @@ module GenesisRuby
120
95
  parse_int attribute: __method__, value: value, allow_empty: true
121
96
  end
122
97
 
123
- # Indicates whether the 3DS Requester has experienced suspicious activity (including previous fraud)
124
- def threeds_v2_card_holder_account_suspicious_activity_indicator=(value)
125
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
126
- CardHolderAccount::SuspiciousActivityIndicators.all
127
-
128
- allowed_options attribute: __method__, allowed: allowed_indicators, value: value, allow_empty: true
129
- end
130
-
131
- # Indicates the length of time that the payment account was enrolled in the
132
- # cardholder’s account with the 3DS Requester
133
- def threeds_v2_card_holder_account_registration_indicator=(value)
134
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
135
- CardHolderAccount::RegistrationIndicators.all
136
-
137
- allowed_options attribute: __method__, allowed: allowed_indicators, value: value, allow_empty: true
138
- end
139
-
140
98
  # Date that the cardholder opened the account with the 3DS Requester.
141
99
  def threeds_v2_card_holder_account_registration_date
142
100
  @threeds_v2_card_holder_account_registration_date&.strftime(
@@ -151,6 +109,33 @@ module GenesisRuby
151
109
 
152
110
  protected
153
111
 
112
+ # Card Holder field validations structure
113
+ def threeds_card_holder_field_validations # rubocop:disable Metrics/MethodLength
114
+ {
115
+ threeds_v2_card_holder_account_update_indicator: Api::Constants::Transactions::
116
+ Parameters::Threeds::Version2::CardHolderAccount::UpdateIndicators.all,
117
+ threeds_v2_card_holder_account_password_change_indicator: Api::Constants::Transactions::
118
+ Parameters::Threeds::Version2::CardHolderAccount::PasswordChangeIndicators.all,
119
+ threeds_v2_card_holder_account_shipping_address_usage_indicator: Api::Constants::Transactions::
120
+ Parameters::Threeds::Version2::CardHolderAccount::ShippingAddressUsageIndicators.all,
121
+ threeds_v2_card_holder_account_suspicious_activity_indicator: Api::Constants::Transactions::
122
+ Parameters::Threeds::Version2::CardHolderAccount::SuspiciousActivityIndicators.all,
123
+ threeds_v2_card_holder_account_registration_indicator: Api::Constants::Transactions::
124
+ Parameters::Threeds::Version2::CardHolderAccount::RegistrationIndicators.all
125
+ }
126
+ end
127
+
128
+ def validate_threeds_card_holder_dates
129
+ today = DateTime.now
130
+ message = 'must be a valid date in the past.'
131
+
132
+ validate_creation_date today, message
133
+ validate_last_change_date today, message
134
+ validate_password_change_date today, message
135
+ validate_shipping_address_date_first_used today, message
136
+ validate_registration_date today, message
137
+ end
138
+
154
139
  # Request CardHolder Account Attributes structure
155
140
  # rubocop:disable Layout/LineLength, Metrics/MethodLength
156
141
  def card_holder_account_attributes
@@ -173,6 +158,53 @@ module GenesisRuby
173
158
  end
174
159
  # rubocop:enable Layout/LineLength, Metrics/MethodLength
175
160
 
161
+ private
162
+
163
+ # Creation Date Validation
164
+ def validate_creation_date(less_than, message)
165
+ return unless @threeds_v2_card_holder_account_creation_date.is_a? DateTime
166
+
167
+ return if @threeds_v2_card_holder_account_creation_date < less_than
168
+
169
+ raise ParameterError, "Card Holder Account Creation Date #{message}"
170
+ end
171
+
172
+ # Last Change Date validation
173
+ def validate_last_change_date(less_than, message)
174
+ return unless @threeds_v2_card_holder_account_last_change_date.is_a? DateTime
175
+
176
+ return if @threeds_v2_card_holder_account_last_change_date < less_than
177
+
178
+ raise ParameterError, "Card Holder Account Last Change Date #{message}"
179
+ end
180
+
181
+ # Password Change Date validation
182
+ def validate_password_change_date(less_than, message)
183
+ return unless @threeds_v2_card_holder_account_password_change_date.is_a? DateTime
184
+
185
+ return if @threeds_v2_card_holder_account_password_change_date < less_than
186
+
187
+ raise ParameterError, "Card Holder Account Password Change Date #{message}"
188
+ end
189
+
190
+ # Shipping Address Date First Used validation
191
+ def validate_shipping_address_date_first_used(less_than, message)
192
+ return unless @threeds_v2_card_holder_account_shipping_address_date_first_used.is_a? DateTime
193
+
194
+ return if @threeds_v2_card_holder_account_shipping_address_date_first_used < less_than
195
+
196
+ raise ParameterError, "Card Holder Account Shipping Address Date First Used #{message}"
197
+ end
198
+
199
+ # Registration Date validations
200
+ def validate_registration_date(less_than, message)
201
+ return unless @threeds_v2_card_holder_account_registration_date.is_a? DateTime
202
+
203
+ return if @threeds_v2_card_holder_account_registration_date < less_than
204
+
205
+ raise ParameterError, "Card Holder Account Registration Date #{message}"
206
+ end
207
+
176
208
  end
177
209
  end
178
210
  end
@@ -28,6 +28,29 @@ module GenesisRuby
28
28
 
29
29
  protected
30
30
 
31
+ # Threeds Common Attribute Field Validation
32
+ def threeds_field_validations
33
+ {}.merge threeds_control_field_validations, threeds_purchase_field_validations,
34
+ threeds_merchant_risk_field_validations, threeds_card_holder_field_validations,
35
+ threeds_browser_field_validations, threeds_sdk_field_validations
36
+ end
37
+
38
+ def threeds_field_conditional_validations # rubocop:disable Metrics/MethodLength
39
+ {
40
+ threeds_v2_control_device_type: Hash[
41
+ Api::Constants::Transactions::Parameters::Threeds::Version2::Control::DeviceTypes::BROWSER,
42
+ %i[threeds_v2_browser_accept_header threeds_v2_browser_java_enabled threeds_v2_browser_language
43
+ threeds_v2_browser_color_depth threeds_v2_browser_screen_height
44
+ threeds_v2_browser_screen_width threeds_v2_browser_time_zone_offset
45
+ threeds_v2_browser_user_agent],
46
+ Api::Constants::Transactions::Parameters::Threeds::Version2::Control::DeviceTypes::APPLICATION,
47
+ %i[threeds_v2_sdk_interface threeds_v2_sdk_ui_types threeds_v2_sdk_application_id
48
+ threeds_v2_sdk_encrypted_data threeds_v2_sdk_ephemeral_public_key_pair
49
+ threeds_v2_sdk_max_timeout threeds_v2_sdk_reference_number]
50
+ ]
51
+ }
52
+ end
53
+
31
54
  # Threeds V2 Web Payment Form Attributes
32
55
  def threeds_v2_common_attributes_structure
33
56
  {
@@ -12,36 +12,23 @@ module GenesisRuby
12
12
  # Mixin ThreedsV2 Control
13
13
  module Control
14
14
 
15
- attr_reader :threeds_v2_control_device_type, :threeds_v2_control_challenge_window_size,
16
- :threeds_v2_control_challenge_indicator
15
+ attr_accessor :threeds_v2_control_device_type, :threeds_v2_control_challenge_window_size,
16
+ :threeds_v2_control_challenge_indicator
17
17
 
18
- # Identifies the device channel of the consumer
19
- def threeds_v2_control_device_type=(value)
20
- allowed_types = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::Control::
21
- DeviceTypes.all
22
-
23
- allowed_options attribute: __method__, allowed: allowed_types, value: value, allow_empty: true
24
- end
25
-
26
- # Identifies the size of the challenge window for the consumer
27
- def threeds_v2_control_challenge_window_size=(value)
28
- allowed_sizes = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::Control::
29
- ChallengeWindowSizes.all
30
-
31
- allowed_options attribute: __method__, allowed: allowed_sizes, value: value, allow_empty: true
32
- end
33
-
34
- # The value has weight and might impact the decision whether a challenge will be required for the
35
- # transaction or not
36
- def threeds_v2_control_challenge_indicator=(value)
37
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
38
- Control::ChallengeIndicators.all
18
+ protected
39
19
 
40
- allowed_options attribute: __method__, allowed: allowed_indicators, value: value, allow_empty: true
20
+ # Control field validations structure
21
+ def threeds_control_field_validations
22
+ {
23
+ threeds_v2_control_device_type: Api::Constants::Transactions::Parameters::Threeds::
24
+ Version2::Control::DeviceTypes.all,
25
+ threeds_v2_control_challenge_window_size: Api::Constants::Transactions::Parameters::Threeds::
26
+ Version2::Control::ChallengeWindowSizes.all,
27
+ threeds_v2_control_challenge_indicator: Api::Constants::Transactions::Parameters::Threeds::
28
+ Version2::Control::ChallengeIndicators.all
29
+ }
41
30
  end
42
31
 
43
- protected
44
-
45
32
  # Request Control Attributes structure
46
33
  def control_attributes
47
34
  {
@@ -13,55 +13,12 @@ module GenesisRuby
13
13
  # Mixin ThreedsV2 MerchantRisk
14
14
  module MerchantRisk
15
15
 
16
- attr_reader :threeds_v2_merchant_risk_shipping_indicator, :threeds_v2_merchant_risk_delivery_timeframe,
17
- :threeds_v2_merchant_risk_reorder_items_indicator,
18
- :threeds_v2_merchant_risk_pre_order_purchase_indicator, :threeds_v2_merchant_risk_gift_card,
19
- :threeds_v2_merchant_risk_gift_card_count
20
-
21
- # Indicator code that most accurately describes the shipping method
22
- def threeds_v2_merchant_risk_shipping_indicator=(value)
23
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
24
- MerchantRisk::ShippingIndicators.all
25
-
26
- allowed_options attribute: __method__,
27
- allowed: allowed_indicators,
28
- value: value.to_s,
29
- allow_empty: true
30
- end
31
-
32
- # Indicates the merchandise delivery timeframe
33
- def threeds_v2_merchant_risk_delivery_timeframe=(value)
34
- allowed_timeframes = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
35
- MerchantRisk::DeliveryTimeframes.all
36
-
37
- allowed_options attribute: __method__,
38
- allowed: allowed_timeframes,
39
- value: value.to_s,
40
- allow_empty: true
41
- end
42
-
43
- # Indicates whether the cardholder is reordering previously purchased merchandise
44
- def threeds_v2_merchant_risk_reorder_items_indicator=(value)
45
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
46
- MerchantRisk::ReorderItemIndicators.all
47
-
48
- allowed_options attribute: __method__,
49
- allowed: allowed_indicators,
50
- value: value.to_s,
51
- allow_empty: true
52
- end
53
-
54
- # Indicates whether cardholder is placing an order for merchandise with a future-availability
55
- # or release date
56
- def threeds_v2_merchant_risk_pre_order_purchase_indicator=(value)
57
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
58
- MerchantRisk::PreOrderPurchaseIndicators.all
59
-
60
- allowed_options attribute: __method__,
61
- allowed: allowed_indicators,
62
- value: value.to_s,
63
- allow_empty: true
64
- end
16
+ attr_reader :threeds_v2_merchant_risk_gift_card_count
17
+ attr_accessor :threeds_v2_merchant_risk_shipping_indicator,
18
+ :threeds_v2_merchant_risk_delivery_timeframe,
19
+ :threeds_v2_merchant_risk_reorder_items_indicator,
20
+ :threeds_v2_merchant_risk_pre_order_purchase_indicator,
21
+ :threeds_v2_merchant_risk_gift_card
65
22
 
66
23
  # For a pre-ordered purchase, the expected date that the merchandise will be available
67
24
  def threeds_v2_merchant_risk_pre_order_date
@@ -75,15 +32,6 @@ module GenesisRuby
75
32
  parse_date attribute: __method__, value: value, allow_empty: true
76
33
  end
77
34
 
78
- # Prepaid or gift card purchase
79
- def threeds_v2_merchant_risk_gift_card=(value)
80
- allowed_options attribute: __method__,
81
- allowed: [true, false],
82
- value: value,
83
- allow_empty: true,
84
- error_message: 'Accepts only boolean values'
85
- end
86
-
87
35
  # For prepaid or gift card purchase, total count of individual prepaid or gift cards/codes purchased
88
36
  def threeds_v2_merchant_risk_gift_card_count=(value)
89
37
  parse_int attribute: __method__, value: value, allow_empty: true
@@ -91,6 +39,21 @@ module GenesisRuby
91
39
 
92
40
  protected
93
41
 
42
+ # Merchant Risk field validations structure
43
+ def threeds_merchant_risk_field_validations # rubocop:disable Metrics/MethodLength
44
+ {
45
+ threeds_v2_merchant_risk_shipping_indicator: Api::Constants::Transactions::Parameters::
46
+ Threeds::Version2::MerchantRisk::ShippingIndicators.all,
47
+ threeds_v2_merchant_risk_delivery_timeframe: Api::Constants::Transactions::Parameters::
48
+ Threeds::Version2::MerchantRisk::DeliveryTimeframes.all,
49
+ threeds_v2_merchant_risk_reorder_items_indicator: Api::Constants::Transactions::Parameters::
50
+ Threeds::Version2::MerchantRisk::ReorderItemIndicators.all,
51
+ threeds_v2_merchant_risk_pre_order_purchase_indicator: Api::Constants::Transactions::Parameters::
52
+ Threeds::Version2::MerchantRisk::PreOrderPurchaseIndicators.all,
53
+ threeds_v2_merchant_risk_gift_card: [true, false]
54
+ }
55
+ end
56
+
94
57
  # Request Merchant Risk Attributes structure
95
58
  def merchant_risk_attributes
96
59
  {
@@ -10,21 +10,18 @@ module GenesisRuby
10
10
  # Mixin ThreedsV2 Purchase
11
11
  module Purchase
12
12
 
13
- attr_reader :threeds_v2_purchase_category
13
+ attr_accessor :threeds_v2_purchase_category
14
14
 
15
- # Identifies the type of transaction being authenticated
16
- def threeds_v2_purchase_category=(value)
17
- allowed_indicators = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::
18
- Purchase::Categories.all
15
+ protected
19
16
 
20
- allowed_options attribute: __method__,
21
- allowed: allowed_indicators,
22
- value: value.to_s,
23
- allow_empty: true
17
+ # Purchase field validations structure
18
+ def threeds_purchase_field_validations
19
+ {
20
+ threeds_v2_purchase_category: Api::Constants::Transactions::Parameters::Threeds::Version2::
21
+ Purchase::Categories.all
22
+ }
24
23
  end
25
24
 
26
- protected
27
-
28
25
  # Request Purchase Attributes structure
29
26
  def purchase_attributes
30
27
  {
@@ -12,18 +12,10 @@ module GenesisRuby
12
12
  # Mixin ThreedsV2 SDK
13
13
  module Sdk
14
14
 
15
- attr_reader :threeds_v2_sdk_interface, :threeds_v2_sdk_application_id, :threeds_v2_sdk_encrypted_data,
15
+ attr_reader :threeds_v2_sdk_application_id, :threeds_v2_sdk_encrypted_data,
16
16
  :threeds_v2_sdk_ephemeral_public_key_pair, :threeds_v2_sdk_max_timeout,
17
17
  :threeds_v2_sdk_reference_number
18
-
19
- # SDK Interface types that the device of the consumer supports for displaying specific challenge
20
- # interfaces within the SDK
21
- def threeds_v2_sdk_interface=(value)
22
- allowed_interfaces = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::Sdk::
23
- Interfaces.all
24
-
25
- allowed_options attribute: __method__, allowed: allowed_interfaces, value: value, allow_empty: true
26
- end
18
+ attr_accessor :threeds_v2_sdk_interface
27
19
 
28
20
  # UI type that the device of the consumer supports for displaying specific challenge interface
29
21
  def threeds_v2_sdk_ui_types
@@ -84,6 +76,14 @@ module GenesisRuby
84
76
 
85
77
  protected
86
78
 
79
+ # SDK field validations
80
+ def threeds_sdk_field_validations
81
+ {
82
+ threeds_v2_sdk_interface: Api::Constants::Transactions::Parameters::Threeds::Version2::Sdk::
83
+ Interfaces.all
84
+ }
85
+ end
86
+
87
87
  # Request SDK Attributes structure
88
88
  def sdk_attributes
89
89
  {
@@ -32,6 +32,15 @@ module GenesisRuby
32
32
 
33
33
  protected
34
34
 
35
+ # Threeds Common Attribute Field Validation
36
+ def threeds_field_validations
37
+ control_validations = threeds_control_field_validations
38
+ control_validations.delete(:threeds_v2_control_device_type)
39
+
40
+ {}.merge control_validations, threeds_purchase_field_validations,
41
+ threeds_merchant_risk_field_validations, threeds_card_holder_field_validations
42
+ end
43
+
35
44
  # Request Control Attributes structure available for the Web Payment Form
36
45
  def control_attributes
37
46
  {
@@ -0,0 +1,166 @@
1
+ require 'genesis_ruby/utils/transactions/travel_data/airline_itinerary/leg'
2
+ require 'genesis_ruby/utils/transactions/travel_data/airline_itinerary/tax'
3
+
4
+ module GenesisRuby
5
+ module Api
6
+ module Mixins
7
+ module Requests
8
+ module Financial
9
+ module TravelData
10
+ # Level 3 Data Airline Itinerary Attributes
11
+ module AirlineItineraryAttributes
12
+
13
+ attr_reader :travel_aid_restricted_ticket_indicator, :travel_aid_ticket_number,
14
+ :travel_aid_passenger_name, :travel_aid_customer_code, :travel_aid_issuing_carrier,
15
+ :travel_aid_agency_name, :travel_aid_agency_code
16
+ attr_accessor :travel_aid_total_fare, :travel_aid_confirmation_information
17
+
18
+ # Date Of Issue
19
+ def travel_aid_date_of_issue
20
+ @travel_aid_date_of_issue&.strftime GenesisRuby::Api::Constants::DateTimeFormats::DD_MM_YYYY_L_HYPHENS
21
+ end
22
+
23
+ # Date Of Issue
24
+ def travel_aid_date_of_issue=(value)
25
+ parse_date attribute: __method__, value: value, allow_empty: true
26
+ end
27
+
28
+ # Restricted Ticket Indicator
29
+ def travel_aid_restricted_ticket_indicator=(value)
30
+ allowed_options attribute: __method__, value: value.to_i, allow_empty: true, allowed: [0, 1]
31
+ end
32
+
33
+ # Ticket Number
34
+ def travel_aid_ticket_number=(value)
35
+ limited_string attribute: __method__, value: value, max: 15
36
+ end
37
+
38
+ # Passenger name
39
+ def travel_aid_passenger_name=(value)
40
+ limited_string attribute: __method__, value: value, max: 29
41
+ end
42
+
43
+ # Customer code
44
+ def travel_aid_customer_code=(value)
45
+ limited_string attribute: __method__, value: value, max: 17
46
+ end
47
+
48
+ # Issuing carrier
49
+ def travel_aid_issuing_carrier=(value)
50
+ limited_string attribute: __method__, value: value, max: 4
51
+ end
52
+
53
+ # Agency name
54
+ def travel_aid_agency_name=(value)
55
+ limited_string attribute: __method__, value: value, max: 30
56
+ end
57
+
58
+ # Agency code
59
+ def travel_aid_agency_code=(value)
60
+ limited_string attribute: __method__, value: value, max: 8
61
+ end
62
+
63
+ # AirlineItinerary Legs data. Max legs 10
64
+ def travel_aid_legs
65
+ @travel_aid_legs || []
66
+ end
67
+
68
+ # AirlineItinerary Taxes data. Max taxes 10
69
+ def travel_aid_taxes
70
+ @travel_aid_taxes || []
71
+ end
72
+
73
+ # Add a single AirlineItinerary Leg data
74
+ def add_travel_aid_leg(leg)
75
+ @travel_aid_legs ||= travel_aid_legs
76
+ leg_obj = GenesisRuby::Utils::Transactions::TravelData::AirlineItinerary::Leg
77
+
78
+ raise InvalidArgumentError, "Leg must be instance of #{leg_obj.name}" unless leg.instance_of? leg_obj
79
+
80
+ if travel_aid_legs.count == ALLOWED_ITEMS_COUNT
81
+ raise InvalidArgumentError, "Allowed Legs count exceeded. Allowed #{ALLOWED_ITEMS_COUNT}."
82
+ end
83
+
84
+ @travel_aid_legs.push leg
85
+ end
86
+
87
+ # Add a single AirlineItinerary Tax data
88
+ def add_travel_aid_tax(tax)
89
+ @travel_aid_taxes ||= travel_aid_taxes
90
+ tax_obj = GenesisRuby::Utils::Transactions::TravelData::AirlineItinerary::Tax
91
+
92
+ raise InvalidArgumentError, "Tax must be instance of #{tax_obj.name}" unless tax.instance_of? tax_obj
93
+
94
+ if travel_aid_taxes.count == ALLOWED_ITEMS_COUNT
95
+ raise InvalidArgumentError, "Allowed Legs count exceeded. Allowed #{ALLOWED_ITEMS_COUNT}."
96
+ end
97
+
98
+ @travel_aid_taxes.push tax
99
+ end
100
+
101
+ # Reset Legs data
102
+ def clear_travel_aid_legs
103
+ @travel_aid_legs = []
104
+ end
105
+
106
+ # Reset Taxes
107
+ def clear_travel_aid_taxes
108
+ @travel_aid_taxes = []
109
+ end
110
+
111
+ protected
112
+
113
+ ALLOWED_ITEMS_COUNT = 10
114
+
115
+ # Legs structure
116
+ def legs_structure
117
+ parse_items 'leg', travel_aid_legs
118
+ end
119
+
120
+ # Taxes structure
121
+ def taxes_structure
122
+ parse_items 'tax', travel_aid_taxes
123
+ end
124
+
125
+ # Prepare structure
126
+ def parse_items(node_name, items)
127
+ data = []
128
+
129
+ items.each do |item|
130
+ item.currency = currency if item.respond_to?(:currency) && respond_to?(:currency)
131
+ data.push item.attributes_structure
132
+ end
133
+
134
+ Hash[node_name.to_sym, data]
135
+ end
136
+
137
+ # Attributes Structure
138
+ def airline_attributes_structure # rubocop:disable RSpec/MethodLength
139
+ {
140
+ ticket_number: travel_aid_ticket_number,
141
+ passenger_name: travel_aid_passenger_name,
142
+ customer_code: travel_aid_customer_code,
143
+ restricted_ticket_indicator: travel_aid_restricted_ticket_indicator,
144
+ issuing_carrier: travel_aid_issuing_carrier,
145
+ total_fare: parse_total_fare,
146
+ agency_name: travel_aid_agency_name,
147
+ agency_code: travel_aid_agency_code,
148
+ confirmation_information: travel_aid_confirmation_information,
149
+ date_of_issue: travel_aid_date_of_issue
150
+ }
151
+ end
152
+
153
+ # Parse Total Fare amount
154
+ def parse_total_fare
155
+ return travel_aid_total_fare if currency.nil? || travel_aid_total_fare.nil?
156
+
157
+ transform_amount travel_aid_total_fare, currency
158
+ end
159
+
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end