genesis_ruby 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/Gemfile.lock +9 -11
  4. data/README.md +93 -3
  5. data/VERSION +1 -1
  6. data/lib/genesis_ruby/api/constants/i18n.rb +90 -0
  7. data/lib/genesis_ruby/api/constants/transactions/parameters/mpi_protocol_sub_versions.rb +43 -0
  8. data/lib/genesis_ruby/api/constants/transactions/parameters/travel_data/ancillary_charges_types.rb +43 -0
  9. data/lib/genesis_ruby/api/constants/transactions/parameters/wpf/reminder_channels.rb +24 -0
  10. data/lib/genesis_ruby/api/constants/transactions.rb +1 -5
  11. data/lib/genesis_ruby/api/mixins/requests/financial/cards/mpi_attributes.rb +14 -4
  12. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_attributes.rb +2 -0
  13. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_indian_card_attributes.rb +4 -0
  14. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/airline_itinerary_attributes.rb +166 -0
  15. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/car_rental_attributes.rb +119 -0
  16. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/hotel_rental_attributes.rb +77 -0
  17. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/reference_ticket_attributes.rb +75 -0
  18. data/lib/genesis_ruby/api/mixins/requests/financial/travel_data/travel_attributes.rb +34 -0
  19. data/lib/genesis_ruby/api/mixins/requests/wpf_reminders_attributes.rb +59 -0
  20. data/lib/genesis_ruby/api/requests/financial/capture.rb +3 -1
  21. data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +3 -1
  22. data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +3 -1
  23. data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +3 -1
  24. data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +3 -1
  25. data/lib/genesis_ruby/api/requests/wpf/create.rb +70 -3
  26. data/lib/genesis_ruby/builders/xml.rb +6 -0
  27. data/lib/genesis_ruby/utils/options/reminder.rb +60 -0
  28. data/lib/genesis_ruby/utils/transactions/financial_types.rb +1 -1
  29. data/lib/genesis_ruby/utils/transactions/references/refundable_types.rb +1 -1
  30. data/lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/base.rb +33 -0
  31. data/lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/leg.rb +97 -0
  32. data/lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/tax.rb +42 -0
  33. data/lib/genesis_ruby/utils/transactions/wpf_types.rb +1 -1
  34. data/lib/genesis_ruby/version.rb +1 -1
  35. metadata +17 -3
@@ -1,5 +1,7 @@
1
1
  require 'genesis_ruby/utils/transactions/wpf_types'
2
2
  require 'genesis_ruby/api/constants/transactions/parameters/sca_exemptions'
3
+ require 'genesis_ruby/api/constants/i18n'
4
+ require 'genesis_ruby/api/mixins/requests/wpf_reminders_attributes'
3
5
 
4
6
  module GenesisRuby
5
7
  module Api
@@ -19,10 +21,17 @@ module GenesisRuby
19
21
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
20
22
  include Mixins::Requests::Financial::RiskAttributes
21
23
  include Mixins::Requests::Financial::Business::BusinessAttributes
24
+ include Mixins::Requests::WpfRemindersAttributes
22
25
 
23
26
  attr_reader :locale, :sca_preference, :sca_exemption
24
27
  attr_accessor :transaction_id, :usage, :description, :consumer_id, :return_cancel_url, :remember_card,
25
- :lifetime, :web_payment_form_id
28
+ :web_payment_form_id
29
+
30
+ MAX_LIFETIME = 131_487
31
+ DEFAULT_LIFETIME = 30
32
+
33
+ private_constant :MAX_LIFETIME
34
+ private_constant :DEFAULT_LIFETIME
26
35
 
27
36
  # The transaction types that the merchant is willing to accept payments for
28
37
  def add_transaction_type(name, custom_attributes = {})
@@ -37,7 +46,12 @@ module GenesisRuby
37
46
 
38
47
  # Define ISO 639-1 language code to the URL
39
48
  def locale=(value)
40
- init_api_wpf_configuration(language: value.to_s.downcase)
49
+ allowed_options attribute: __method__,
50
+ allowed: Constants::I18n.all,
51
+ value: value.to_s.downcase,
52
+ allow_empty: true
53
+
54
+ init_api_wpf_configuration(language: locale)
41
55
  end
42
56
 
43
57
  # Signifies whether to perform SCA on the transaction. At least one 3DS transaction type has to be submitted.
@@ -59,6 +73,41 @@ module GenesisRuby
59
73
  allow_empty: true
60
74
  end
61
75
 
76
+ # Signifies whether the ’Pay Later’ feature would be enabled on the WPF
77
+ def pay_later
78
+ @pay_later ||= false
79
+
80
+ return nil unless @pay_later
81
+
82
+ @pay_later
83
+ end
84
+
85
+ # Signifies whether the ’Pay Later’ feature would be enabled on the WPF
86
+ def pay_later=(value)
87
+ allowed_options attribute: __method__,
88
+ allowed: [true, false],
89
+ value: value,
90
+ allow_empty: true,
91
+ error_message: 'Accepts only boolean values'
92
+ end
93
+
94
+ # A number of minutes determining how long the WPF will be valid. Will be set to 30 minutes by default.
95
+ def lifetime
96
+ @lifetime ||= DEFAULT_LIFETIME
97
+ end
98
+
99
+ # A number of minutes determining how long the WPF will be valid. Will be set to 30 minutes by default.
100
+ def lifetime=(value)
101
+ lifetime = value.to_i
102
+
103
+ if lifetime < 1 || lifetime > MAX_LIFETIME
104
+ raise InvalidArgumentError,
105
+ "Valid value ranges between 1 minute and 3 months (#{MAX_LIFETIME} minutes) given in minutes"
106
+ end
107
+
108
+ @lifetime = lifetime
109
+ end
110
+
62
111
  protected
63
112
 
64
113
  # Load base configuration
@@ -86,6 +135,8 @@ module GenesisRuby
86
135
  raise ParameterError, "Invalid Currency given with value #{currency}"
87
136
  end
88
137
 
138
+ validate_reminders
139
+
89
140
  super
90
141
  end
91
142
 
@@ -121,7 +172,9 @@ module GenesisRuby
121
172
  recurring_category: recurring_category,
122
173
  dynamic_descriptor_params: dynamic_descriptor_structure,
123
174
  risk_params: risk_parameters_structure,
124
- account_owner: account_owner_attributes_structure
175
+ account_owner: account_owner_attributes_structure,
176
+ pay_later: pay_later,
177
+ reminders: pay_later ? reminders_structure : []
125
178
  }
126
179
  }
127
180
  end
@@ -137,6 +190,20 @@ module GenesisRuby
137
190
  @transaction_types.push(value)
138
191
  end
139
192
 
193
+ # Validate Reminders against the lifetime
194
+ def validate_reminders
195
+ return if lifetime.nil?
196
+
197
+ reminders.each do |reminder|
198
+ next unless reminder.after >= lifetime
199
+
200
+ raise(
201
+ ParameterError,
202
+ "Reminder (#{reminder.after} min) could not be greater than or equal to lifetime (#{lifetime} min)."
203
+ )
204
+ end
205
+ end
206
+
140
207
  end
141
208
  end
142
209
  end
@@ -86,6 +86,12 @@ module GenesisRuby
86
86
  # Build XMl Document part from Array
87
87
  def build_array(element_name, element_value)
88
88
  element_value.each do |tag_value|
89
+ if tag_value.is_a? Hash
90
+ add_node element_name, tag_value
91
+
92
+ next
93
+ end
94
+
89
95
  add_element element_name, tag_value
90
96
  end
91
97
  end
@@ -0,0 +1,60 @@
1
+ require 'genesis_ruby/utils/options/base'
2
+ require 'genesis_ruby/api/constants/transactions/parameters/wpf/reminder_channels'
3
+
4
+ module GenesisRuby
5
+ module Utils
6
+ module Options
7
+ # Single reminder data object
8
+ class Reminder < Base
9
+
10
+ # Min After minutes
11
+ MIN_AFTER = 1
12
+ # Max After minutes
13
+ MAX_AFTER = 31 * 24 * 60
14
+
15
+ def []=(key, value)
16
+ unless available_keys.include? key.to_s
17
+ raise InvalidArgumentError, "Invalid Reminder Key given! Allowed: #{available_keys.join(", ")}"
18
+ end
19
+
20
+ __send__ "validate_#{key}", value
21
+
22
+ super(key.to_sym, value)
23
+ end
24
+
25
+ # Single Reinder structure
26
+ def object_structure
27
+ { reminder: self }
28
+ end
29
+
30
+ private
31
+
32
+ # Available Reminder Data keys
33
+ def available_keys
34
+ %w(channel after)
35
+ end
36
+
37
+ # Validate Channel value
38
+ def validate_channel(value)
39
+ return if Api::Constants::Transactions::Parameters::Wpf::ReminderChannels.all.include? value
40
+
41
+ raise InvalidArgumentError,
42
+ "Invalid Reminder Channel given. Allowed values: #{
43
+ Api::Constants::Transactions::Parameters::Wpf::ReminderChannels.all.join(", ")
44
+ }"
45
+ end
46
+
47
+ # Number of minutes after WPF creation when the reminder should be sent.
48
+ # Valid value ranges between 1 minute and 31 days given in minutes
49
+ def validate_after(value)
50
+ value_int = value.to_i
51
+
52
+ return if value_int >= MIN_AFTER && value_int <= MAX_AFTER
53
+
54
+ raise InvalidArgumentError, 'Invalid After value given. Allowed integer between 1 and 31'
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
@@ -19,7 +19,7 @@ module GenesisRuby
19
19
  EFECTY, ELO, EPS,
20
20
  EZEECARD_PAYOUT, EZEEWALLET,
21
21
  FASHIONCHEQUE,
22
- GIROPAY, GOOGLE_PAY,
22
+ GOOGLE_PAY,
23
23
  IDEAL, IDEBIT_PAYIN, IDEBIT_PAYOUT, INCREMENTAL_AUTHORIZE, INSTA_DEBIT_PAYIN, INSTA_DEBIT_PAYOUT,
24
24
  INTERSOLVE, ITAU,
25
25
  MULTIBANCO, MY_BANK,
@@ -17,7 +17,7 @@ module GenesisRuby
17
17
  CAPTURE, CASHU,
18
18
  DAVIVIENDA,
19
19
  EFECTY, EPS, FASHIONCHEQUE,
20
- GIROPAY, GOOGLE_PAY,
20
+ GOOGLE_PAY,
21
21
  IDEAL, IDEBIT_PAYIN, INIT_RECURRING_SALE, INIT_RECURRING_SALE_3D, INVOICE_CAPTURE, ITAU,
22
22
  MY_BANK,
23
23
  NEOSURF,
@@ -0,0 +1,33 @@
1
+ module GenesisRuby
2
+ module Utils
3
+ module Transactions
4
+ module TravelData
5
+ module AirlineItinerary
6
+ # Airline Itinerary Data base class
7
+ class Base
8
+
9
+ include Api::Mixins::Requests::RestrictedSetter
10
+
11
+ # Constructor
12
+ def initialize(params = {}) # rubocop:disable Style/OptionHash
13
+ parse_attributes params if params.is_a? Hash
14
+
15
+ super()
16
+ end
17
+
18
+ # Item attribute structure
19
+ def attributes_structure; end
20
+
21
+ protected
22
+
23
+ # Initialize attributes
24
+ def parse_attributes(params)
25
+ params.each { |key, value| __send__ "#{key}=", value }
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,97 @@
1
+ require 'genesis_ruby/utils/transactions/travel_data/airline_itinerary/base'
2
+
3
+ module GenesisRuby
4
+ module Utils
5
+ module Transactions
6
+ module TravelData
7
+ module AirlineItinerary
8
+ # Signify a single AirlineItinerary Leg data
9
+ class Leg < Base
10
+
11
+ attr_reader :carrier_code, :service_class, :origin_city, :destination_city, :fare_basis_code,
12
+ :flight_number, :departure_time_segment, :stopover_code
13
+ attr_accessor :departure_time
14
+
15
+ # Departure date
16
+ def departure_date
17
+ @departure_date&.strftime GenesisRuby::Api::Constants::DateTimeFormats::DD_MM_YYYY_L_HYPHENS
18
+ end
19
+
20
+ # Departure date
21
+ def departure_date=(value)
22
+ parse_date attribute: __method__, value: value, allow_empty: true
23
+ end
24
+
25
+ # Arrival date
26
+ def arrival_date
27
+ @arrival_date&.strftime GenesisRuby::Api::Constants::DateTimeFormats::DD_MM_YYYY_L_HYPHENS
28
+ end
29
+
30
+ # Arrival date
31
+ def arrival_date=(value)
32
+ parse_date attribute: __method__, value: value, allow_empty: true
33
+ end
34
+
35
+ # Carrier Code
36
+ def carrier_code=(value)
37
+ limited_string attribute: __method__, value: value.to_s, max: 2
38
+ end
39
+
40
+ # Service Class
41
+ def service_class=(value)
42
+ limited_string attribute: __method__, value: value.to_s, max: 1
43
+ end
44
+
45
+ # Origin City
46
+ def origin_city=(value)
47
+ limited_string attribute: __method__, value: value.to_s, max: 3
48
+ end
49
+
50
+ # Destination City
51
+ def destination_city=(value)
52
+ limited_string attribute: __method__, value: value.to_s, max: 3
53
+ end
54
+
55
+ # Fare basis code
56
+ def fare_basis_code=(value)
57
+ limited_string attribute: __method__, value: value.to_s, max: 6
58
+ end
59
+
60
+ # Flight number
61
+ def flight_number=(value)
62
+ limited_string attribute: __method__, value: value.to_s, max: 5
63
+ end
64
+
65
+ # Departure time segment
66
+ def departure_time_segment=(value)
67
+ allowed_options attribute: __method__, value: value.to_s, allowed: %w(A P), allow_empty: true
68
+ end
69
+
70
+ # Stopover code
71
+ def stopover_code=(value)
72
+ allowed_options attribute: __method__, value: value, allowed: [0, 1], allow_empty: true
73
+ end
74
+
75
+ # Get Single Leg structure
76
+ def attributes_structure # rubocop:disable Metrics/MethodLength
77
+ {
78
+ departure_date: departure_date,
79
+ arrival_date: arrival_date,
80
+ carrier_code: carrier_code,
81
+ service_class: service_class,
82
+ origin_city: origin_city,
83
+ destination_city: destination_city,
84
+ stopover_code: stopover_code,
85
+ fare_basis_code: fare_basis_code,
86
+ flight_number: flight_number,
87
+ departure_time: departure_time,
88
+ departure_time_segment: departure_time_segment
89
+ }
90
+ end
91
+
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,42 @@
1
+ require 'genesis_ruby/utils/transactions/travel_data/airline_itinerary/base'
2
+ require 'genesis_ruby/utils/money_format'
3
+
4
+ module GenesisRuby
5
+ module Utils
6
+ module Transactions
7
+ module TravelData
8
+ module AirlineItinerary
9
+ # Signify a single AirlineItinerary Tax data
10
+ class Tax < Base
11
+
12
+ attr_reader :fee_type
13
+ attr_accessor :fee_amount, :currency
14
+
15
+ # Fee type
16
+ def fee_type=(value)
17
+ limited_string attribute: __method__, value: value, max: 8
18
+ end
19
+
20
+ # Get Single Tax structure
21
+ def attributes_structure
22
+ {
23
+ fee_amount: parse_fee_amount,
24
+ fee_type: fee_type
25
+ }
26
+ end
27
+
28
+ protected
29
+
30
+ # Minor currency conversion if currency is set
31
+ def parse_fee_amount
32
+ return fee_amount if currency.nil? || fee_amount.nil?
33
+
34
+ MoneyFormat.amount_to_exponent fee_amount, currency
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -16,7 +16,7 @@ module GenesisRuby
16
16
  BRADESCO,
17
17
  CABAL, CASHU, CENCOSUD, DAVIVIENDA,
18
18
  EFECTY, ELO, EPS, EZEEWALLET, FASHIONCHEQUE,
19
- GIROPAY, GOOGLE_PAY,
19
+ GOOGLE_PAY,
20
20
  IDEAL, IDEBIT_PAYIN, INSTA_DEBIT_PAYIN, INTERSOLVE, ITAU,
21
21
  MULTIBANCO, MY_BANK,
22
22
  NARANJA, NATIVA, NEOSURF, NETELLER,
@@ -1,5 +1,5 @@
1
1
  module GenesisRuby
2
2
 
3
- VERSION = '0.1.5'.freeze
3
+ VERSION = '0.1.7'.freeze
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genesis_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - emerchantpay Ltd.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-01 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http
@@ -240,6 +240,7 @@ files:
240
240
  - lib/genesis_ruby/api/constants/date_time_formats.rb
241
241
  - lib/genesis_ruby/api/constants/endpoints.rb
242
242
  - lib/genesis_ruby/api/constants/environments.rb
243
+ - lib/genesis_ruby/api/constants/i18n.rb
243
244
  - lib/genesis_ruby/api/constants/states.rb
244
245
  - lib/genesis_ruby/api/constants/states/state.rb
245
246
  - lib/genesis_ruby/api/constants/transactions.rb
@@ -249,6 +250,7 @@ files:
249
250
  - lib/genesis_ruby/api/constants/transactions/parameters/managed_recurring/intervals.rb
250
251
  - lib/genesis_ruby/api/constants/transactions/parameters/managed_recurring/modes.rb
251
252
  - lib/genesis_ruby/api/constants/transactions/parameters/managed_recurring/payment_types.rb
253
+ - lib/genesis_ruby/api/constants/transactions/parameters/mpi_protocol_sub_versions.rb
252
254
  - lib/genesis_ruby/api/constants/transactions/parameters/mpi_protocol_versions.rb
253
255
  - lib/genesis_ruby/api/constants/transactions/parameters/recurring/categories.rb
254
256
  - lib/genesis_ruby/api/constants/transactions/parameters/recurring/types.rb
@@ -270,6 +272,8 @@ files:
270
272
  - lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/purchase/categories.rb
271
273
  - lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/interfaces.rb
272
274
  - lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/ui_types.rb
275
+ - lib/genesis_ruby/api/constants/transactions/parameters/travel_data/ancillary_charges_types.rb
276
+ - lib/genesis_ruby/api/constants/transactions/parameters/wpf/reminder_channels.rb
273
277
  - lib/genesis_ruby/api/mixins/constants/common.rb
274
278
  - lib/genesis_ruby/api/mixins/requests/address_info_attributes.rb
275
279
  - lib/genesis_ruby/api/mixins/requests/attribute_validation.rb
@@ -316,7 +320,13 @@ files:
316
320
  - lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/recurring.rb
317
321
  - lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/sdk.rb
318
322
  - lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/wpf_attributes.rb
323
+ - lib/genesis_ruby/api/mixins/requests/financial/travel_data/airline_itinerary_attributes.rb
324
+ - lib/genesis_ruby/api/mixins/requests/financial/travel_data/car_rental_attributes.rb
325
+ - lib/genesis_ruby/api/mixins/requests/financial/travel_data/hotel_rental_attributes.rb
326
+ - lib/genesis_ruby/api/mixins/requests/financial/travel_data/reference_ticket_attributes.rb
327
+ - lib/genesis_ruby/api/mixins/requests/financial/travel_data/travel_attributes.rb
319
328
  - lib/genesis_ruby/api/mixins/requests/restricted_setter.rb
329
+ - lib/genesis_ruby/api/mixins/requests/wpf_reminders_attributes.rb
320
330
  - lib/genesis_ruby/api/notification.rb
321
331
  - lib/genesis_ruby/api/request.rb
322
332
  - lib/genesis_ruby/api/requests/base/financial.rb
@@ -374,11 +384,15 @@ files:
374
384
  - lib/genesis_ruby/utils/options/api_config.rb
375
385
  - lib/genesis_ruby/utils/options/base.rb
376
386
  - lib/genesis_ruby/utils/options/network_adapter_config.rb
387
+ - lib/genesis_ruby/utils/options/reminder.rb
377
388
  - lib/genesis_ruby/utils/threeds/v2.rb
378
389
  - lib/genesis_ruby/utils/transactions/financial_types.rb
379
390
  - lib/genesis_ruby/utils/transactions/references/capturable_types.rb
380
391
  - lib/genesis_ruby/utils/transactions/references/refundable_types.rb
381
392
  - lib/genesis_ruby/utils/transactions/references/voidable_types.rb
393
+ - lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/base.rb
394
+ - lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/leg.rb
395
+ - lib/genesis_ruby/utils/transactions/travel_data/airline_itinerary/tax.rb
382
396
  - lib/genesis_ruby/utils/transactions/wpf_types.rb
383
397
  - lib/genesis_ruby/version.rb
384
398
  homepage: https://github.com/GenesisGateway/genesis_ruby
@@ -404,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
404
418
  - !ruby/object:Gem::Version
405
419
  version: '0'
406
420
  requirements: []
407
- rubygems_version: 3.1.2
421
+ rubygems_version: 3.4.10
408
422
  signing_key:
409
423
  specification_version: 4
410
424
  summary: Ruby Client for Genesis Payment Processing Gateway