nexio_activemerchant 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04b87b2ac1b4c597f9317e421d181f22e5664d9086d1d4e257c65ab9dfb7a14
|
4
|
+
data.tar.gz: 62d6982b454d32c4416127656b7505c8ab3b3395e93af51d584c7dfbeb0fae58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2fd9ba7715e2e9bed79bf6a3632ac483f7cb415b1854057137fa2d1f92c2fc9bd87b272af1d03df44eee8950b0c75e6e646527d256367eafe14aa3bdb67f0e9
|
7
|
+
data.tar.gz: 8f51de8cba7f9acb2cb489c07363246e1e5abcc1a57e71dfd559e81dcc2e6b1c9d84c7e28fe96a4baa9c1a3c36163b4bec4d1c5051f3b65a378af36f41526337
|
@@ -40,6 +40,8 @@ module ActiveMerchant
|
|
40
40
|
post = build_payload(options)
|
41
41
|
post[:processingOptions] ||= {}
|
42
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]
|
43
45
|
add_invoice(post, money, options)
|
44
46
|
add_payment(post, payment, options)
|
45
47
|
add_order_data(post, options)
|
@@ -89,6 +91,26 @@ module ActiveMerchant
|
|
89
91
|
resp.params.fetch('token', {}).fetch('token', nil)
|
90
92
|
end
|
91
93
|
|
94
|
+
def set_webhooks(data)
|
95
|
+
post = { merchantId: options[:merchant_id].to_s }
|
96
|
+
if data.is_a?(String)
|
97
|
+
post[:webhooks] = {
|
98
|
+
TRANSACTION_AUTHORIZED: { url: data },
|
99
|
+
TRANSACTION_CAPTURED: { url: data }
|
100
|
+
}
|
101
|
+
else
|
102
|
+
webhooks = {}
|
103
|
+
webhooks[:TRANSACTION_AUTHORIZED] = { url: data[:authorized] } if data.key?(:authorized)
|
104
|
+
webhooks[:TRANSACTION_CAPTURED] = { url: data[:captured] } if data.key?(:captured)
|
105
|
+
post[:webhooks] = webhooks
|
106
|
+
end
|
107
|
+
commit('webhook', post)
|
108
|
+
end
|
109
|
+
|
110
|
+
def set_secret
|
111
|
+
commit('secret', { merchantId: options[:merchant_id].to_s }).params['secret']
|
112
|
+
end
|
113
|
+
|
92
114
|
private
|
93
115
|
|
94
116
|
def add_invoice(post, money, options)
|
@@ -156,6 +178,12 @@ module ActiveMerchant
|
|
156
178
|
|
157
179
|
def add_payment(post, payment, options)
|
158
180
|
post[:tokenex] = token_from(payment)
|
181
|
+
if payment.is_a?(Spree::CreditCard)
|
182
|
+
post[:card] = {
|
183
|
+
cardHolderName: payment.name,
|
184
|
+
cardType: payment.brand
|
185
|
+
}
|
186
|
+
end
|
159
187
|
post[:processingOptions] ||= {}
|
160
188
|
post[:processingOptions][:merchantId] = self.options[:merchant_id].to_s
|
161
189
|
post[:processingOptions][:saveCardToken] = options[:save_credit_card] if options.key?(:save_credit_card)
|
@@ -166,7 +194,8 @@ module ActiveMerchant
|
|
166
194
|
|
167
195
|
{
|
168
196
|
token: payment.gateway_payment_profile_id,
|
169
|
-
lastFour: payment.last_digits
|
197
|
+
lastFour: payment.last_digits,
|
198
|
+
cardType: payment.brand
|
170
199
|
}
|
171
200
|
end
|
172
201
|
|
@@ -205,11 +234,11 @@ module ActiveMerchant
|
|
205
234
|
end
|
206
235
|
|
207
236
|
def commit(action, parameters)
|
208
|
-
payload = parse(ssl_post(
|
209
|
-
|
237
|
+
payload = parse(ssl_post(commit_action_url(action, parameters), post_data(action, parameters),
|
238
|
+
Authorization: "Basic #{options[:auth_token]}"))
|
210
239
|
|
211
240
|
Response.new(
|
212
|
-
|
241
|
+
response_status(action, payload),
|
213
242
|
nil,
|
214
243
|
payload,
|
215
244
|
authorization: authorization_from(payload),
|
@@ -229,6 +258,14 @@ module ActiveMerchant
|
|
229
258
|
)
|
230
259
|
end
|
231
260
|
|
261
|
+
def response_status(action, payload)
|
262
|
+
case action
|
263
|
+
when 'process' then authorization_from(payload).present?
|
264
|
+
else
|
265
|
+
true
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
232
269
|
def authorization_from(payload)
|
233
270
|
payload.fetch('id', nil)
|
234
271
|
end
|
@@ -237,8 +274,13 @@ module ActiveMerchant
|
|
237
274
|
parameters.to_json
|
238
275
|
end
|
239
276
|
|
240
|
-
def
|
241
|
-
path =
|
277
|
+
def commit_action_url(action, _parameters)
|
278
|
+
path = case action
|
279
|
+
when 'webhook' then '/webhook/v3/config'
|
280
|
+
when 'secret' then '/webhook/v3/secret'
|
281
|
+
else
|
282
|
+
"/pay/v3/#{action}"
|
283
|
+
end
|
242
284
|
"#{test? ? test_url : live_url}#{path}"
|
243
285
|
end
|
244
286
|
|
data/lib/nexio_activemerchant.rb
CHANGED
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.0
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|