nexio_activemerchant 0.1.0 → 0.2.2
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 +4 -4
- data/LICENSE +21 -0
- data/lib/active_merchant/billing/encrypted_nexio_card.rb +2 -2
- data/lib/active_merchant/billing/gateways/nexio.rb +70 -12
- data/lib/nexio_activemerchant.rb +1 -0
- data/lib/nexio_activemerchant/version.rb +1 -1
- data/nexio_activemerchant.gemspec +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fee4e8586b27556107241251a935bdc43ed0a5a6071511a0307b3c2542d891f
|
4
|
+
data.tar.gz: 8adc6b9e898e8b41016f380854c0450f31b21e033134e921f97e8d63d7f47886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dcf35fb8da06141ed952109bccd03fdbb885325237210b2d17fa22291708e17b3ce3e0bcb330b8d8d5a447d11b7a87dd35c26851572f0115515c2c1e60b76d4
|
7
|
+
data.tar.gz: 4b1421517e5a04defdd269948cd6a72de85a8c90589a00fd3ca39ba02b892abd753aa119f7fffb7f9aeb48c8553111fb98b36e89414326c5ba79702a0493fbcc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Whitespectre
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -18,8 +18,8 @@ module ActiveMerchant
|
|
18
18
|
|
19
19
|
if empty?(brand)
|
20
20
|
errors << [:brand, 'is required'] if own_form
|
21
|
-
|
22
|
-
errors << [:brand, 'is invalid']
|
21
|
+
elsif !self.class.card_companies.include?(brand)
|
22
|
+
errors << [:brand, 'is invalid']
|
23
23
|
end
|
24
24
|
|
25
25
|
errors << [:encrypted_number, 'is required'] if empty?(encrypted_number)
|
@@ -38,6 +38,11 @@ module ActiveMerchant
|
|
38
38
|
|
39
39
|
def purchase(money, payment, options = {})
|
40
40
|
post = build_payload(options)
|
41
|
+
post[:processingOptions] ||= {}
|
42
|
+
post[:processingOptions][:verboseResponse] = true if test?
|
43
|
+
post[:processingOptions][:customerRedirectUrl] = options[:three_d_callback_url] if options.key?(:three_d_callback_url)
|
44
|
+
post[:processingOptions][:check3ds] = options[:three_d_secure]
|
45
|
+
post[:processingOptions][:paymentType] = options[:payment_type] if options.key?(:payment_type)
|
41
46
|
add_invoice(post, money, options)
|
42
47
|
add_payment(post, payment, options)
|
43
48
|
add_order_data(post, options)
|
@@ -48,16 +53,17 @@ module ActiveMerchant
|
|
48
53
|
purchase(money, payment, options.merge(payload: options.fetch(:payload, {}).merge(isAuthOnly: true)))
|
49
54
|
end
|
50
55
|
|
51
|
-
def capture(
|
52
|
-
commit('capture',
|
56
|
+
def capture(money, authorization, _options = {})
|
57
|
+
commit('capture', { id: authorization, data: { amount: amount(money).to_f } })
|
53
58
|
end
|
54
59
|
|
55
|
-
def refund(
|
56
|
-
commit('refund',
|
60
|
+
def refund(money, authorization, _options = {})
|
61
|
+
commit('refund', { id: authorization, data: { amount: amount(money).to_f } })
|
57
62
|
end
|
63
|
+
alias credit refund
|
58
64
|
|
59
|
-
def void(
|
60
|
-
commit('void',
|
65
|
+
def void(authorization, _options = {})
|
66
|
+
commit('void', { id: authorization })
|
61
67
|
end
|
62
68
|
|
63
69
|
def verify(credit_card, options = {})
|
@@ -86,6 +92,31 @@ module ActiveMerchant
|
|
86
92
|
resp.params.fetch('token', {}).fetch('token', nil)
|
87
93
|
end
|
88
94
|
|
95
|
+
def set_webhooks(data)
|
96
|
+
post = { merchantId: options[:merchant_id].to_s }
|
97
|
+
if data.is_a?(String)
|
98
|
+
post[:webhooks] = {
|
99
|
+
TRANSACTION_AUTHORIZED: { url: data },
|
100
|
+
TRANSACTION_CAPTURED: { url: data }
|
101
|
+
}
|
102
|
+
else
|
103
|
+
webhooks = {}
|
104
|
+
webhooks[:TRANSACTION_AUTHORIZED] = { url: data[:authorized] } if data.key?(:authorized)
|
105
|
+
webhooks[:TRANSACTION_CAPTURED] = { url: data[:captured] } if data.key?(:captured)
|
106
|
+
post[:webhooks] = webhooks
|
107
|
+
end
|
108
|
+
commit('webhook', post)
|
109
|
+
end
|
110
|
+
|
111
|
+
def set_secret
|
112
|
+
commit('secret', { merchantId: options[:merchant_id].to_s }).params['secret']
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_transaction(id)
|
116
|
+
parse(ssl_get(action_url("/transaction/v3/paymentId/#{id}"), base_headers))
|
117
|
+
rescue ResponseError => e
|
118
|
+
end
|
119
|
+
|
89
120
|
private
|
90
121
|
|
91
122
|
def add_invoice(post, money, options)
|
@@ -153,6 +184,12 @@ module ActiveMerchant
|
|
153
184
|
|
154
185
|
def add_payment(post, payment, options)
|
155
186
|
post[:tokenex] = token_from(payment)
|
187
|
+
if payment.is_a?(Spree::CreditCard)
|
188
|
+
post[:card] = {
|
189
|
+
cardHolderName: payment.name,
|
190
|
+
cardType: payment.brand
|
191
|
+
}
|
192
|
+
end
|
156
193
|
post[:processingOptions] ||= {}
|
157
194
|
post[:processingOptions][:merchantId] = self.options[:merchant_id].to_s
|
158
195
|
post[:processingOptions][:saveCardToken] = options[:save_credit_card] if options.key?(:save_credit_card)
|
@@ -163,7 +200,8 @@ module ActiveMerchant
|
|
163
200
|
|
164
201
|
{
|
165
202
|
token: payment.gateway_payment_profile_id,
|
166
|
-
lastFour: payment.last_digits
|
203
|
+
lastFour: payment.last_digits,
|
204
|
+
cardType: payment.brand
|
167
205
|
}
|
168
206
|
end
|
169
207
|
|
@@ -202,11 +240,10 @@ module ActiveMerchant
|
|
202
240
|
end
|
203
241
|
|
204
242
|
def commit(action, parameters)
|
205
|
-
payload = parse(ssl_post(
|
206
|
-
Authorization: "Basic #{options[:auth_token]}"))
|
243
|
+
payload = parse(ssl_post(commit_action_url(action, parameters), post_data(action, parameters), base_headers))
|
207
244
|
|
208
245
|
Response.new(
|
209
|
-
|
246
|
+
response_status(action, payload),
|
210
247
|
nil,
|
211
248
|
payload,
|
212
249
|
authorization: authorization_from(payload),
|
@@ -226,6 +263,14 @@ module ActiveMerchant
|
|
226
263
|
)
|
227
264
|
end
|
228
265
|
|
266
|
+
def response_status(action, payload)
|
267
|
+
case action
|
268
|
+
when 'process' then authorization_from(payload).present?
|
269
|
+
else
|
270
|
+
true
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
229
274
|
def authorization_from(payload)
|
230
275
|
payload.fetch('id', nil)
|
231
276
|
end
|
@@ -234,8 +279,17 @@ module ActiveMerchant
|
|
234
279
|
parameters.to_json
|
235
280
|
end
|
236
281
|
|
237
|
-
def
|
238
|
-
path =
|
282
|
+
def commit_action_url(action, _parameters)
|
283
|
+
path = case action
|
284
|
+
when 'webhook' then '/webhook/v3/config'
|
285
|
+
when 'secret' then '/webhook/v3/secret'
|
286
|
+
else
|
287
|
+
"/pay/v3/#{action}"
|
288
|
+
end
|
289
|
+
action_url(path)
|
290
|
+
end
|
291
|
+
|
292
|
+
def action_url(path)
|
239
293
|
"#{test? ? test_url : live_url}#{path}"
|
240
294
|
end
|
241
295
|
|
@@ -254,6 +308,10 @@ module ActiveMerchant
|
|
254
308
|
def build_payload(options)
|
255
309
|
{ data: { customer: {} } }.merge!(options.fetch(:payload, {}))
|
256
310
|
end
|
311
|
+
|
312
|
+
def base_headers(custom = {})
|
313
|
+
{ Authorization: "Basic #{options[:auth_token]}" }
|
314
|
+
end
|
257
315
|
end
|
258
316
|
end
|
259
317
|
end
|
data/lib/nexio_activemerchant.rb
CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = NexioActivemerchant::VERSION
|
8
8
|
spec.authors = %w[Whitespectre]
|
9
9
|
spec.email = %w[hello@whitespectre.com]
|
10
|
+
spec.licenses = %w[MIT]
|
10
11
|
|
11
12
|
spec.summary = 'ActiveMechant gateway for Nexio'
|
12
13
|
spec.homepage = 'https://github.com/whitespectre/nexio_activemerchant'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexio_activemerchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Whitespectre
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- ".travis.yml"
|
52
52
|
- CHANGELOG
|
53
53
|
- Gemfile
|
54
|
+
- LICENSE
|
54
55
|
- README.md
|
55
56
|
- Rakefile
|
56
57
|
- bin/console
|
@@ -61,7 +62,8 @@ files:
|
|
61
62
|
- lib/nexio_activemerchant/version.rb
|
62
63
|
- nexio_activemerchant.gemspec
|
63
64
|
homepage: https://github.com/whitespectre/nexio_activemerchant
|
64
|
-
licenses:
|
65
|
+
licenses:
|
66
|
+
- MIT
|
65
67
|
metadata:
|
66
68
|
homepage_uri: https://github.com/whitespectre/nexio_activemerchant
|
67
69
|
source_code_uri: https://github.com/whitespectre/nexio_activemerchant
|