nexio_activemerchant 0.4.0 → 0.4.1

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: 8267f1055cb04161ae87bca490199fbaf4ab95a67eb0232b956590fa87cfb0e0
4
+ data.tar.gz: 24984f56bd8933454549c8eadacfc1df478e72beeb083d2f0ea542fc2076b59d
5
5
  SHA512:
6
- metadata.gz: 395afe852039e7b35d972a2230e52cd77c938bb94ccb44f49cf14fff5734636cc5a7c4885d37d07b21d82fb67fe174cfb020611190ffd953ebb7e6cb8296bca0
7
- data.tar.gz: 03651caa2f01c34336ac9f66e4c577c191b77dae6fe4f0f536f7801a066669c181c1cd86c0909a0ae29f8e1d8a92641d4eed9cd8ac0b52bf9dc43850577ed58b
6
+ metadata.gz: b888126145cc8f56083f141b46c11b4a865722a713e655381c06205268559783facc7f78f62df2098ff9cb9bc7ca41c3fc668742aeaab94635265e746c6680d4
7
+ data.tar.gz: 89a14ea14571922157ec962c845ae9c0b254e63085fd4ab4763c5d0d98a20970789901c226c444935b82eb89b835e74f6175e005910d7f3c38df5e7efba95d94
@@ -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.1'
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.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-10 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant