nexio_activemerchant 0.2.3 → 0.2.7

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: aa463661c8db5f5568825ac31a6bd4c42d5997bd4df1fef6f7afb92f0d72501a
4
- data.tar.gz: 33e492999b3bdd59a53d764ef1d4e0ba46d7ada66e16b89a378b2c891139d73c
3
+ metadata.gz: '09b41171285a1391d8d99233c196e387bc1822c3efdbb8187eb8422764f1beae'
4
+ data.tar.gz: 85f11b3a8a146594f3f0919a1f8b3aa2a6a5415c342b541931acea748ce81c94
5
5
  SHA512:
6
- metadata.gz: 9815bde8e3cf49027550eb1bfe25f112ed17e1fb2e557c6ec14ddff479a1ad66ad01c95eef099988d611e106bc770f4c952754bdf570412c1cb496a8366d82b0
7
- data.tar.gz: ce430b0a30c7608a97a3377a80eff3bf5a67b3116e00066b616213abb7aa2e85d3d6c7009c3f65547a06014cea5ebb3abc9123a0f2a763087f82d68c6ab60a16
6
+ metadata.gz: '094f7c5d9058ef1ceb7ed58fc77f217c0190175a64f75a24027909d75003b3bd4b7da8812a3b972b62b864e5f123e63c38129856ad74f0d5483592cc803377c0'
7
+ data.tar.gz: b82b1e74e01c35752e1f64e4949ccb038b841d62e32686590a58e3aba1ee2dd6959883fda3d0e9a7529130b86b216419f3983ee1b3ade95b0b93b18500a3fcae
@@ -3,6 +3,8 @@
3
3
  module ActiveMerchant
4
4
  module Billing
5
5
  class EncryptedNexioCard < CreditCard
6
+ ALLOWED_CARD_BRANDS = %w(amex discover jcb mastercard visa).freeze
7
+
6
8
  attr_accessor :encrypted_number, :own_form, :one_time_token
7
9
 
8
10
  attr_reader :brand
@@ -18,7 +20,7 @@ module ActiveMerchant
18
20
 
19
21
  if empty?(brand)
20
22
  errors << [:brand, 'is required'] if own_form
21
- elsif !self.class.card_companies.include?(brand)
23
+ elsif !ALLOWED_CARD_BRANDS.include?(brand)
22
24
  errors << [:brand, 'is invalid']
23
25
  end
24
26
 
@@ -26,6 +26,7 @@ module ActiveMerchant
26
26
 
27
27
  def generate_token(options = {})
28
28
  post = build_payload(options)
29
+ post[:data][:allowedCardTypes] = %w(amex discover jcb mastercard visa)
29
30
  add_currency(post, options)
30
31
  add_order_data(post, options)
31
32
  add_card_data(post, options)
@@ -171,15 +172,12 @@ module ActiveMerchant
171
172
  def add_address(post, data, prefix)
172
173
  return post if data.blank?
173
174
 
174
- post[:data][:customer].merge!({
175
- "#{prefix}AddressOne": data[:address1],
176
- "#{prefix}AddressTwo": data[:address2],
177
- "#{prefix}City": data[:city],
178
- "#{prefix}Country": data[:country],
179
- "#{prefix}Phone": data[:phone],
180
- "#{prefix}Postal": data[:zip],
181
- "#{prefix}State": data[:state]
182
- })
175
+ {
176
+ AddressOne: :address1, AddressTwo: :address2, City: :city,
177
+ Country: :country, Phone: :phone, Postal: :zip, State: :state
178
+ }.each do |suffix, key|
179
+ post[:data][:customer]["#{prefix}#{suffix}"] = data[key] if data[key].present?
180
+ end
183
181
  end
184
182
 
185
183
  def add_payment(post, payment, options)
@@ -188,7 +186,7 @@ module ActiveMerchant
188
186
  post[:card] = {
189
187
  cardHolderName: payment.name,
190
188
  cardType: payment.brand
191
- }
189
+ }.merge!(post.fetch(:card, {}))
192
190
  end
193
191
  post[:processingOptions] ||= {}
194
192
  post[:processingOptions][:merchantId] = self.options[:merchant_id].to_s
@@ -253,6 +251,7 @@ module ActiveMerchant
253
251
  network_transaction_id: payload['id']
254
252
  )
255
253
  rescue ResponseError => e
254
+ logger&.error e.response.body
256
255
  error_payload = parse(e.response.body)
257
256
  Response.new(
258
257
  false,
@@ -276,7 +275,7 @@ module ActiveMerchant
276
275
  end
277
276
 
278
277
  def post_data(_action, parameters = {})
279
- parameters.to_json
278
+ { merchantId: options[:merchant_id] }.merge(parameters).to_json
280
279
  end
281
280
 
282
281
  def commit_action_url(action, _parameters)
@@ -305,8 +304,8 @@ module ActiveMerchant
305
304
  CVVResult.new(data.fetch('gatewayMessage', {}).fetch('cvvresponse', nil))
306
305
  end
307
306
 
308
- def build_payload(options)
309
- { data: { customer: {} } }.merge!(options.fetch(:payload, {}))
307
+ def build_payload(params)
308
+ { data: { customer: {} } }.merge!(params.fetch(:payload, {}))
310
309
  end
311
310
 
312
311
  def base_headers(custom = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NexioActivemerchant
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.7'
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.2.3
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Whitespectre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-11 00:00:00.000000000 Z
11
+ date: 2021-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant