nexio_activemerchant 0.4.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 270866bef6896178cdc8fcae4ae1c2e158bcfdca7106ae24a09d91b7823e15a0
4
- data.tar.gz: d7d76d0a219146a0e8a7f37e68944836e693c1218fd8fad8fd75f4c1ed65b2a9
3
+ metadata.gz: 59dd2e649d9d7366b3b117a7f1b4848a0aed17af38054059c165a85131e64b5e
4
+ data.tar.gz: a2ef3247bc366edc6ff6be8e18a1cc2ce1a09d4943ebdcf9cb9d850778ea4efc
5
5
  SHA512:
6
- metadata.gz: 395afe852039e7b35d972a2230e52cd77c938bb94ccb44f49cf14fff5734636cc5a7c4885d37d07b21d82fb67fe174cfb020611190ffd953ebb7e6cb8296bca0
7
- data.tar.gz: 03651caa2f01c34336ac9f66e4c577c191b77dae6fe4f0f536f7801a066669c181c1cd86c0909a0ae29f8e1d8a92641d4eed9cd8ac0b52bf9dc43850577ed58b
6
+ metadata.gz: aba0211afbdb40d68e3d169e6e1249cbc6fa4435da040a4dbb30783fc93f20bc43c1f436631e35ae03b33ac633d4e8507e9467846638eac2553c71a7b835aa90
7
+ data.tar.gz: 88c3f83b39acb2e7cbe1092bbdb79a21d879e9591d0215ece284343cba89c84240496eca13421dac89ed5f2c89650ea9dc1840dac3b3d141f4b81f017da1c88e
data/.gitignore CHANGED
@@ -7,3 +7,6 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  /Gemfile.lock
10
+
11
+ # RubyMine files
12
+ .idea/
@@ -9,7 +9,7 @@ module ActiveMerchant
9
9
  self.base_path = '/apm/v3'
10
10
  self.abstract_class = false
11
11
 
12
- OneTimeToken = Struct.new(:token, :iframe_url, :redirect_urls, :button_urls)
12
+ OneTimeToken = Struct.new(:token, :iframe_url, :script_url, :redirect_urls, :button_urls)
13
13
 
14
14
  def generate_token(money, options = {})
15
15
  post = build_payload(options)
@@ -25,6 +25,7 @@ module ActiveMerchant
25
25
  OneTimeToken.new(
26
26
  resp.params['token'],
27
27
  resp.params['expressIFrameUrl'],
28
+ resp.params['scriptUrl'],
28
29
  map_urls(resp.params['redirectUrls']),
29
30
  map_urls(resp.params['buttonIFrameUrls'])
30
31
  )
@@ -24,16 +24,16 @@ module ActiveMerchant
24
24
  OneTimeToken.new(token, Time.parse(expiration), fraud_url)
25
25
  end
26
26
 
27
- def purchase(money, payment, options = {})
27
+ def purchase(money, source, options = {})
28
28
  post = build_payload(options)
29
29
  add_invoice(post, money, options)
30
- add_payment(post, payment, options)
30
+ add_payment(post, source, options)
31
31
  add_order_data(post, options)
32
32
  commit('process', post)
33
33
  end
34
34
 
35
- def authorize(money, payment, options = {})
36
- purchase(money, payment, options.merge(payload: options.fetch(:payload, {}).merge(isAuthOnly: true)))
35
+ def authorize(money, source, options = {})
36
+ purchase(money, source, options.merge(payload: options.fetch(:payload, {}).merge(isAuthOnly: true)))
37
37
  end
38
38
 
39
39
  def verify(credit_card, options = {})
@@ -43,10 +43,10 @@ module ActiveMerchant
43
43
  end
44
44
  end
45
45
 
46
- def store(payment, options = {})
46
+ def store(source, options = {})
47
47
  post = build_payload(options)
48
48
  post[:merchantId] ||= options[:merchant_id]
49
- add_card_details(post, payment, options)
49
+ add_card_details(post, source, options)
50
50
  add_currency(post, options)
51
51
  add_order_data(post, options)
52
52
  resp = commit('saveCard', post)
@@ -57,14 +57,14 @@ module ActiveMerchant
57
57
 
58
58
  private
59
59
 
60
- def add_payment(post, payment, options)
61
- post[:tokenex] = token_from(payment)
62
- if payment.is_a?(Spree::CreditCard)
63
- post[:card] = {
64
- cardHolderName: payment.name,
65
- cardType: payment.brand
66
- }.merge!(post.fetch(:card, {}))
60
+ def add_payment(post, source, options)
61
+ post[:tokenex] = token_from(source)
62
+ post[:card] ||= {}
63
+ if source.is_a?(Spree::CreditCard)
64
+ post[:card][:cardHolderName] = source.name
65
+ post[:card][:cardType] = source.brand
67
66
  end
67
+ post[:card][:securityCode] = options.dig(:card, :cvv) if options.dig(:card, :cvv)
68
68
  post[:processingOptions][:saveCardToken] = options[:save_credit_card] if options.key?(:save_credit_card)
69
69
  if options[:three_d_callback_url].present?
70
70
  post[:processingOptions][:customerRedirectUrl] = options[:three_d_callback_url]
@@ -73,23 +73,24 @@ module ActiveMerchant
73
73
  post[:processingOptions][:paymentType] = options[:payment_type] if options[:payment_type].present?
74
74
  end
75
75
 
76
- def token_from(payment)
77
- return { token: payment } if payment.is_a?(String)
76
+ def token_from(source)
77
+ return { token: source } if source.is_a?(String)
78
78
 
79
79
  {
80
- token: payment.gateway_payment_profile_id,
81
- lastFour: payment.last_digits,
82
- cardType: payment.brand
80
+ token: source.gateway_payment_profile_id,
81
+ lastFour: source.last_digits,
82
+ cardType: source.brand
83
83
  }
84
84
  end
85
85
 
86
86
  def add_card_data(post, options)
87
87
  if card = options[:card]
88
- post[:card] = {
88
+ post[:card] ||= {}
89
+ post[:card].merge!(
89
90
  cardHolderName: card[:name],
90
91
  expirationMonth: card[:month],
91
92
  expirationYear: card[:year]
92
- }
93
+ )
93
94
  end
94
95
  end
95
96
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NexioActivemerchant
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.2'
5
5
  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.4.0
4
+ version: 0.4.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-10 00:00:00.000000000 Z
11
+ date: 2023-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.1.2
89
+ rubygems_version: 3.1.6
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: ActiveMechant gateway for Nexio