nexio_activemerchant 0.2.2 → 0.2.6

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: 3fee4e8586b27556107241251a935bdc43ed0a5a6071511a0307b3c2542d891f
4
- data.tar.gz: 8adc6b9e898e8b41016f380854c0450f31b21e033134e921f97e8d63d7f47886
3
+ metadata.gz: c71ca2a7f93f4b56d210272254bb2e5b42f21971a67dcdb4577b7676aeb77963
4
+ data.tar.gz: 438164011b498f1d97be2d03e41ddfb5cd5d92c06ef66aa65cfdf7def2baafc9
5
5
  SHA512:
6
- metadata.gz: 6dcf35fb8da06141ed952109bccd03fdbb885325237210b2d17fa22291708e17b3ce3e0bcb330b8d8d5a447d11b7a87dd35c26851572f0115515c2c1e60b76d4
7
- data.tar.gz: 4b1421517e5a04defdd269948cd6a72de85a8c90589a00fd3ca39ba02b892abd753aa119f7fffb7f9aeb48c8553111fb98b36e89414326c5ba79702a0493fbcc
6
+ metadata.gz: fbcaea369894ec54d50b0aab65cdfa66fd17c97febbeaadd80b07a6c3b7165e97728a115eecfd60d144c0aefc030682fb6d5331946db14129f966636eb584f8f
7
+ data.tar.gz: 418c3d334030134e369d897ac2a4a09b7226af458cc6972b2f90d0de1201250614baecc94b06a3f657ab4c6a52e4fdd5c287a8ef2c4a0f86f0bd62c23ca2d91d
@@ -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)
@@ -125,7 +126,7 @@ module ActiveMerchant
125
126
  end
126
127
 
127
128
  def add_currency(post, options)
128
- post[:data][:currency] = options[:currency] || currency(money)
129
+ post[:data][:currency] = options[:currency] if options.key?(:currency)
129
130
  end
130
131
 
131
132
  def add_order_data(post, options)
@@ -188,7 +189,7 @@ module ActiveMerchant
188
189
  post[:card] = {
189
190
  cardHolderName: payment.name,
190
191
  cardType: payment.brand
191
- }
192
+ }.merge!(post.fetch(:card, {}))
192
193
  end
193
194
  post[:processingOptions] ||= {}
194
195
  post[:processingOptions][:merchantId] = self.options[:merchant_id].to_s
@@ -253,6 +254,7 @@ module ActiveMerchant
253
254
  network_transaction_id: payload['id']
254
255
  )
255
256
  rescue ResponseError => e
257
+ logger&.error e.response.body
256
258
  error_payload = parse(e.response.body)
257
259
  Response.new(
258
260
  false,
@@ -276,7 +278,7 @@ module ActiveMerchant
276
278
  end
277
279
 
278
280
  def post_data(_action, parameters = {})
279
- parameters.to_json
281
+ { merchantId: options[:merchant_id] }.merge(parameters).to_json
280
282
  end
281
283
 
282
284
  def commit_action_url(action, _parameters)
@@ -305,8 +307,8 @@ module ActiveMerchant
305
307
  CVVResult.new(data.fetch('gatewayMessage', {}).fetch('cvvresponse', nil))
306
308
  end
307
309
 
308
- def build_payload(options)
309
- { data: { customer: {} } }.merge!(options.fetch(:payload, {}))
310
+ def build_payload(params)
311
+ { data: { customer: {} } }.merge!(params.fetch(:payload, {}))
310
312
  end
311
313
 
312
314
  def base_headers(custom = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NexioActivemerchant
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.6'
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.2
4
+ version: 0.2.6
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-06 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