genesis_ruby 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c16e207efd1721cd293a6749709104f57410f684e5bbb3d0b3378001cdfe5d19
4
- data.tar.gz: 495b1333514eecfc206cac7ae713b9593fdd886233ef840be3af610f499f80c8
3
+ metadata.gz: 3bae58236ea63ffb79254010e7dd8651252a8f128eb3c9e245eaf6cc4588c426
4
+ data.tar.gz: e9bc31285e5acceefe5df452d274445f6b88e3039115d313ea1361b9990cc149
5
5
  SHA512:
6
- metadata.gz: 58dba79785a36d57714cf28f6b56878cbf2c8a748584bf7c5e0a4440775c77b39db44eb0a3cf645b399aef81ca3e84967ea05be8e513014b7498ae61a078eec4
7
- data.tar.gz: 8fea90819598e5f3830de518c4a044fbbf2f7c83dc96f56fe1b1b9c2479a157f095fe5ec1cc8b9fddc4de51a80bbaad0167fe9c84df77f5b0e79652fcf6bc5f6
6
+ metadata.gz: 235e870d4dc316eface0f780352fe0129293740742ab45b6638d839cf51cbd9296e193be9a9cf533da6f1c089e39885e47fbf4220523a715a1db8c3c821a3b6c
7
+ data.tar.gz: 346de3c0848acea9c8394323b8377fc1fb86eab52fa125f30586dcb71bf0f2422d7f128fe3152547284274ca5eddde44a1a1d96206d9391bcf65525669f46529
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ 0.1.6
2
+ -----
3
+ **Features**:
4
+
5
+ * Added Web Payment Form `lifetime` validations with a maximum allowed value of 3 months in minutes (131487)
6
+ * Added Web Payment Form `lifetime` default value of 30 minutes
7
+ * Added Web Payment Form Reminders support
8
+ * Added Pay Later parameter support to the Web Payment Form
9
+ * Reminders will be sent to the Gateway only when `pay_later=true`
10
+ * Added Reminder Language parameter support to the Web Payment Form. It accepts only available WPF locales.
11
+ * Added validation for Web Payment Form `locale` attribute. It accepts only available WPF locales.
12
+
1
13
  0.1.5
2
14
  -----
3
15
  **Features**:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- genesis_ruby (0.1.5)
4
+ genesis_ruby (0.1.6)
5
5
  net-http (~> 0.3.2)
6
6
  nokogiri (~> 1.14)
7
7
 
@@ -12,7 +12,7 @@ GEM
12
12
  public_suffix (>= 2.0.2, < 6.0)
13
13
  ast (2.4.2)
14
14
  base64 (0.2.0)
15
- bigdecimal (3.1.6)
15
+ bigdecimal (3.1.7)
16
16
  concurrent-ruby (1.2.3)
17
17
  crack (1.0.0)
18
18
  bigdecimal
@@ -34,7 +34,7 @@ GEM
34
34
  httparty (0.21.0)
35
35
  mini_mime (>= 1.0.0)
36
36
  multi_xml (>= 0.5.2)
37
- i18n (1.14.1)
37
+ i18n (1.14.4)
38
38
  concurrent-ruby (~> 1.0)
39
39
  json (2.7.1)
40
40
  language_server-protocol (3.17.0.3)
@@ -45,7 +45,7 @@ GEM
45
45
  ruby2_keywords (~> 0.0.1)
46
46
  net-http (0.3.2)
47
47
  uri
48
- nokogiri (1.15.5)
48
+ nokogiri (1.15.6)
49
49
  mini_portile2 (~> 2.8.2)
50
50
  racc (~> 1.4)
51
51
  octokit (7.2.0)
@@ -68,7 +68,7 @@ GEM
68
68
  rubocop (>= 0.63.1, < 2.0)
69
69
  public_suffix (5.0.4)
70
70
  racc (1.7.3)
71
- rack (2.2.8.1)
71
+ rack (2.2.9)
72
72
  rack-protection (3.2.0)
73
73
  base64 (>= 0.1.0)
74
74
  rack (~> 2.2, >= 2.2.4)
@@ -91,7 +91,7 @@ GEM
91
91
  rspec-support (3.13.1)
92
92
  rspec_junit_formatter (0.6.0)
93
93
  rspec-core (>= 2, < 4, != 2.12.0)
94
- rubocop (1.61.0)
94
+ rubocop (1.62.1)
95
95
  json (~> 2.3)
96
96
  language_server-protocol (>= 3.17.0)
97
97
  parallel (~> 1.10)
@@ -99,10 +99,10 @@ GEM
99
99
  rainbow (>= 2.2.2, < 4.0)
100
100
  regexp_parser (>= 1.8, < 3.0)
101
101
  rexml (>= 3.2.5, < 4.0)
102
- rubocop-ast (>= 1.30.0, < 2.0)
102
+ rubocop-ast (>= 1.31.1, < 2.0)
103
103
  ruby-progressbar (~> 1.7)
104
104
  unicode-display_width (>= 2.4.0, < 3.0)
105
- rubocop-ast (1.31.1)
105
+ rubocop-ast (1.31.2)
106
106
  parser (>= 3.3.0.4)
107
107
  rubocop-capybara (2.20.0)
108
108
  rubocop (~> 1.41)
@@ -111,7 +111,7 @@ GEM
111
111
  rubocop-faker (1.1.0)
112
112
  faker (>= 2.12.0)
113
113
  rubocop (>= 0.82.0)
114
- rubocop-rspec (2.27.0)
114
+ rubocop-rspec (2.27.1)
115
115
  rubocop (~> 1.40)
116
116
  rubocop-capybara (~> 2.17)
117
117
  rubocop-factory_bot (~> 2.22)
data/README.md CHANGED
@@ -98,6 +98,11 @@ begin
98
98
  # Other
99
99
  request.lifetime = 30
100
100
  request.web_payment_form_id = '987654321'
101
+
102
+ # Reminders
103
+ request.pay_later = true
104
+ request.add_reminder channel: 'email', after: 10
105
+ request.add_reminder channel: 'sms', after: 30
101
106
  end.execute
102
107
 
103
108
  puts genesis.response.response_object
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -0,0 +1,90 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Constants
4
+ # WPF localization constants
5
+ class I18n
6
+
7
+ extend Mixins::Constants::Common
8
+
9
+ # Arabic
10
+ AR = 'ar'.freeze
11
+
12
+ # Bulgarian
13
+ BG = 'bg'.freeze
14
+
15
+ # German
16
+ DE = 'de'.freeze
17
+
18
+ # English
19
+ EN = 'en'.freeze
20
+
21
+ # Spanish
22
+ ES = 'es'.freeze
23
+
24
+ # French
25
+ FR = 'fr'.freeze
26
+
27
+ # Hindu
28
+ HI = 'hi'.freeze
29
+
30
+ # Japanese
31
+ JA = 'ja'.freeze
32
+
33
+ # Icelandic
34
+ IS = 'is'.freeze
35
+
36
+ # Italian
37
+ IT = 'it'.freeze
38
+
39
+ # Dutch
40
+ NL = 'nl'.freeze
41
+
42
+ # Portuguese
43
+ PT = 'pt'.freeze
44
+
45
+ # Polish
46
+ PL = 'pl'.freeze
47
+
48
+ # Russian
49
+ RU = 'ru'.freeze
50
+
51
+ # Turkish
52
+ TR = 'tr'.freeze
53
+
54
+ # Mandarin Chinese
55
+ ZH = 'zh'.freeze
56
+
57
+ # Indonesian
58
+ ID = 'id'.freeze
59
+
60
+ # Malay
61
+ MS = 'ms'.freeze
62
+
63
+ # Thai
64
+ TH = 'th'.freeze
65
+
66
+ # Czech
67
+ CS = 'cs'.freeze
68
+
69
+ # Croatian
70
+ HR = 'hr'.freeze
71
+
72
+ # Slovenian
73
+ SL = 'sl'.freeze
74
+
75
+ # Finnish
76
+ FI = 'fi'.freeze
77
+
78
+ # Norwegian
79
+ NO = 'no'.freeze
80
+
81
+ # Danish
82
+ DA = 'da'.freeze
83
+
84
+ # Swedish
85
+ SV = 'sv'.freeze
86
+
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,24 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Constants
4
+ module Transactions
5
+ module Parameters
6
+ module Wpf
7
+ # Channel for sending WPF reminder. Valid values are ’email’ and ’sms’
8
+ class ReminderChannels
9
+
10
+ extend Mixins::Constants::Common
11
+
12
+ # Channel email
13
+ EMAIL = 'email'.freeze
14
+
15
+ # Channel sms
16
+ SMS = 'sms'.freeze
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,59 @@
1
+ require 'genesis_ruby/utils/options/reminder'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Mixins
6
+ module Requests
7
+ # Settings for reminders sending when using the ’Pay Later’ feature
8
+ module WpfRemindersAttributes
9
+
10
+ attr_reader :reminder_language
11
+ attr_writer :reminders
12
+
13
+ # It must be a valid language abbreviation
14
+ def reminder_language=(value)
15
+ allowed_options attribute: __method__,
16
+ allowed: Api::Constants::I18n.all,
17
+ value: value.to_s.downcase,
18
+ allow_empty: true
19
+ end
20
+
21
+ # Settings for a single reminder. Upto three reminders are allowed
22
+ def add_reminder(channel:, after:)
23
+ raise InvalidArgumentError, 'Reminders exceed the allowed count of 3.' if reminders.count >= 3
24
+
25
+ reminders << init_reminder(channel: channel, after: after)
26
+ end
27
+
28
+ protected
29
+
30
+ # Reminders structure
31
+ def reminders_structure
32
+ return reminders if reminders.empty?
33
+
34
+ reminders.map &:object_structure
35
+ end
36
+
37
+ private :reminders=
38
+
39
+ # Reminder Data Object
40
+ def init_reminder(channel:, after:)
41
+ reminder = Utils::Options::Reminder.new
42
+
43
+ reminder.channel = channel
44
+ reminder.after = after.to_i
45
+
46
+ reminder
47
+ end
48
+
49
+ # The number of the sent reminders would be exactly as sent or configured and delivery failures could be
50
+ # handled on demand. Also there will be no reminders sent if the WPF is already completed
51
+ def reminders
52
+ @reminders ||= []
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  module GenesisRuby
2
2
 
3
- VERSION = '0.1.5'.freeze
3
+ VERSION = '0.1.6'.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.6
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-03-25 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
@@ -270,6 +271,7 @@ files:
270
271
  - lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/purchase/categories.rb
271
272
  - lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/interfaces.rb
272
273
  - lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/ui_types.rb
274
+ - lib/genesis_ruby/api/constants/transactions/parameters/wpf/reminder_channels.rb
273
275
  - lib/genesis_ruby/api/mixins/constants/common.rb
274
276
  - lib/genesis_ruby/api/mixins/requests/address_info_attributes.rb
275
277
  - lib/genesis_ruby/api/mixins/requests/attribute_validation.rb
@@ -317,6 +319,7 @@ files:
317
319
  - lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/sdk.rb
318
320
  - lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/wpf_attributes.rb
319
321
  - lib/genesis_ruby/api/mixins/requests/restricted_setter.rb
322
+ - lib/genesis_ruby/api/mixins/requests/wpf_reminders_attributes.rb
320
323
  - lib/genesis_ruby/api/notification.rb
321
324
  - lib/genesis_ruby/api/request.rb
322
325
  - lib/genesis_ruby/api/requests/base/financial.rb
@@ -374,6 +377,7 @@ files:
374
377
  - lib/genesis_ruby/utils/options/api_config.rb
375
378
  - lib/genesis_ruby/utils/options/base.rb
376
379
  - lib/genesis_ruby/utils/options/network_adapter_config.rb
380
+ - lib/genesis_ruby/utils/options/reminder.rb
377
381
  - lib/genesis_ruby/utils/threeds/v2.rb
378
382
  - lib/genesis_ruby/utils/transactions/financial_types.rb
379
383
  - lib/genesis_ruby/utils/transactions/references/capturable_types.rb