nexio_activemerchant 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/lib/active_merchant/billing/encrypted_nexio_card.rb +1 -1
- data/lib/active_merchant/billing/gateways/nexio_apm_gateway.rb +7 -5
- data/lib/active_merchant/billing/gateways/nexio_base_gateway.rb +18 -8
- data/lib/active_merchant/billing/gateways/nexio_gateway.rb +4 -7
- data/lib/nexio_activemerchant/transaction.rb +13 -0
- data/lib/nexio_activemerchant/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aed1e22c05eb961b28f55d0576219532c0b4077ed15f86bf39e33a45f59a42de
|
4
|
+
data.tar.gz: c9729141380772a443e1aca9bed8c88ce76c206dd46b834a9342499f242a3ea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f8bb6a1e812b6f303a269908f997fd50ce308b219b956dceb74aadeb0f1b03d4f5b319d89af7125552d231b4ae24ae1b3624c6328a8fb0f608d367267f030e0
|
7
|
+
data.tar.gz: 88a4222587961c5a8d7d10c15c104aa2a75132e9425e8de7d3be64b9c0264c16fb5625ad0cea1dd8db52b58f7ddcfb7715a7ac044e06643eef36a9a640685440
|
data/.rubocop.yml
CHANGED
@@ -11,6 +11,10 @@
|
|
11
11
|
|
12
12
|
Gemspec/RequiredRubyVersion:
|
13
13
|
Enabled: false
|
14
|
+
Metrics/AbcSize:
|
15
|
+
Enabled: false
|
16
|
+
Metrics/CyclomaticComplexity:
|
17
|
+
Enabled: false
|
14
18
|
Metrics/ClassLength:
|
15
19
|
Enabled: false
|
16
20
|
Metrics/MethodLength:
|
@@ -19,3 +23,5 @@ Lint/AssignmentInCondition:
|
|
19
23
|
Enabled: false
|
20
24
|
Style/GuardClause:
|
21
25
|
Enabled: false
|
26
|
+
Style/Documentation:
|
27
|
+
Enabled: false
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ActiveMerchant
|
4
4
|
module Billing
|
5
5
|
class EncryptedNexioCard < CreditCard
|
6
|
-
ALLOWED_CARD_BRANDS = %w
|
6
|
+
ALLOWED_CARD_BRANDS = %w[amex discover jcb mastercard visa].freeze
|
7
7
|
|
8
8
|
attr_accessor :encrypted_number, :own_form, :one_time_token
|
9
9
|
|
@@ -18,6 +18,7 @@ module ActiveMerchant
|
|
18
18
|
add_order_data(post, options)
|
19
19
|
post[:customerRedirectUrl] = options[:callback_url] if options[:callback_url].present?
|
20
20
|
post[:processingOptions][:saveRecurringToken] = true if options[:save_token]
|
21
|
+
post[:isAuthOnly] = true if options[:is_auth_only]
|
21
22
|
resp = commit('token', post)
|
22
23
|
return unless resp.success?
|
23
24
|
|
@@ -32,15 +33,16 @@ module ActiveMerchant
|
|
32
33
|
def purchase(money, payment, options = {})
|
33
34
|
post = build_payload(options)
|
34
35
|
add_invoice(post, money, options)
|
35
|
-
|
36
|
-
post[:apm] = { token: payment.gateway_payment_profile_id }
|
37
|
-
else
|
38
|
-
post[:apm] = { token: payment }
|
39
|
-
end
|
36
|
+
post[:apm] = { token: payment.is_a?(Spree::PaymentSource) ? payment.gateway_payment_profile_id : payment }
|
40
37
|
add_order_data(post, options)
|
38
|
+
post[:isAuthOnly] = true if options[:is_auth_only]
|
41
39
|
commit('process', post)
|
42
40
|
end
|
43
41
|
|
42
|
+
def authorize(money, payment, options = {})
|
43
|
+
purchase(money, payment, options.merge(is_auth_only: true))
|
44
|
+
end
|
45
|
+
|
44
46
|
private
|
45
47
|
|
46
48
|
def map_urls(list)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'json'
|
4
|
+
require 'nexio_activemerchant/transaction'
|
4
5
|
|
5
6
|
module ActiveMerchant
|
6
7
|
module Billing
|
@@ -43,7 +44,7 @@ module ActiveMerchant
|
|
43
44
|
transcript
|
44
45
|
end
|
45
46
|
|
46
|
-
def
|
47
|
+
def setup_webhooks(data)
|
47
48
|
post = { merchantId: options[:merchant_id].to_s }
|
48
49
|
if data.is_a?(String)
|
49
50
|
post[:webhooks] = {
|
@@ -65,6 +66,13 @@ module ActiveMerchant
|
|
65
66
|
commit('secret', { merchantId: options[:merchant_id].to_s }).params['secret']
|
66
67
|
end
|
67
68
|
|
69
|
+
def get_transaction(id)
|
70
|
+
data = parse(ssl_get(action_url("/transaction/v3/paymentId/#{id}"), base_headers))
|
71
|
+
::NexioActivemerchant::Transaction.new(data)
|
72
|
+
rescue ResponseError
|
73
|
+
nil
|
74
|
+
end
|
75
|
+
|
68
76
|
private
|
69
77
|
|
70
78
|
def build_payload(params)
|
@@ -176,11 +184,11 @@ module ActiveMerchant
|
|
176
184
|
|
177
185
|
def commit_action_url(action, _parameters)
|
178
186
|
path = case action
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
187
|
+
when 'webhook' then '/webhook/v3/config'
|
188
|
+
when 'secret' then '/webhook/v3/secret'
|
189
|
+
else
|
190
|
+
"#{self.class.base_path}/#{action}"
|
191
|
+
end
|
184
192
|
action_url(path)
|
185
193
|
end
|
186
194
|
|
@@ -189,12 +197,14 @@ module ActiveMerchant
|
|
189
197
|
end
|
190
198
|
|
191
199
|
def base_headers(custom = {})
|
192
|
-
{ Authorization: "Basic #{options[:auth_token]}" }
|
200
|
+
{ Authorization: "Basic #{options[:auth_token]}" }.merge(custom)
|
193
201
|
end
|
194
202
|
|
203
|
+
SUCCESS_PROCESS_STATUSES = %w[authOnlyPending authorizedPending pending authOnly settled].freeze
|
204
|
+
|
195
205
|
def response_status(action, payload)
|
196
206
|
case action
|
197
|
-
when 'process' then
|
207
|
+
when 'process' then SUCCESS_PROCESS_STATUSES.include?(payload['transactionStatus'])
|
198
208
|
else
|
199
209
|
true
|
200
210
|
end
|
@@ -13,7 +13,7 @@ module ActiveMerchant
|
|
13
13
|
|
14
14
|
def generate_token(options = {})
|
15
15
|
post = build_payload(options)
|
16
|
-
post[:data][:allowedCardTypes] = %w
|
16
|
+
post[:data][:allowedCardTypes] = %w[amex discover jcb mastercard visa]
|
17
17
|
add_currency(post, options)
|
18
18
|
add_order_data(post, options)
|
19
19
|
add_card_data(post, options)
|
@@ -55,11 +55,6 @@ module ActiveMerchant
|
|
55
55
|
resp.params.fetch('token', {}).fetch('token', nil)
|
56
56
|
end
|
57
57
|
|
58
|
-
def get_transaction(id)
|
59
|
-
parse(ssl_get(action_url("/transaction/v3/paymentId/#{id}"), base_headers))
|
60
|
-
rescue ResponseError => e
|
61
|
-
end
|
62
|
-
|
63
58
|
private
|
64
59
|
|
65
60
|
def add_payment(post, payment, options)
|
@@ -71,7 +66,9 @@ module ActiveMerchant
|
|
71
66
|
}.merge!(post.fetch(:card, {}))
|
72
67
|
end
|
73
68
|
post[:processingOptions][:saveCardToken] = options[:save_credit_card] if options.key?(:save_credit_card)
|
74
|
-
|
69
|
+
if options[:three_d_callback_url].present?
|
70
|
+
post[:processingOptions][:customerRedirectUrl] = options[:three_d_callback_url]
|
71
|
+
end
|
75
72
|
post[:processingOptions][:check3ds] = options[:three_d_secure]
|
76
73
|
post[:processingOptions][:paymentType] = options[:payment_type] if options[:payment_type].present?
|
77
74
|
end
|
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.3.
|
4
|
+
version: 0.3.1
|
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-
|
11
|
+
date: 2021-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/active_merchant/billing/gateways/nexio_base_gateway.rb
|
62
62
|
- lib/active_merchant/billing/gateways/nexio_gateway.rb
|
63
63
|
- lib/nexio_activemerchant.rb
|
64
|
+
- lib/nexio_activemerchant/transaction.rb
|
64
65
|
- lib/nexio_activemerchant/version.rb
|
65
66
|
- nexio_activemerchant.gemspec
|
66
67
|
homepage: https://github.com/whitespectre/nexio_activemerchant
|