activemerchant 1.112.0 → 1.118.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +115 -0
  3. data/README.md +1 -1
  4. data/lib/active_merchant.rb +1 -1
  5. data/lib/active_merchant/billing/avs_result.rb +1 -1
  6. data/lib/active_merchant/billing/compatibility.rb +3 -3
  7. data/lib/active_merchant/billing/credit_card.rb +3 -1
  8. data/lib/active_merchant/billing/credit_card_methods.rb +58 -11
  9. data/lib/active_merchant/billing/gateway.rb +1 -1
  10. data/lib/active_merchant/billing/gateways/adyen.rb +26 -16
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +50 -18
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -2
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
  16. data/lib/active_merchant/billing/gateways/balanced.rb +5 -4
  17. data/lib/active_merchant/billing/gateways/bambora_apac.rb +8 -8
  18. data/lib/active_merchant/billing/gateways/bank_frick.rb +8 -8
  19. data/lib/active_merchant/billing/gateways/banwire.rb +1 -1
  20. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +6 -4
  21. data/lib/active_merchant/billing/gateways/beanstream.rb +3 -3
  22. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +4 -5
  23. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -3
  24. data/lib/active_merchant/billing/gateways/blue_snap.rb +85 -23
  25. data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
  26. data/lib/active_merchant/billing/gateways/borgun.rb +12 -12
  27. data/lib/active_merchant/billing/gateways/bpoint.rb +8 -8
  28. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +20 -17
  30. data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -7
  31. data/lib/active_merchant/billing/gateways/cams.rb +8 -8
  32. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
  34. data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/cardknox.rb +8 -8
  36. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  37. data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
  38. data/lib/active_merchant/billing/gateways/cenpos.rb +11 -11
  39. data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
  40. data/lib/active_merchant/billing/gateways/checkout_v2.rb +18 -21
  41. data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
  42. data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
  43. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  44. data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
  45. data/lib/active_merchant/billing/gateways/credorax.rb +32 -15
  46. data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
  47. data/lib/active_merchant/billing/gateways/culqi.rb +10 -10
  48. data/lib/active_merchant/billing/gateways/cyber_source.rb +61 -37
  49. data/lib/active_merchant/billing/gateways/d_local.rb +11 -11
  50. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
  51. data/lib/active_merchant/billing/gateways/decidir.rb +24 -9
  52. data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
  53. data/lib/active_merchant/billing/gateways/digitzs.rb +6 -6
  54. data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
  55. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -4
  56. data/lib/active_merchant/billing/gateways/elavon.rb +279 -227
  57. data/lib/active_merchant/billing/gateways/element.rb +8 -8
  58. data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
  59. data/lib/active_merchant/billing/gateways/eway.rb +3 -4
  60. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
  61. data/lib/active_merchant/billing/gateways/eway_rapid.rb +8 -8
  62. data/lib/active_merchant/billing/gateways/exact.rb +8 -9
  63. data/lib/active_merchant/billing/gateways/ezic.rb +8 -8
  64. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  65. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
  66. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  67. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
  68. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  69. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +21 -10
  70. data/lib/active_merchant/billing/gateways/flo2cash.rb +9 -9
  71. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  72. data/lib/active_merchant/billing/gateways/forte.rb +14 -8
  73. data/lib/active_merchant/billing/gateways/global_collect.rb +29 -10
  74. data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
  75. data/lib/active_merchant/billing/gateways/hdfc.rb +10 -10
  76. data/lib/active_merchant/billing/gateways/hps.rb +17 -14
  77. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  78. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  79. data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
  80. data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
  81. data/lib/active_merchant/billing/gateways/ipp.rb +7 -7
  82. data/lib/active_merchant/billing/gateways/iridium.rb +16 -17
  83. data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
  84. data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
  85. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
  86. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
  87. data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
  88. data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
  89. data/lib/active_merchant/billing/gateways/linkpoint.rb +5 -6
  90. data/lib/active_merchant/billing/gateways/litle.rb +28 -12
  91. data/lib/active_merchant/billing/gateways/mastercard.rb +12 -12
  92. data/lib/active_merchant/billing/gateways/mercado_pago.rb +8 -8
  93. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
  94. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  95. data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
  96. data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
  97. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
  98. data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
  99. data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
  100. data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
  101. data/lib/active_merchant/billing/gateways/migs.rb +3 -4
  102. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
  103. data/lib/active_merchant/billing/gateways/monei.rb +7 -7
  104. data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
  105. data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
  106. data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
  107. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
  108. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
  109. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
  110. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  111. data/lib/active_merchant/billing/gateways/netbanx.rb +12 -10
  112. data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
  113. data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
  114. data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
  115. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  116. data/lib/active_merchant/billing/gateways/omise.rb +13 -13
  117. data/lib/active_merchant/billing/gateways/openpay.rb +4 -5
  118. data/lib/active_merchant/billing/gateways/opp.rb +12 -12
  119. data/lib/active_merchant/billing/gateways/optimal_payment.rb +3 -4
  120. data/lib/active_merchant/billing/gateways/orbital.rb +175 -81
  121. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
  122. data/lib/active_merchant/billing/gateways/pagarme.rb +9 -9
  123. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  124. data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
  125. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
  126. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
  127. data/lib/active_merchant/billing/gateways/pay_junction.rb +4 -5
  128. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
  129. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
  130. data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
  131. data/lib/active_merchant/billing/gateways/payeezy.rb +35 -17
  132. data/lib/active_merchant/billing/gateways/payex.rb +11 -12
  133. data/lib/active_merchant/billing/gateways/payflow.rb +4 -1
  134. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  135. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  136. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -2
  137. data/lib/active_merchant/billing/gateways/paymentez.rb +26 -6
  138. data/lib/active_merchant/billing/gateways/paymill.rb +10 -10
  139. data/lib/active_merchant/billing/gateways/paypal.rb +10 -2
  140. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -0
  141. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
  142. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  143. data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
  144. data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
  145. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  146. data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
  147. data/lib/active_merchant/billing/gateways/payway.rb +8 -9
  148. data/lib/active_merchant/billing/gateways/pin.rb +11 -0
  149. data/lib/active_merchant/billing/gateways/plugnpay.rb +2 -3
  150. data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
  151. data/lib/active_merchant/billing/gateways/psigate.rb +3 -4
  152. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
  153. data/lib/active_merchant/billing/gateways/qbms.rb +4 -5
  154. data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
  155. data/lib/active_merchant/billing/gateways/quickbooks.rb +4 -3
  156. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -4
  157. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -2
  158. data/lib/active_merchant/billing/gateways/qvalent.rb +9 -9
  159. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/redsys.rb +87 -7
  161. data/lib/active_merchant/billing/gateways/s5.rb +7 -7
  162. data/lib/active_merchant/billing/gateways/safe_charge.rb +40 -14
  163. data/lib/active_merchant/billing/gateways/sage.rb +3 -5
  164. data/lib/active_merchant/billing/gateways/sage_pay.rb +6 -7
  165. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  166. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -2
  167. data/lib/active_merchant/billing/gateways/secure_pay.rb +3 -4
  168. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +2 -4
  169. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -2
  170. data/lib/active_merchant/billing/gateways/securion_pay.rb +5 -6
  171. data/lib/active_merchant/billing/gateways/skip_jack.rb +3 -4
  172. data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -6
  173. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +7 -7
  174. data/lib/active_merchant/billing/gateways/spreedly_core.rb +6 -6
  175. data/lib/active_merchant/billing/gateways/stripe.rb +12 -12
  176. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +30 -0
  177. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
  178. data/lib/active_merchant/billing/gateways/telr.rb +9 -9
  179. data/lib/active_merchant/billing/gateways/trans_first.rb +3 -3
  180. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +14 -14
  181. data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
  182. data/lib/active_merchant/billing/gateways/trust_commerce.rb +8 -9
  183. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +36 -36
  185. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +4 -5
  186. data/lib/active_merchant/billing/gateways/vanco.rb +3 -3
  187. data/lib/active_merchant/billing/gateways/verifi.rb +1 -2
  188. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -2
  189. data/lib/active_merchant/billing/gateways/visanet_peru.rb +10 -10
  190. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  191. data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
  192. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
  193. data/lib/active_merchant/billing/gateways/worldpay.rb +18 -10
  194. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
  195. data/lib/active_merchant/billing/gateways/worldpay_us.rb +9 -9
  196. data/lib/active_merchant/billing/response.rb +3 -2
  197. data/lib/active_merchant/country.rb +1 -1
  198. data/lib/active_merchant/network_connection_retries.rb +2 -2
  199. data/lib/active_merchant/post_data.rb +1 -1
  200. data/lib/active_merchant/posts_data.rb +1 -1
  201. data/lib/active_merchant/version.rb +1 -1
  202. data/lib/support/ssl_verify.rb +2 -2
  203. data/lib/support/ssl_version.rb +2 -2
  204. metadata +2 -2
@@ -24,15 +24,15 @@ module ActiveMerchant #:nodoc:
24
24
  'authonly' => 'CC.PA',
25
25
  'capture' => 'CC.CP',
26
26
  'refund' => 'CC.RF',
27
- 'void' => 'CC.RV',
27
+ 'void' => 'CC.RV'
28
28
  }
29
29
 
30
- def initialize(options={})
30
+ def initialize(options = {})
31
31
  requires!(options, :sender, :channel, :userid, :userpwd)
32
32
  super
33
33
  end
34
34
 
35
- def purchase(money, payment, options={})
35
+ def purchase(money, payment, options = {})
36
36
  post = {}
37
37
  add_invoice(post, money, options)
38
38
  add_payment(post, payment)
@@ -42,7 +42,7 @@ module ActiveMerchant #:nodoc:
42
42
  commit('sale', post)
43
43
  end
44
44
 
45
- def authorize(money, payment, options={})
45
+ def authorize(money, payment, options = {})
46
46
  post = {}
47
47
  add_invoice(post, money, options)
48
48
  add_payment(post, payment)
@@ -52,7 +52,7 @@ module ActiveMerchant #:nodoc:
52
52
  commit('authonly', post)
53
53
  end
54
54
 
55
- def capture(money, authorization, options={})
55
+ def capture(money, authorization, options = {})
56
56
  post = {}
57
57
  post[:authorization] = authorization
58
58
  add_invoice(post, money, options)
@@ -60,7 +60,7 @@ module ActiveMerchant #:nodoc:
60
60
  commit('capture', post)
61
61
  end
62
62
 
63
- def refund(money, authorization, options={})
63
+ def refund(money, authorization, options = {})
64
64
  post = {}
65
65
  post[:authorization] = authorization
66
66
  add_invoice(post, money, options)
@@ -68,14 +68,14 @@ module ActiveMerchant #:nodoc:
68
68
  commit('refund', post)
69
69
  end
70
70
 
71
- def void(authorization, options={})
71
+ def void(authorization, options = {})
72
72
  post = {}
73
73
  post[:authorization] = authorization
74
74
 
75
75
  commit('void', post)
76
76
  end
77
77
 
78
- def verify(credit_card, options={})
78
+ def verify(credit_card, options = {})
79
79
  MultiResponse.run(:use_first_response) do |r|
80
80
  r.process { authorize(100, credit_card, options) }
81
81
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -74,7 +74,7 @@ module ActiveMerchant #:nodoc:
74
74
 
75
75
  def card_brand(card)
76
76
  brand = super
77
- ({'master' => 'mastercard', 'american_express' => 'amex'}[brand] || brand)
77
+ ({ 'master' => 'mastercard', 'american_express' => 'amex' }[brand] || brand)
78
78
  end
79
79
 
80
80
  def parse(body)
@@ -71,21 +71,23 @@ module ActiveMerchant #:nodoc:
71
71
  post[:shopperName] = options[:shopper_name] if options[:shopper_name]
72
72
 
73
73
  if options[:third_party_payout]
74
- post[:recurring] = options[:recurring_contract] || {contract: 'PAYOUT'}
74
+ post[:recurring] = options[:recurring_contract] || { contract: 'PAYOUT' }
75
75
  MultiResponse.run do |r|
76
76
  r.process {
77
77
  commit(
78
78
  'storeDetailAndSubmitThirdParty',
79
79
  post,
80
80
  @options[:store_payout_account],
81
- @options[:store_payout_password])
81
+ @options[:store_payout_password]
82
+ )
82
83
  }
83
84
  r.process {
84
85
  commit(
85
86
  'confirmThirdParty',
86
87
  modification_request(r.authorization, @options),
87
88
  @options[:review_payout_account],
88
- @options[:review_payout_password])
89
+ @options[:review_payout_password]
90
+ )
89
91
  }
90
92
  end
91
93
  else
@@ -108,7 +110,7 @@ module ActiveMerchant #:nodoc:
108
110
  def store(creditcard, options = {})
109
111
  post = store_request(options)
110
112
  post[:card] = credit_card_hash(creditcard)
111
- post[:recurring] = {contract: 'RECURRING'}
113
+ post[:recurring] = { contract: 'RECURRING' }
112
114
 
113
115
  commit('store', post)
114
116
  end
@@ -104,7 +104,7 @@ module ActiveMerchant #:nodoc:
104
104
  end
105
105
  end
106
106
 
107
- def verify(source, options={})
107
+ def verify(source, options = {})
108
108
  MultiResponse.run(:use_first_response) do |r|
109
109
  r.process { authorize(100, source, options) }
110
110
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -175,10 +175,10 @@ module ActiveMerchant #:nodoc:
175
175
  # can't actually delete a secure profile with the supplicated API. This function sets the status of the profile to closed (C).
176
176
  # Closed profiles will have to removed manually.
177
177
  def delete(vault_id)
178
- update(vault_id, false, {status: 'C'})
178
+ update(vault_id, false, { status: 'C' })
179
179
  end
180
180
 
181
- alias_method :unstore, :delete
181
+ alias unstore delete
182
182
 
183
183
  # Update the values (such as CC expiration) stored at
184
184
  # the gateway. The CC number must be supplied in the
@@ -410,15 +410,14 @@ module ActiveMerchant #:nodoc:
410
410
  recurring_post(post_data(params, false))
411
411
  end
412
412
 
413
- def post(data, use_profile_api=nil)
413
+ def post(data, use_profile_api = nil)
414
414
  response = parse(ssl_post((use_profile_api ? SECURE_PROFILE_URL : self.live_url), data))
415
415
  response[:customer_vault_id] = response[:customerCode] if response[:customerCode]
416
416
  build_response(success?(response), message_from(response), response,
417
417
  test: test? || response[:authCode] == 'TEST',
418
418
  authorization: authorization_from(response),
419
419
  cvv_result: CVD_CODES[response[:cvdId]],
420
- avs_result: { code: AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] }
421
- )
420
+ avs_result: { code: AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] })
422
421
  end
423
422
 
424
423
  def recurring_post(data)
@@ -443,7 +442,7 @@ module ActiveMerchant #:nodoc:
443
442
  end
444
443
 
445
444
  def add_source(post, source)
446
- if source.is_a?(String) or source.is_a?(Integer)
445
+ if source.is_a?(String) || source.is_a?(Integer)
447
446
  post[:customerCode] = source
448
447
  else
449
448
  card_brand(source) == 'check' ? add_check(post, source) : add_credit_card(post, source)
@@ -468,7 +467,7 @@ module ActiveMerchant #:nodoc:
468
467
  params[:vbvEnabled] = '0'
469
468
  params[:scEnabled] = '0'
470
469
 
471
- params.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
470
+ params.reject { |_k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
472
471
  end
473
472
  end
474
473
  end
@@ -332,7 +332,7 @@ module ActiveMerchant #:nodoc:
332
332
  parse(ssl_post(url, post_data(action, fields)))
333
333
  end
334
334
 
335
- def parse_recurring(response_fields, opts={}) # expected status?
335
+ def parse_recurring(response_fields, opts = {}) # expected status?
336
336
  parsed = {}
337
337
  response_fields.each do |k, v|
338
338
  mapped_key = REBILL_FIELD_MAP.include?(k) ? REBILL_FIELD_MAP[k] : k
@@ -366,8 +366,7 @@ module ActiveMerchant #:nodoc:
366
366
  test: test?,
367
367
  authorization: (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
368
368
  avs_result: { code: parsed[:avs_result_code] },
369
- cvv_result: parsed[:card_code]
370
- )
369
+ cvv_result: parsed[:card_code])
371
370
  end
372
371
 
373
372
  def message_from(parsed)
@@ -58,7 +58,7 @@ module ActiveMerchant
58
58
  'line1: N, zip: M, name: N' => 'W',
59
59
  'line1: N, zip: N, name: U' => 'N',
60
60
  'line1: N, zip: N, name: M' => 'K',
61
- 'line1: N, zip: N, name: N' => 'N',
61
+ 'line1: N, zip: N, name: N' => 'N'
62
62
  }
63
63
 
64
64
  BANK_ACCOUNT_TYPE_MAPPING = {
@@ -70,12 +70,12 @@ module ActiveMerchant
70
70
 
71
71
  STATE_CODE_COUNTRIES = %w(US CA)
72
72
 
73
- def initialize(options={})
73
+ def initialize(options = {})
74
74
  requires!(options, :api_username, :api_password)
75
75
  super
76
76
  end
77
77
 
78
- def purchase(money, payment_method, options={})
78
+ def purchase(money, payment_method, options = {})
79
79
  payment_method_details = PaymentMethodDetails.new(payment_method)
80
80
 
81
81
  commit(:purchase, :post, payment_method_details) do |doc|
@@ -87,13 +87,13 @@ module ActiveMerchant
87
87
  end
88
88
  end
89
89
 
90
- def authorize(money, payment_method, options={})
90
+ def authorize(money, payment_method, options = {})
91
91
  commit(:authorize) do |doc|
92
92
  add_auth_purchase(doc, money, payment_method, options)
93
93
  end
94
94
  end
95
95
 
96
- def capture(money, authorization, options={})
96
+ def capture(money, authorization, options = {})
97
97
  commit(:capture, :put) do |doc|
98
98
  add_authorization(doc, authorization)
99
99
  add_order(doc, options)
@@ -101,7 +101,7 @@ module ActiveMerchant
101
101
  end
102
102
  end
103
103
 
104
- def refund(money, authorization, options={})
104
+ def refund(money, authorization, options = {})
105
105
  commit(:refund, :put) do |doc|
106
106
  add_authorization(doc, authorization)
107
107
  add_amount(doc, money, options)
@@ -109,14 +109,14 @@ module ActiveMerchant
109
109
  end
110
110
  end
111
111
 
112
- def void(authorization, options={})
112
+ def void(authorization, options = {})
113
113
  commit(:void, :put) do |doc|
114
114
  add_authorization(doc, authorization)
115
115
  add_order(doc, options)
116
116
  end
117
117
  end
118
118
 
119
- def verify(payment_method, options={})
119
+ def verify(payment_method, options = {})
120
120
  authorize(0, payment_method, options)
121
121
  end
122
122
 
@@ -177,7 +177,7 @@ module ActiveMerchant
177
177
  add_order(doc, options)
178
178
  doc.send('store-card', options[:store_card] || false)
179
179
  add_amount(doc, money, options)
180
- add_fraud_info(doc, options)
180
+ add_fraud_info(doc, payment_method, options)
181
181
 
182
182
  if payment_method.is_a?(String)
183
183
  doc.send('vaulted-shopper-id', payment_method)
@@ -200,6 +200,7 @@ module ActiveMerchant
200
200
  doc.send('last-name', payment_method.last_name)
201
201
  doc.send('personal-identification-number', options[:personal_identification_number]) if options[:personal_identification_number]
202
202
  doc.email(options[:email]) if options[:email]
203
+ doc.phone(options[:phone_number]) if options[:phone_number]
203
204
  add_address(doc, options)
204
205
  end
205
206
 
@@ -212,12 +213,28 @@ module ActiveMerchant
212
213
  end
213
214
  end
214
215
 
215
- def add_description(doc, description)
216
+ def add_metadata(doc, options)
217
+ transaction_meta_data = options[:transaction_meta_data] || []
218
+ return if transaction_meta_data.empty? && !options[:description]
219
+
216
220
  doc.send('transaction-meta-data') do
217
- doc.send('meta-data') do
218
- doc.send('meta-key', 'description')
219
- doc.send('meta-value', truncate(description, 500))
220
- doc.send('meta-description', 'Description')
221
+ # ensure backwards compatibility for calls expecting :description
222
+ # to become meta-data fields.
223
+ if options[:description]
224
+ doc.send('meta-data') do
225
+ doc.send('meta-key', 'description')
226
+ doc.send('meta-value', truncate(options[:description], 500))
227
+ doc.send('meta-description', 'Description')
228
+ end
229
+ end
230
+
231
+ # https://developers.bluesnap.com/v8976-XML/docs/meta-data
232
+ transaction_meta_data.each do |entry|
233
+ doc.send('meta-data') do
234
+ doc.send('meta-key', truncate(entry[:meta_key], 40))
235
+ doc.send('meta-value', truncate(entry[:meta_value], 500))
236
+ doc.send('meta-description', truncate(entry[:meta_description], 40))
237
+ end
221
238
  end
222
239
  end
223
240
  end
@@ -225,7 +242,7 @@ module ActiveMerchant
225
242
  def add_order(doc, options)
226
243
  doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
227
244
  doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
228
- add_description(doc, options[:description]) if options[:description]
245
+ add_metadata(doc, options)
229
246
  add_3ds(doc, options[:three_d_secure]) if options[:three_d_secure]
230
247
  add_level_3_data(doc, options)
231
248
  end
@@ -236,7 +253,8 @@ module ActiveMerchant
236
253
 
237
254
  doc.country(address[:country]) if address[:country]
238
255
  doc.state(address[:state]) if address[:state] && STATE_CODE_COUNTRIES.include?(address[:country])
239
- doc.address(address[:address]) if address[:address]
256
+ doc.address(address[:address1]) if address[:address1]
257
+ doc.address2(address[:address2]) if address[:address2]
240
258
  doc.city(address[:city]) if address[:city]
241
259
  doc.zip(address[:zip]) if address[:zip]
242
260
  end
@@ -298,9 +316,32 @@ module ActiveMerchant
298
316
  doc.send('transaction-id', authorization)
299
317
  end
300
318
 
301
- def add_fraud_info(doc, options)
319
+ def add_fraud_info(doc, payment_method, options)
302
320
  doc.send('transaction-fraud-info') do
303
321
  doc.send('shopper-ip-address', options[:ip]) if options[:ip]
322
+ if fraud_info = options[:transaction_fraud_info]
323
+ doc.send('fraud-session-id', fraud_info[:fraud_session_id]) if fraud_info[:fraud_session_id]
324
+ end
325
+ unless payment_method.is_a? String
326
+ doc.send('shipping-contact-info') do
327
+ add_shipping_contact_info(doc, payment_method, options)
328
+ end
329
+ end
330
+ end
331
+ end
332
+
333
+ def add_shipping_contact_info(doc, payment_method, options)
334
+ if address = options[:shipping_address]
335
+ # https://developers.bluesnap.com/v8976-XML/docs/shipping-contact-info
336
+ doc.send('first-name', payment_method.first_name)
337
+ doc.send('last-name', payment_method.last_name)
338
+
339
+ doc.country(address[:country]) if address[:country]
340
+ doc.state(address[:state]) if address[:state] && STATE_CODE_COUNTRIES.include?(address[:country])
341
+ doc.address1(address[:address1]) if address[:address1]
342
+ doc.address2(address[:address2]) if address[:address2]
343
+ doc.city(address[:city]) if address[:city]
344
+ doc.zip(address[:zip]) if address[:zip]
304
345
  end
305
346
  end
306
347
 
@@ -314,8 +355,8 @@ module ActiveMerchant
314
355
 
315
356
  add_echeck_transaction(doc, payment_method_details.payment_method, options, vaulted_shopper_id.present?) if payment_method_details.check?
316
357
 
317
- add_fraud_info(doc, options)
318
- add_description(doc, options)
358
+ add_fraud_info(doc, payment_method_details.payment_method, options)
359
+ add_metadata(doc, options)
319
360
  end
320
361
 
321
362
  def add_echeck_transaction(doc, check, options, vaulted_shopper)
@@ -350,12 +391,21 @@ module ActiveMerchant
350
391
  parsed = {}
351
392
  doc = Nokogiri::XML(response.body)
352
393
  doc.root.xpath('*').each do |node|
394
+ name = node.name.downcase
395
+
353
396
  if node.elements.empty?
354
- parsed[node.name.downcase] = node.text
397
+ parsed[name] = node.text
398
+ elsif name == 'transaction-meta-data'
399
+ metadata = []
400
+ node.elements.each { |m|
401
+ metadata.push parse_metadata_entry(m)
402
+ }
403
+
404
+ parsed['transaction-meta-data'] = metadata
355
405
  else
356
- node.elements.each do |childnode|
406
+ node.elements.each { |childnode|
357
407
  parse_element(parsed, childnode)
358
- end
408
+ }
359
409
  end
360
410
  end
361
411
 
@@ -363,6 +413,18 @@ module ActiveMerchant
363
413
  parsed
364
414
  end
365
415
 
416
+ def parse_metadata_entry(node)
417
+ entry = {}
418
+
419
+ node.elements.each { |e|
420
+ entry = entry.merge({
421
+ e.name => e.text
422
+ })
423
+ }
424
+
425
+ entry
426
+ end
427
+
366
428
  def parse_element(parsed, node)
367
429
  if !node.elements.empty?
368
430
  node.elements.each { |e| parse_element(parsed, e) }
@@ -476,7 +538,7 @@ module ActiveMerchant
476
538
  def headers
477
539
  {
478
540
  'Content-Type' => 'application/xml',
479
- 'Authorization' => ('Basic ' + Base64.strict_encode64("#{@options[:api_username]}:#{@options[:api_password]}").strip),
541
+ 'Authorization' => ('Basic ' + Base64.strict_encode64("#{@options[:api_username]}:#{@options[:api_password]}").strip)
480
542
  }
481
543
  end
482
544
 
@@ -47,9 +47,9 @@ module ActiveMerchant #:nodoc:
47
47
  money = amount(money)
48
48
  case normalize(paysource)
49
49
  when /1$/
50
- Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true)
50
+ Response.new(true, SUCCESS_MESSAGE, { paid_amount: money }, test: true)
51
51
  when /2$/
52
- Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
52
+ Response.new(false, FAILURE_MESSAGE, { paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
53
53
  else
54
54
  raise Error, error_message(paysource)
55
55
  end
@@ -61,9 +61,9 @@ module ActiveMerchant #:nodoc:
61
61
  when /1$/
62
62
  raise Error, REFUND_ERROR_MESSAGE
63
63
  when /2$/
64
- Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
64
+ Response.new(false, FAILURE_MESSAGE, { paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
65
65
  else
66
- Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true)
66
+ Response.new(true, SUCCESS_MESSAGE, { paid_amount: money }, test: true)
67
67
  end
68
68
  end
69
69
 
@@ -73,9 +73,9 @@ module ActiveMerchant #:nodoc:
73
73
  when /1$/
74
74
  raise Error, CAPTURE_ERROR_MESSAGE
75
75
  when /2$/
76
- Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
76
+ Response.new(false, FAILURE_MESSAGE, { paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
77
77
  else
78
- Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true)
78
+ Response.new(true, SUCCESS_MESSAGE, { paid_amount: money }, test: true)
79
79
  end
80
80
  end
81
81
 
@@ -84,18 +84,18 @@ module ActiveMerchant #:nodoc:
84
84
  when /1$/
85
85
  raise Error, VOID_ERROR_MESSAGE
86
86
  when /2$/
87
- Response.new(false, FAILURE_MESSAGE, {authorization: reference, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
87
+ Response.new(false, FAILURE_MESSAGE, { authorization: reference, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
88
88
  else
89
- Response.new(true, SUCCESS_MESSAGE, {authorization: reference}, test: true)
89
+ Response.new(true, SUCCESS_MESSAGE, { authorization: reference }, test: true)
90
90
  end
91
91
  end
92
92
 
93
93
  def store(paysource, options = {})
94
94
  case normalize(paysource)
95
95
  when /1$/
96
- Response.new(true, SUCCESS_MESSAGE, {billingid: '1'}, test: true, authorization: AUTHORIZATION)
96
+ Response.new(true, SUCCESS_MESSAGE, { billingid: '1' }, test: true, authorization: AUTHORIZATION)
97
97
  when /2$/
98
- Response.new(false, FAILURE_MESSAGE, {billingid: nil, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
98
+ Response.new(false, FAILURE_MESSAGE, { billingid: nil, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
99
99
  else
100
100
  raise Error, error_message(paysource)
101
101
  end
@@ -106,7 +106,7 @@ module ActiveMerchant #:nodoc:
106
106
  when /1$/
107
107
  Response.new(true, SUCCESS_MESSAGE, {}, test: true)
108
108
  when /2$/
109
- Response.new(false, FAILURE_MESSAGE, {error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
109
+ Response.new(false, FAILURE_MESSAGE, { error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
110
110
  else
111
111
  raise Error, UNSTORE_ERROR_MESSAGE
112
112
  end
@@ -118,9 +118,9 @@ module ActiveMerchant #:nodoc:
118
118
  money = amount(money)
119
119
  case money
120
120
  when /00$/
121
- Response.new(true, SUCCESS_MESSAGE, {authorized_amount: money}, test: true, authorization: AUTHORIZATION, emv_authorization: AUTHORIZATION_EMV_SUCCESS)
121
+ Response.new(true, SUCCESS_MESSAGE, { authorized_amount: money }, test: true, authorization: AUTHORIZATION, emv_authorization: AUTHORIZATION_EMV_SUCCESS)
122
122
  when /05$/
123
- Response.new(false, FAILURE_MESSAGE, {authorized_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error], emv_authorization: AUTHORIZATION_EMV_DECLINE)
123
+ Response.new(false, FAILURE_MESSAGE, { authorized_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error], emv_authorization: AUTHORIZATION_EMV_DECLINE)
124
124
  else
125
125
  raise Error, error_message(paysource)
126
126
  end
@@ -130,9 +130,9 @@ module ActiveMerchant #:nodoc:
130
130
  money = amount(money)
131
131
  case normalize(paysource)
132
132
  when /1$/, AUTHORIZATION
133
- Response.new(true, SUCCESS_MESSAGE, {authorized_amount: money}, test: true, authorization: AUTHORIZATION)
133
+ Response.new(true, SUCCESS_MESSAGE, { authorized_amount: money }, test: true, authorization: AUTHORIZATION)
134
134
  when /2$/
135
- Response.new(false, FAILURE_MESSAGE, {authorized_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
135
+ Response.new(false, FAILURE_MESSAGE, { authorized_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
136
136
  else
137
137
  raise Error, error_message(paysource)
138
138
  end
@@ -142,9 +142,9 @@ module ActiveMerchant #:nodoc:
142
142
  money = amount(money)
143
143
  case money
144
144
  when /00$/
145
- Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true, authorization: AUTHORIZATION, emv_authorization: AUTHORIZATION_EMV_SUCCESS)
145
+ Response.new(true, SUCCESS_MESSAGE, { paid_amount: money }, test: true, authorization: AUTHORIZATION, emv_authorization: AUTHORIZATION_EMV_SUCCESS)
146
146
  when /05$/
147
- Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error], emv_authorization: AUTHORIZATION_EMV_DECLINE)
147
+ Response.new(false, FAILURE_MESSAGE, { paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error], emv_authorization: AUTHORIZATION_EMV_DECLINE)
148
148
  else
149
149
  raise Error, error_message(paysource)
150
150
  end
@@ -154,9 +154,9 @@ module ActiveMerchant #:nodoc:
154
154
  money = amount(money)
155
155
  case normalize(paysource)
156
156
  when /1$/, AUTHORIZATION
157
- Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true, authorization: AUTHORIZATION)
157
+ Response.new(true, SUCCESS_MESSAGE, { paid_amount: money }, test: true, authorization: AUTHORIZATION)
158
158
  when /2$/
159
- Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
159
+ Response.new(false, FAILURE_MESSAGE, { paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
160
160
  else
161
161
  raise Error, error_message(paysource)
162
162
  end