genesis_ruby 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/Gemfile.lock +43 -40
  4. data/README.md +23 -0
  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/managed_recurring/amount_types.rb +1 -1
  8. data/lib/genesis_ruby/api/constants/transactions/parameters/wpf/reminder_channels.rb +24 -0
  9. data/lib/genesis_ruby/api/mixins/requests/attribute_validation.rb +54 -0
  10. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/recurring_type_attributes.rb +7 -0
  11. data/lib/genesis_ruby/api/mixins/requests/wpf_reminders_attributes.rb +59 -0
  12. data/lib/genesis_ruby/api/request.rb +7 -4
  13. data/lib/genesis_ruby/api/requests/base/financial.rb +27 -0
  14. data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +4 -0
  15. data/lib/genesis_ruby/api/requests/base/reference.rb +4 -0
  16. data/lib/genesis_ruby/api/requests/financial/capture.rb +0 -1
  17. data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +6 -1
  18. data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +0 -1
  19. data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +6 -1
  20. data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +0 -1
  21. data/lib/genesis_ruby/api/requests/financial/cards/threeds/v2/method_continue.rb +4 -1
  22. data/lib/genesis_ruby/api/requests/financial/refund.rb +0 -2
  23. data/lib/genesis_ruby/api/requests/financial/void.rb +4 -0
  24. data/lib/genesis_ruby/api/requests/non_financial/reconcile/date_range.rb +4 -2
  25. data/lib/genesis_ruby/api/requests/wpf/create.rb +84 -5
  26. data/lib/genesis_ruby/api/requests/wpf/reconcile.rb +4 -0
  27. data/lib/genesis_ruby/api/response.rb +1 -1
  28. data/lib/genesis_ruby/configuration.rb +21 -3
  29. data/lib/genesis_ruby/dependencies.rb +2 -1
  30. data/lib/genesis_ruby/errors/request_error.rb +14 -0
  31. data/lib/genesis_ruby/utils/options/reminder.rb +60 -0
  32. data/lib/genesis_ruby/version.rb +1 -1
  33. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02dff613f2499bed46dee4d66d10fb64ea987d663d14e1097bb6ab36a444336a
4
- data.tar.gz: bc89246c16d0b2e5b70dbd11c2b35421874ec749e0e6dd2926135850bf37faa7
3
+ metadata.gz: 3bae58236ea63ffb79254010e7dd8651252a8f128eb3c9e245eaf6cc4588c426
4
+ data.tar.gz: e9bc31285e5acceefe5df452d274445f6b88e3039115d313ea1361b9990cc149
5
5
  SHA512:
6
- metadata.gz: 8eacfb3b669fee18642bbeadb3d291ee4e8fd18e45fd45486c954646f3dc7f1cc146321b64cfef6d8bdce9a91c58e13d6e3a4c4a44eb71154a366d54a58a5e6c
7
- data.tar.gz: 7d8eff36538c46f41671c90d71af6af9d8d432c52ddb2238a5b64699956be0a9eabf68fd19c52a03e2310738ce9eb6f918d1c4b1d12dd23c06265cb2c0d7cb2b
6
+ metadata.gz: 235e870d4dc316eface0f780352fe0129293740742ab45b6638d839cf51cbd9296e193be9a9cf533da6f1c089e39885e47fbf4220523a715a1db8c3c821a3b6c
7
+ data.tar.gz: 346de3c0848acea9c8394323b8377fc1fb86eab52fa125f30586dcb71bf0f2422d7f128fe3152547284274ca5eddde44a1a1d96206d9391bcf65525669f46529
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
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
+
13
+ 0.1.5
14
+ -----
15
+ **Features**:
16
+
17
+ * Added Smart Routing support
18
+ * Added Required field validations to the existing transaction requests
19
+
20
+ **Fixes**:
21
+
22
+ * Fixed JSON parser loading in the Response handling logic
23
+
1
24
  0.1.4
2
25
  -----
3
26
  **Features**:
data/Gemfile.lock CHANGED
@@ -1,24 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- genesis_ruby (0.1.4)
4
+ genesis_ruby (0.1.6)
5
5
  net-http (~> 0.3.2)
6
6
  nokogiri (~> 1.14)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.8.5)
11
+ addressable (2.8.6)
12
12
  public_suffix (>= 2.0.2, < 6.0)
13
13
  ast (2.4.2)
14
14
  base64 (0.2.0)
15
- concurrent-ruby (1.2.2)
16
- crack (0.4.5)
15
+ bigdecimal (3.1.7)
16
+ concurrent-ruby (1.2.3)
17
+ crack (1.0.0)
18
+ bigdecimal
17
19
  rexml
18
- diff-lcs (1.5.0)
20
+ diff-lcs (1.5.1)
19
21
  faker (2.23.0)
20
22
  i18n (>= 1.8.11, < 2)
21
- faraday (2.7.12)
23
+ faraday (2.8.1)
22
24
  base64
23
25
  faraday-net_http (>= 2.0, < 3.1)
24
26
  ruby2_keywords (>= 0.0.4)
@@ -28,13 +30,13 @@ GEM
28
30
  gitlab (4.19.0)
29
31
  httparty (~> 0.20)
30
32
  terminal-table (>= 1.5.1)
31
- hashdiff (1.0.1)
33
+ hashdiff (1.1.0)
32
34
  httparty (0.21.0)
33
35
  mini_mime (>= 1.0.0)
34
36
  multi_xml (>= 0.5.2)
35
- i18n (1.14.1)
37
+ i18n (1.14.4)
36
38
  concurrent-ruby (~> 1.0)
37
- json (2.6.3)
39
+ json (2.7.1)
38
40
  language_server-protocol (3.17.0.3)
39
41
  mini_mime (1.1.5)
40
42
  mini_portile2 (2.8.5)
@@ -43,14 +45,14 @@ GEM
43
45
  ruby2_keywords (~> 0.0.1)
44
46
  net-http (0.3.2)
45
47
  uri
46
- nokogiri (1.15.5)
48
+ nokogiri (1.15.6)
47
49
  mini_portile2 (~> 2.8.2)
48
50
  racc (~> 1.4)
49
51
  octokit (7.2.0)
50
52
  faraday (>= 1, < 3)
51
53
  sawyer (~> 0.9)
52
- parallel (1.23.0)
53
- parser (3.2.2.4)
54
+ parallel (1.24.0)
55
+ parser (3.3.0.5)
54
56
  ast (~> 2.4.1)
55
57
  racc
56
58
  pronto (0.11.2)
@@ -66,70 +68,71 @@ GEM
66
68
  rubocop (>= 0.63.1, < 2.0)
67
69
  public_suffix (5.0.4)
68
70
  racc (1.7.3)
69
- rack (2.2.8)
70
- rack-protection (3.1.0)
71
+ rack (2.2.9)
72
+ rack-protection (3.2.0)
73
+ base64 (>= 0.1.0)
71
74
  rack (~> 2.2, >= 2.2.4)
72
75
  rainbow (3.1.1)
73
76
  rake (13.1.0)
74
- regexp_parser (2.8.2)
77
+ regexp_parser (2.9.0)
75
78
  rexml (3.2.6)
76
- rspec (3.12.0)
77
- rspec-core (~> 3.12.0)
78
- rspec-expectations (~> 3.12.0)
79
- rspec-mocks (~> 3.12.0)
80
- rspec-core (3.12.2)
81
- rspec-support (~> 3.12.0)
82
- rspec-expectations (3.12.3)
79
+ rspec (3.13.0)
80
+ rspec-core (~> 3.13.0)
81
+ rspec-expectations (~> 3.13.0)
82
+ rspec-mocks (~> 3.13.0)
83
+ rspec-core (3.13.0)
84
+ rspec-support (~> 3.13.0)
85
+ rspec-expectations (3.13.0)
83
86
  diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.12.0)
85
- rspec-mocks (3.12.6)
87
+ rspec-support (~> 3.13.0)
88
+ rspec-mocks (3.13.0)
86
89
  diff-lcs (>= 1.2.0, < 2.0)
87
- rspec-support (~> 3.12.0)
88
- rspec-support (3.12.1)
90
+ rspec-support (~> 3.13.0)
91
+ rspec-support (3.13.1)
89
92
  rspec_junit_formatter (0.6.0)
90
93
  rspec-core (>= 2, < 4, != 2.12.0)
91
- rubocop (1.57.2)
94
+ rubocop (1.62.1)
92
95
  json (~> 2.3)
93
96
  language_server-protocol (>= 3.17.0)
94
97
  parallel (~> 1.10)
95
- parser (>= 3.2.2.4)
98
+ parser (>= 3.3.0.2)
96
99
  rainbow (>= 2.2.2, < 4.0)
97
100
  regexp_parser (>= 1.8, < 3.0)
98
101
  rexml (>= 3.2.5, < 4.0)
99
- rubocop-ast (>= 1.28.1, < 2.0)
102
+ rubocop-ast (>= 1.31.1, < 2.0)
100
103
  ruby-progressbar (~> 1.7)
101
104
  unicode-display_width (>= 2.4.0, < 3.0)
102
- rubocop-ast (1.30.0)
103
- parser (>= 3.2.1.0)
104
- rubocop-capybara (2.19.0)
105
+ rubocop-ast (1.31.2)
106
+ parser (>= 3.3.0.4)
107
+ rubocop-capybara (2.20.0)
108
+ rubocop (~> 1.41)
109
+ rubocop-factory_bot (2.25.1)
105
110
  rubocop (~> 1.41)
106
- rubocop-factory_bot (2.24.0)
107
- rubocop (~> 1.33)
108
111
  rubocop-faker (1.1.0)
109
112
  faker (>= 2.12.0)
110
113
  rubocop (>= 0.82.0)
111
- rubocop-rspec (2.25.0)
114
+ rubocop-rspec (2.27.1)
112
115
  rubocop (~> 1.40)
113
116
  rubocop-capybara (~> 2.17)
114
117
  rubocop-factory_bot (~> 2.22)
115
118
  ruby-progressbar (1.13.0)
116
119
  ruby2_keywords (0.0.5)
117
- rugged (1.7.1)
120
+ rugged (1.7.2)
118
121
  sawyer (0.9.2)
119
122
  addressable (>= 2.3.5)
120
123
  faraday (>= 0.17.3, < 3)
121
- sinatra (3.1.0)
124
+ sinatra (3.2.0)
122
125
  mustermann (~> 3.0)
123
126
  rack (~> 2.2, >= 2.2.4)
124
- rack-protection (= 3.1.0)
127
+ rack-protection (= 3.2.0)
125
128
  tilt (~> 2.0)
126
129
  terminal-table (3.0.2)
127
130
  unicode-display_width (>= 1.1.1, < 3)
128
- thor (1.3.0)
131
+ thor (1.3.1)
129
132
  tilt (2.3.0)
130
133
  unicode-display_width (2.5.0)
131
134
  uri (0.13.0)
132
- webmock (3.19.1)
135
+ webmock (3.23.0)
133
136
  addressable (>= 2.8.0)
134
137
  crack (>= 0.3.2)
135
138
  hashdiff (>= 0.4.0, < 2.0.0)
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
@@ -148,6 +153,24 @@ rescue GenesisRuby::Error => error
148
153
  end
149
154
  ```
150
155
 
156
+ ### Smart Router
157
+
158
+ The Smart Routing API is a higher-level abstraction that allows for simpler and more efficient gateway Processing API integration.
159
+ It does not require the terminal token (`configuration.token`). This by itself minimizes the need for complex customer-level manual routing to terminals set up on the gateway platform configuration layer.
160
+
161
+ By default the Smart Router is disabled. Contact your account manager to use the functionality.
162
+
163
+ Smart Router global definition for all requests
164
+ * GenesisRuby::Configuration
165
+ ```ruby
166
+ configuration.force_smart_routing = true
167
+ ```
168
+
169
+ * Smart Router definition per request
170
+ ```ruby
171
+ request.use_smart_router = true
172
+ ```
173
+
151
174
  ### Example 3DSv2 Request
152
175
 
153
176
  Sample request including all the conditionally required/optional params for initiating a 3DS transaction with the 3DSv2-Method authentication protocol.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
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
@@ -13,7 +13,7 @@ module GenesisRuby
13
13
  FIXED = 'fixed'.freeze
14
14
 
15
15
  # Amount Type MAX
16
- MAX = 'MAX'.freeze
16
+ MAX = 'max'.freeze
17
17
 
18
18
  end
19
19
  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,54 @@
1
+ require 'genesis_ruby/errors/request_error'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Mixins
6
+ module Requests
7
+ # Request Class attribute validations
8
+ # Reads the pre-set `validation_<attribute>` and perform validation on the fields
9
+ module AttributeValidation
10
+
11
+ protected
12
+
13
+ # Perform validation
14
+ def validate
15
+ validate_required_fields
16
+ end
17
+
18
+ # Required Fields Accessor
19
+ def required_fields
20
+ @required_fields ||= []
21
+ end
22
+
23
+ # Required Fields Accessor
24
+ def required_fields=(value)
25
+ raise RequestError, 'Invalid value given for Required Fields! Allowed type Array.' unless value.is_a? Array
26
+
27
+ @required_fields = value
28
+ end
29
+
30
+ private
31
+
32
+ # Validated Required fields
33
+ def validate_required_fields
34
+ required_fields.each do |field_name|
35
+ if null_or_empty_field?(field_name)
36
+ raise ParameterError, "Empty (nil) for required parameter: #{field_name}"
37
+ end
38
+ end
39
+ end
40
+
41
+ # Validate if the given field_name is null or empty
42
+ def null_or_empty_field?(field_name)
43
+ field_value = __send__ field_name.to_sym
44
+
45
+ return false if [Integer, Float, TrueClass, FalseClass, DateTime].any? { |type| field_value.is_a? type }
46
+
47
+ field_value.nil? || field_value.empty?
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -21,6 +21,13 @@ module GenesisRuby
21
21
  allow_empty: true
22
22
  end
23
23
 
24
+ protected
25
+
26
+ # Minimum required fields with recurring_type subsequent request
27
+ def recurring_type_subsequent_required_request_attributes
28
+ %i[transaction_id amount]
29
+ end
30
+
24
31
  end
25
32
  end
26
33
  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
@@ -9,6 +9,9 @@ module GenesisRuby
9
9
  # Base Request Class
10
10
  class Request
11
11
 
12
+ include Mixins::Requests::RestrictedSetter
13
+ include Mixins::Requests::AttributeValidation
14
+
12
15
  PROTOCOL_HTTPS = 'https'.freeze
13
16
  PORT_HTTPS = 443
14
17
 
@@ -46,12 +49,12 @@ module GenesisRuby
46
49
  attr_reader :configuration, :builder_interface, :builder_context
47
50
  attr_accessor :tree_structure
48
51
 
49
- # Request Configuration
50
- def init_configuration; end
51
-
52
52
  # Required fields for the request
53
53
  def init_required_fields; end
54
54
 
55
+ # Request Configuration
56
+ def init_configuration; end
57
+
55
58
  # Pre-defined XML Request Configuration
56
59
  def init_xml_configuration
57
60
  @api_config.load_xml_config
@@ -121,7 +124,7 @@ module GenesisRuby
121
124
 
122
125
  # Perform validation over the defined parameters
123
126
  def check_requirements
124
- # TODO: perform validation over the defined parameters
127
+ validate
125
128
  end
126
129
 
127
130
  # Build the Genesis API endpoint
@@ -7,6 +7,20 @@ module GenesisRuby
7
7
 
8
8
  include Mixins::Requests::Financial::BaseAttributes
9
9
 
10
+ # Use Smart Router endpoint for the current request
11
+ def use_smart_router
12
+ @use_smart_router ||= false
13
+ end
14
+
15
+ # Use Smart Router endpoint for the current request
16
+ def use_smart_router=(value)
17
+ unless [true, false].include? value
18
+ raise InvalidArgumentError, 'Given invalid Use Smart Routing value! Allowed: true, false'
19
+ end
20
+
21
+ @use_smart_router = value
22
+ end
23
+
10
24
  protected
11
25
 
12
26
  # Returns the Request transaction type
@@ -24,6 +38,14 @@ module GenesisRuby
24
38
  super
25
39
  init_xml_configuration
26
40
  init_api_gateway_configuration
41
+ init_api_smart_router_configuration if @configuration.force_smart_routing
42
+ end
43
+
44
+ # Process the request
45
+ def process_request_parameters
46
+ init_api_smart_router_configuration if use_smart_router
47
+
48
+ super
27
49
  end
28
50
 
29
51
  def populate_structure
@@ -37,6 +59,11 @@ module GenesisRuby
37
59
  }
38
60
  end
39
61
 
62
+ # Initialize Smart Router endpoint
63
+ def init_api_smart_router_configuration
64
+ api_config.url = build_request_url({ subdomain: 'smart_router', path: 'transactions' })
65
+ end
66
+
40
67
  end
41
68
  end
42
69
  end
@@ -11,6 +11,10 @@ module GenesisRuby
11
11
  include Mixins::Requests::Financial::Cards::TokenizationAttributes
12
12
  include Mixins::Requests::Financial::PaymentAttributes
13
13
 
14
+ def init_required_fields
15
+ self.required_fields = %i[transaction_id amount currency]
16
+ end
17
+
14
18
  protected
15
19
 
16
20
  # Credit Card attributes
@@ -10,6 +10,10 @@ module GenesisRuby
10
10
 
11
11
  protected
12
12
 
13
+ def init_required_fields
14
+ self.required_fields = %i[transaction_id reference_id amount currency]
15
+ end
16
+
13
17
  # Reference transaction request structure
14
18
  def reference_transaction_structure
15
19
  raise NotImplementedError, 'Reference transaction structure must be implemented.'
@@ -6,7 +6,6 @@ module GenesisRuby
6
6
  class Capture < Requests::Base::Reference
7
7
 
8
8
  include Mixins::Requests::Financial::Business::BusinessAttributes
9
- include Mixins::Requests::RestrictedSetter
10
9
 
11
10
  protected
12
11
 
@@ -23,7 +23,6 @@ module GenesisRuby
23
23
  include Mixins::Requests::Financial::ReferenceAttributes
24
24
  include Mixins::Requests::Financial::RiskAttributes
25
25
  include Mixins::Requests::Financial::ScaAttributes
26
- include Mixins::Requests::RestrictedSetter
27
26
 
28
27
  protected
29
28
 
@@ -32,6 +31,12 @@ module GenesisRuby
32
31
  GenesisRuby::Api::Constants::Transactions::AUTHORIZE
33
32
  end
34
33
 
34
+ def init_required_fields
35
+ return super unless recurring_type == Constants::Transactions::Parameters::Recurring::Types::SUBSEQUENT
36
+
37
+ self.required_fields = recurring_type_subsequent_required_request_attributes
38
+ end
39
+
35
40
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
36
41
  super.merge(
37
42
  gaming: gaming,
@@ -26,7 +26,6 @@ module GenesisRuby
26
26
  include Mixins::Requests::Financial::RiskAttributes
27
27
  include Mixins::Requests::Financial::ScaAttributes
28
28
  include Mixins::Requests::Financial::Threeds::Version2::CommonAttributes
29
- include Mixins::Requests::RestrictedSetter
30
29
 
31
30
  # Specifies the recurring type of transaction
32
31
  def recurring_type=(value)
@@ -22,7 +22,6 @@ module GenesisRuby
22
22
  include Mixins::Requests::Financial::ReferenceAttributes
23
23
  include Mixins::Requests::Financial::RiskAttributes
24
24
  include Mixins::Requests::Financial::ScaAttributes
25
- include Mixins::Requests::RestrictedSetter
26
25
 
27
26
  protected
28
27
 
@@ -31,6 +30,12 @@ module GenesisRuby
31
30
  GenesisRuby::Api::Constants::Transactions::SALE
32
31
  end
33
32
 
33
+ def init_required_fields
34
+ return super unless recurring_type == Constants::Transactions::Parameters::Recurring::Types::SUBSEQUENT
35
+
36
+ self.required_fields = recurring_type_subsequent_required_request_attributes
37
+ end
38
+
34
39
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
35
40
  super.merge(
36
41
  gaming: gaming,
@@ -25,7 +25,6 @@ module GenesisRuby
25
25
  include Mixins::Requests::Financial::RiskAttributes
26
26
  include Mixins::Requests::Financial::ScaAttributes
27
27
  include Mixins::Requests::Financial::Threeds::Version2::CommonAttributes
28
- include Mixins::Requests::RestrictedSetter
29
28
 
30
29
  # Specifies the recurring type of transaction
31
30
  def recurring_type=(value)
@@ -11,7 +11,6 @@ module GenesisRuby
11
11
  class MethodContinue < Request
12
12
 
13
13
  include Mixins::Requests::Financial::PaymentAttributes
14
- include Mixins::Requests::RestrictedSetter
15
14
 
16
15
  attr_writer :url, :transaction_unique_id, :signature
17
16
 
@@ -105,6 +104,10 @@ module GenesisRuby
105
104
  init_api_gateway_configuration request_path: 'threeds/threeds_method/:unique_id', include_token: false
106
105
  end
107
106
 
107
+ def init_required_fields
108
+ self.required_fields = %i[amount transaction_timestamp]
109
+ end
110
+
108
111
  # Build correct endpoint url during runtime
109
112
  def process_request_parameters
110
113
  @api_config.url = url
@@ -7,8 +7,6 @@ module GenesisRuby
7
7
  # Refund reference transaction request
8
8
  class Refund < Requests::Base::Reference
9
9
 
10
- include Mixins::Requests::RestrictedSetter
11
-
12
10
  attr_accessor :beneficiary_bank_code, :beneficiary_name, :beneficiary_account_number, :bank, :bank_branch,
13
11
  :bank_account
14
12
  attr_reader :bank_account_type
@@ -14,6 +14,10 @@ module GenesisRuby
14
14
  Api::Constants::Transactions::VOID
15
15
  end
16
16
 
17
+ def init_required_fields
18
+ self.required_fields = %i[transaction_id reference_id]
19
+ end
20
+
17
21
  # Void transaction request structure
18
22
  def payment_transaction_structure
19
23
  {
@@ -8,8 +8,6 @@ module GenesisRuby
8
8
  # The response is paginated, each request will return 100 entries max.
9
9
  class DateRange < Api::Request
10
10
 
11
- include Mixins::Requests::RestrictedSetter
12
-
13
11
  attr_reader :page
14
12
 
15
13
  # Start of the requested date range (time is optional)
@@ -62,6 +60,10 @@ module GenesisRuby
62
60
  @api_config.parser_skip_root_node = false
63
61
  end
64
62
 
63
+ def init_required_fields
64
+ self.required_fields = %i[start_date]
65
+ end
66
+
65
67
  # API Request structure
66
68
  def populate_structure
67
69
  @tree_structure = {
@@ -1,14 +1,15 @@
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
6
8
  module Requests
7
9
  module Wpf
8
10
  # Web-Payment Form Request
9
- class Create < Request
11
+ class Create < Request # rubocop:disable Metrics/ClassLength
10
12
 
11
- include Mixins::Requests::RestrictedSetter
12
13
  include Mixins::Requests::Financial::PaymentAttributes
13
14
  include Mixins::Requests::AddressInfoAttributes
14
15
  include Mixins::Requests::Financial::AsyncAttributes
@@ -20,10 +21,17 @@ module GenesisRuby
20
21
  include Mixins::Requests::Financial::DynamicDescriptorAttributes
21
22
  include Mixins::Requests::Financial::RiskAttributes
22
23
  include Mixins::Requests::Financial::Business::BusinessAttributes
24
+ include Mixins::Requests::WpfRemindersAttributes
23
25
 
24
26
  attr_reader :locale, :sca_preference, :sca_exemption
25
27
  attr_accessor :transaction_id, :usage, :description, :consumer_id, :return_cancel_url, :remember_card,
26
- :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
27
35
 
28
36
  # The transaction types that the merchant is willing to accept payments for
29
37
  def add_transaction_type(name, custom_attributes = {})
@@ -38,7 +46,12 @@ module GenesisRuby
38
46
 
39
47
  # Define ISO 639-1 language code to the URL
40
48
  def locale=(value)
41
- 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)
42
55
  end
43
56
 
44
57
  # Signifies whether to perform SCA on the transaction. At least one 3DS transaction type has to be submitted.
@@ -60,6 +73,41 @@ module GenesisRuby
60
73
  allow_empty: true
61
74
  end
62
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
+
63
111
  protected
64
112
 
65
113
  # Load base configuration
@@ -68,12 +116,27 @@ module GenesisRuby
68
116
  init_api_wpf_configuration
69
117
  end
70
118
 
119
+ def init_required_fields
120
+ self.required_fields = %i[
121
+ transaction_id
122
+ amount
123
+ currency
124
+ notification_url
125
+ return_success_url
126
+ return_failure_url
127
+ return_cancel_url
128
+ transaction_types
129
+ ]
130
+ end
131
+
71
132
  # Perform validation over the defined parameters upon request execution
72
133
  def check_requirements
73
134
  unless GenesisRuby::Api::Constants::Currencies::Iso4217.valid?(currency)
74
135
  raise ParameterError, "Invalid Currency given with value #{currency}"
75
136
  end
76
137
 
138
+ validate_reminders
139
+
77
140
  super
78
141
  end
79
142
 
@@ -109,7 +172,9 @@ module GenesisRuby
109
172
  recurring_category: recurring_category,
110
173
  dynamic_descriptor_params: dynamic_descriptor_structure,
111
174
  risk_params: risk_parameters_structure,
112
- account_owner: account_owner_attributes_structure
175
+ account_owner: account_owner_attributes_structure,
176
+ pay_later: pay_later,
177
+ reminders: pay_later ? reminders_structure : []
113
178
  }
114
179
  }
115
180
  end
@@ -125,6 +190,20 @@ module GenesisRuby
125
190
  @transaction_types.push(value)
126
191
  end
127
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
+
128
207
  end
129
208
  end
130
209
  end
@@ -17,6 +17,10 @@ module GenesisRuby
17
17
  @api_config.url = build_request_url subdomain: 'wpf', path: 'wpf/reconcile'
18
18
  end
19
19
 
20
+ def init_required_fields
21
+ self.required_fields = %i[unique_id]
22
+ end
23
+
20
24
  # WPF Reconcile request structure
21
25
  def populate_structure
22
26
  @tree_structure = {
@@ -54,7 +54,7 @@ module GenesisRuby
54
54
 
55
55
  # Load the corresponding parser based on the Network header
56
56
  def load_parser(network)
57
- @parser = GenesisRuby::Parsers.new(GenesisRuby::Parser::JSON) if network.json?
57
+ @parser = GenesisRuby::Parser.new(GenesisRuby::Parser::JSON) if network.json?
58
58
  @parser = GenesisRuby::Parser.new(GenesisRuby::Parser::XML) if network.xml?
59
59
 
60
60
  raise NetworkError, network.server_message if @parser.nil? || @response_raw.empty?
@@ -59,6 +59,11 @@ module GenesisRuby
59
59
  @timeout ||= DEFAULT_TIMEOUT
60
60
  end
61
61
 
62
+ # Enable Smart Routing for Financial transaction requests
63
+ def force_smart_routing
64
+ @force_smart_routing ||= false
65
+ end
66
+
62
67
  # Genesis Request Timeout
63
68
  def timeout=(value)
64
69
  timeout = value.to_i
@@ -120,6 +125,15 @@ module GenesisRuby
120
125
  @sanitize_response
121
126
  end
122
127
 
128
+ # Enable Smart Routing for Financial transaction requests
129
+ def force_smart_routing=(value)
130
+ unless [true, false].include? value
131
+ raise InvalidArgumentError, 'Given invalid Force Smart Routing value! Allowed: true, false'
132
+ end
133
+
134
+ @force_smart_routing = value
135
+ end
136
+
123
137
  private
124
138
 
125
139
  # Various definitions for environment
@@ -160,15 +174,19 @@ module GenesisRuby
160
174
  # rubocop:enable Metrics/MethodLength
161
175
 
162
176
  # Available Genesis subdomains
163
- def available_sub_domains
177
+ def available_sub_domains # rubocop:disable Metrics/MethodLength
164
178
  {
165
- gateway: {
179
+ gateway: {
166
180
  GenesisRuby::Api::Constants::Environments::PRODUCTION => 'gate.',
167
181
  GenesisRuby::Api::Constants::Environments::STAGING => 'staging.gate.'
168
182
  },
169
- wpf: {
183
+ wpf: {
170
184
  GenesisRuby::Api::Constants::Environments::PRODUCTION => 'wpf.',
171
185
  GenesisRuby::Api::Constants::Environments::STAGING => 'staging.wpf.'
186
+ },
187
+ smart_router: {
188
+ GenesisRuby::Api::Constants::Environments::PRODUCTION => 'prod.api.',
189
+ GenesisRuby::Api::Constants::Environments::STAGING => 'staging.api.'
172
190
  }
173
191
  }
174
192
  end
@@ -1,9 +1,10 @@
1
1
  # =================================
2
2
  # Transaction Request Requirements
3
3
  # =================================
4
+ require 'genesis_ruby/api/mixins/requests/attribute_validation'
5
+ require 'genesis_ruby/api/mixins/requests/restricted_setter'
4
6
  require 'genesis_ruby/api/request'
5
7
  require 'genesis_ruby/api/mixins/constants/common'
6
- require 'genesis_ruby/api/mixins/requests/restricted_setter'
7
8
 
8
9
  # =================================
9
10
  # Transaction Requests Definitions
@@ -0,0 +1,14 @@
1
+ require 'genesis_ruby/errors/error'
2
+
3
+ module GenesisRuby
4
+ # Response Custom Error
5
+ class RequestError < Error
6
+
7
+ def custom_message
8
+ return 'Invalid argument given! ' unless @message
9
+
10
+ @message
11
+ end
12
+
13
+ end
14
+ 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.4'.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.4
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-01-19 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,8 +271,10 @@ 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
277
+ - lib/genesis_ruby/api/mixins/requests/attribute_validation.rb
275
278
  - lib/genesis_ruby/api/mixins/requests/customer_address/billing_info_attributes.rb
276
279
  - lib/genesis_ruby/api/mixins/requests/customer_address/customer_info_attributes.rb
277
280
  - lib/genesis_ruby/api/mixins/requests/customer_address/shipping_info_attributes.rb
@@ -316,6 +319,7 @@ files:
316
319
  - lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/sdk.rb
317
320
  - lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/wpf_attributes.rb
318
321
  - lib/genesis_ruby/api/mixins/requests/restricted_setter.rb
322
+ - lib/genesis_ruby/api/mixins/requests/wpf_reminders_attributes.rb
319
323
  - lib/genesis_ruby/api/notification.rb
320
324
  - lib/genesis_ruby/api/request.rb
321
325
  - lib/genesis_ruby/api/requests/base/financial.rb
@@ -349,6 +353,7 @@ files:
349
353
  - lib/genesis_ruby/errors/object_formatter_error.rb
350
354
  - lib/genesis_ruby/errors/parameter_error.rb
351
355
  - lib/genesis_ruby/errors/parser_error.rb
356
+ - lib/genesis_ruby/errors/request_error.rb
352
357
  - lib/genesis_ruby/errors/response_error.rb
353
358
  - lib/genesis_ruby/network/adapter/base_adapter.rb
354
359
  - lib/genesis_ruby/network/adapter/net_http_adapter.rb
@@ -372,6 +377,7 @@ files:
372
377
  - lib/genesis_ruby/utils/options/api_config.rb
373
378
  - lib/genesis_ruby/utils/options/base.rb
374
379
  - lib/genesis_ruby/utils/options/network_adapter_config.rb
380
+ - lib/genesis_ruby/utils/options/reminder.rb
375
381
  - lib/genesis_ruby/utils/threeds/v2.rb
376
382
  - lib/genesis_ruby/utils/transactions/financial_types.rb
377
383
  - lib/genesis_ruby/utils/transactions/references/capturable_types.rb