activemerchant 1.113.0 → 1.119.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +114 -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 -0
  8. data/lib/active_merchant/billing/credit_card_methods.rb +72 -13
  9. data/lib/active_merchant/billing/gateways/adyen.rb +24 -14
  10. data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
  11. data/lib/active_merchant/billing/gateways/authorize_net.rb +44 -12
  12. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
  13. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +2 -1
  14. data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
  15. data/lib/active_merchant/billing/gateways/balanced.rb +4 -3
  16. data/lib/active_merchant/billing/gateways/bambora_apac.rb +7 -7
  17. data/lib/active_merchant/billing/gateways/bank_frick.rb +7 -7
  18. data/lib/active_merchant/billing/gateways/banwire.rb +1 -1
  19. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +6 -4
  20. data/lib/active_merchant/billing/gateways/beanstream.rb +3 -3
  21. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +4 -5
  22. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -3
  23. data/lib/active_merchant/billing/gateways/blue_snap.rb +37 -12
  24. data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
  25. data/lib/active_merchant/billing/gateways/borgun.rb +11 -11
  26. data/lib/active_merchant/billing/gateways/bpoint.rb +8 -8
  27. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  28. data/lib/active_merchant/billing/gateways/braintree_blue.rb +13 -10
  29. data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -7
  30. data/lib/active_merchant/billing/gateways/cams.rb +8 -8
  31. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  32. data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
  34. data/lib/active_merchant/billing/gateways/cardknox.rb +7 -7
  35. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  36. data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
  37. data/lib/active_merchant/billing/gateways/cenpos.rb +10 -10
  38. data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
  39. data/lib/active_merchant/billing/gateways/checkout_v2.rb +17 -20
  40. data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
  41. data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
  42. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  43. data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
  44. data/lib/active_merchant/billing/gateways/credorax.rb +26 -15
  45. data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
  46. data/lib/active_merchant/billing/gateways/culqi.rb +9 -9
  47. data/lib/active_merchant/billing/gateways/cyber_source.rb +58 -36
  48. data/lib/active_merchant/billing/gateways/d_local.rb +11 -11
  49. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
  50. data/lib/active_merchant/billing/gateways/decidir.rb +31 -10
  51. data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
  52. data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
  53. data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
  54. data/lib/active_merchant/billing/gateways/efsnet.rb +2 -3
  55. data/lib/active_merchant/billing/gateways/elavon.rb +286 -225
  56. data/lib/active_merchant/billing/gateways/element.rb +8 -8
  57. data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
  58. data/lib/active_merchant/billing/gateways/eway.rb +3 -4
  59. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
  60. data/lib/active_merchant/billing/gateways/eway_rapid.rb +19 -6
  61. data/lib/active_merchant/billing/gateways/exact.rb +8 -9
  62. data/lib/active_merchant/billing/gateways/ezic.rb +7 -7
  63. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  64. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
  65. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  66. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
  67. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  68. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +21 -10
  69. data/lib/active_merchant/billing/gateways/flo2cash.rb +8 -8
  70. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  71. data/lib/active_merchant/billing/gateways/forte.rb +14 -8
  72. data/lib/active_merchant/billing/gateways/global_collect.rb +35 -16
  73. data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
  74. data/lib/active_merchant/billing/gateways/hdfc.rb +9 -9
  75. data/lib/active_merchant/billing/gateways/hps.rb +17 -8
  76. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  77. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  78. data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
  79. data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
  80. data/lib/active_merchant/billing/gateways/ipp.rb +5 -5
  81. data/lib/active_merchant/billing/gateways/iridium.rb +14 -15
  82. data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
  83. data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
  84. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
  85. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
  86. data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
  87. data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
  88. data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -5
  89. data/lib/active_merchant/billing/gateways/litle.rb +31 -15
  90. data/lib/active_merchant/billing/gateways/mastercard.rb +10 -10
  91. data/lib/active_merchant/billing/gateways/mercado_pago.rb +7 -7
  92. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
  93. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  94. data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
  95. data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
  96. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
  97. data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
  98. data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
  99. data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
  100. data/lib/active_merchant/billing/gateways/migs.rb +3 -4
  101. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
  102. data/lib/active_merchant/billing/gateways/monei.rb +7 -7
  103. data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
  104. data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
  105. data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
  106. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
  107. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
  108. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
  109. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  110. data/lib/active_merchant/billing/gateways/netbanx.rb +19 -8
  111. data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
  112. data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
  113. data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
  114. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  115. data/lib/active_merchant/billing/gateways/omise.rb +13 -13
  116. data/lib/active_merchant/billing/gateways/openpay.rb +3 -4
  117. data/lib/active_merchant/billing/gateways/opp.rb +9 -9
  118. data/lib/active_merchant/billing/gateways/optimal_payment.rb +2 -3
  119. data/lib/active_merchant/billing/gateways/orbital.rb +196 -85
  120. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
  121. data/lib/active_merchant/billing/gateways/pagarme.rb +8 -8
  122. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  123. data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
  124. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
  125. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
  126. data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -3
  127. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
  128. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
  129. data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
  130. data/lib/active_merchant/billing/gateways/payeezy.rb +32 -14
  131. data/lib/active_merchant/billing/gateways/payex.rb +6 -7
  132. data/lib/active_merchant/billing/gateways/payflow.rb +1 -1
  133. data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
  134. data/lib/active_merchant/billing/gateways/paymentez.rb +26 -6
  135. data/lib/active_merchant/billing/gateways/paymill.rb +7 -7
  136. data/lib/active_merchant/billing/gateways/paypal.rb +10 -2
  137. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -0
  138. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
  139. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  140. data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
  141. data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
  142. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  143. data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
  144. data/lib/active_merchant/billing/gateways/payway.rb +8 -9
  145. data/lib/active_merchant/billing/gateways/pin.rb +11 -0
  146. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -2
  147. data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
  148. data/lib/active_merchant/billing/gateways/psigate.rb +2 -3
  149. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
  150. data/lib/active_merchant/billing/gateways/qbms.rb +1 -2
  151. data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
  152. data/lib/active_merchant/billing/gateways/quickbooks.rb +1 -1
  153. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -4
  154. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -2
  155. data/lib/active_merchant/billing/gateways/qvalent.rb +8 -8
  156. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  157. data/lib/active_merchant/billing/gateways/redsys.rb +86 -5
  158. data/lib/active_merchant/billing/gateways/s5.rb +7 -7
  159. data/lib/active_merchant/billing/gateways/safe_charge.rb +40 -14
  160. data/lib/active_merchant/billing/gateways/sage.rb +3 -5
  161. data/lib/active_merchant/billing/gateways/sage_pay.rb +2 -3
  162. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  163. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -2
  164. data/lib/active_merchant/billing/gateways/secure_pay.rb +3 -4
  165. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +2 -4
  166. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -2
  167. data/lib/active_merchant/billing/gateways/securion_pay.rb +5 -6
  168. data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -3
  169. data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -6
  170. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +7 -7
  171. data/lib/active_merchant/billing/gateways/spreedly_core.rb +6 -6
  172. data/lib/active_merchant/billing/gateways/stripe.rb +10 -10
  173. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +30 -0
  174. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
  175. data/lib/active_merchant/billing/gateways/telr.rb +8 -8
  176. data/lib/active_merchant/billing/gateways/trans_first.rb +2 -2
  177. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +12 -12
  178. data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
  179. data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -2
  180. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
  181. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +32 -32
  182. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +3 -4
  183. data/lib/active_merchant/billing/gateways/vanco.rb +3 -3
  184. data/lib/active_merchant/billing/gateways/verifi.rb +1 -2
  185. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -2
  186. data/lib/active_merchant/billing/gateways/visanet_peru.rb +10 -10
  187. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  188. data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
  189. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
  190. data/lib/active_merchant/billing/gateways/worldpay.rb +19 -11
  191. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
  192. data/lib/active_merchant/billing/gateways/worldpay_us.rb +7 -7
  193. data/lib/active_merchant/billing/response.rb +3 -2
  194. data/lib/active_merchant/country.rb +1 -1
  195. data/lib/active_merchant/network_connection_retries.rb +2 -2
  196. data/lib/active_merchant/post_data.rb +1 -1
  197. data/lib/active_merchant/posts_data.rb +1 -1
  198. data/lib/active_merchant/version.rb +1 -1
  199. data/lib/support/ssl_verify.rb +2 -2
  200. data/lib/support/ssl_version.rb +2 -2
  201. metadata +2 -2
@@ -129,8 +129,7 @@ module ActiveMerchant #:nodoc:
129
129
  postal_match: AVS_POSTAL_CODES[response['AVSPostalResponseCode']],
130
130
  street_match: AVS_ADDRESS_CODES[response['AVSAddressResponseCode']]
131
131
  },
132
- cvv_result: CVV2_CODES[response['CVV2ResponseCode']]
133
- )
132
+ cvv_result: CVV2_CODES[response['CVV2ResponseCode']])
134
133
  end
135
134
 
136
135
  def url(action)
@@ -149,9 +148,9 @@ module ActiveMerchant #:nodoc:
149
148
 
150
149
  def success?(response)
151
150
  if %w(cc_settle cc_debit cc_preauth cc_refund).include?(response[:action])
152
- !response['ApprovalCode'].nil? and response['ErrorCode'].nil? and response['Status'] == 'Approved'
151
+ !response['ApprovalCode'].nil? && response['ErrorCode'].nil? && (response['Status'] == 'Approved')
153
152
  elsif response[:action] = 'void'
154
- !response['ApprovalCode'].nil? and response['ErrorCode'].nil? and response['Status'] == 'Voided'
153
+ !response['ApprovalCode'].nil? && response['ErrorCode'].nil? && (response['Status'] == 'Voided')
155
154
  end
156
155
  end
157
156
 
@@ -16,14 +16,14 @@ module ActiveMerchant #:nodoc:
16
16
  'processing_error' => STANDARD_ERROR_CODE[:processing_error]
17
17
  }
18
18
 
19
- def initialize(options={})
19
+ def initialize(options = {})
20
20
  requires!(options, :api_key)
21
21
  @api_key = options[:api_key]
22
22
 
23
23
  super
24
24
  end
25
25
 
26
- def purchase(money, payment_method, options={})
26
+ def purchase(money, payment_method, options = {})
27
27
  post = {}
28
28
  add_amount(post, money)
29
29
  add_payment_method(post, payment_method)
@@ -32,7 +32,7 @@ module ActiveMerchant #:nodoc:
32
32
  commit(:post, 'transactions', post)
33
33
  end
34
34
 
35
- def authorize(money, payment_method, options={})
35
+ def authorize(money, payment_method, options = {})
36
36
  post = {}
37
37
  add_amount(post, money)
38
38
  add_payment_method(post, payment_method)
@@ -43,27 +43,27 @@ module ActiveMerchant #:nodoc:
43
43
  commit(:post, 'transactions', post)
44
44
  end
45
45
 
46
- def capture(money, authorization, options={})
46
+ def capture(money, authorization, options = {})
47
47
  return Response.new(false, 'Não é possível capturar uma transação sem uma prévia autorização.') if authorization.nil?
48
48
 
49
49
  post = {}
50
50
  commit(:post, "transactions/#{authorization}/capture", post)
51
51
  end
52
52
 
53
- def refund(money, authorization, options={})
53
+ def refund(money, authorization, options = {})
54
54
  return Response.new(false, 'Não é possível estornar uma transação sem uma prévia captura.') if authorization.nil?
55
55
 
56
56
  void(authorization, options)
57
57
  end
58
58
 
59
- def void(authorization, options={})
59
+ def void(authorization, options = {})
60
60
  return Response.new(false, 'Não é possível estornar uma transação autorizada sem uma prévia autorização.') if authorization.nil?
61
61
 
62
62
  post = {}
63
63
  commit(:post, "transactions/#{authorization}/refund", post)
64
64
  end
65
65
 
66
- def verify(payment_method, options={})
66
+ def verify(payment_method, options = {})
67
67
  MultiResponse.run(:use_first_response) do |r|
68
68
  r.process { authorize(127, payment_method, options) }
69
69
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -99,7 +99,7 @@ module ActiveMerchant #:nodoc:
99
99
  post[:card_cvv] = credit_card.verification_value
100
100
  end
101
101
 
102
- def add_metadata(post, options={})
102
+ def add_metadata(post, options = {})
103
103
  post[:metadata] = {}
104
104
  post[:metadata][:order_id] = options[:order_id]
105
105
  post[:metadata][:ip] = options[:ip]
@@ -11,12 +11,12 @@ module ActiveMerchant #:nodoc:
11
11
  self.homepage_url = 'http://www.pagofacil.net/'
12
12
  self.display_name = 'PagoFacil'
13
13
 
14
- def initialize(options={})
14
+ def initialize(options = {})
15
15
  requires!(options, :branch_id, :merchant_id, :service_id)
16
16
  super
17
17
  end
18
18
 
19
- def purchase(money, credit_card, options={})
19
+ def purchase(money, credit_card, options = {})
20
20
  post = {}
21
21
  add_invoice(post, money, options)
22
22
  add_payment(post, credit_card)
@@ -13,31 +13,31 @@ module ActiveMerchant #:nodoc:
13
13
  self.homepage_url = 'http://www.bluefincommerce.com/'
14
14
  self.display_name = 'PayConex'
15
15
 
16
- def initialize(options={})
16
+ def initialize(options = {})
17
17
  requires!(options, :account_id, :api_accesskey)
18
18
  super
19
19
  end
20
20
 
21
- def purchase(money, payment_method, options={})
21
+ def purchase(money, payment_method, options = {})
22
22
  post = {}
23
23
  add_auth_purchase_params(post, money, payment_method, options)
24
24
  commit('SALE', post)
25
25
  end
26
26
 
27
- def authorize(money, payment_method, options={})
27
+ def authorize(money, payment_method, options = {})
28
28
  post = {}
29
29
  add_auth_purchase_params(post, money, payment_method, options)
30
30
  commit('AUTHORIZATION', post)
31
31
  end
32
32
 
33
- def capture(money, authorization, options={})
33
+ def capture(money, authorization, options = {})
34
34
  post = {}
35
35
  add_reference_params(post, authorization, options)
36
36
  add_amount(post, money, options)
37
37
  commit('CAPTURE', post)
38
38
  end
39
39
 
40
- def refund(money, authorization, options={})
40
+ def refund(money, authorization, options = {})
41
41
  post = {}
42
42
  add_reference_params(post, authorization, options)
43
43
  add_amount(post, money, options)
@@ -50,7 +50,7 @@ module ActiveMerchant #:nodoc:
50
50
  commit('REVERSAL', post)
51
51
  end
52
52
 
53
- def credit(money, payment_method, options={})
53
+ def credit(money, payment_method, options = {})
54
54
  raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' if payment_method.is_a?(String)
55
55
 
56
56
  post = {}
@@ -58,11 +58,11 @@ module ActiveMerchant #:nodoc:
58
58
  commit('CREDIT', post)
59
59
  end
60
60
 
61
- def verify(payment_method, options={})
61
+ def verify(payment_method, options = {})
62
62
  authorize(0, payment_method, options)
63
63
  end
64
64
 
65
- def store(payment_method, options={})
65
+ def store(payment_method, options = {})
66
66
  post = {}
67
67
  add_credentials(post)
68
68
  add_payment_method(post, payment_method)
@@ -183,7 +183,7 @@ module ActiveMerchant #:nodoc:
183
183
  commit(action, build_request(action, options), authorization)
184
184
  end
185
185
 
186
- def refund(money, authorization, options={})
186
+ def refund(money, authorization, options = {})
187
187
  action = 'refundtx'
188
188
 
189
189
  options[:money] = money
@@ -197,7 +197,7 @@ module ActiveMerchant #:nodoc:
197
197
  SUCCESS_CODES.include?(response[:res])
198
198
  end
199
199
 
200
- def build_request(action, options={})
200
+ def build_request(action, options = {})
201
201
  xml = Builder::XmlMarkup.new
202
202
  xml.instruct!
203
203
 
@@ -220,7 +220,7 @@ module ActiveMerchant #:nodoc:
220
220
  xml.target!
221
221
  end
222
222
 
223
- def build_authorization(xml, money, creditcard, options={})
223
+ def build_authorization(xml, money, creditcard, options = {})
224
224
  xml.tag! 'authtx', {
225
225
  cref: options[:order_id],
226
226
  cname: creditcard.name,
@@ -235,13 +235,13 @@ module ActiveMerchant #:nodoc:
235
235
  }
236
236
  end
237
237
 
238
- def build_capture(xml, money, authorization, options={})
238
+ def build_capture(xml, money, authorization, options = {})
239
239
  xml.tag! 'settletx', {
240
240
  tid: authorization
241
241
  }
242
242
  end
243
243
 
244
- def build_refund(xml, money, authorization, options={})
244
+ def build_refund(xml, money, authorization, options = {})
245
245
  xml.tag! 'refundtx', {
246
246
  tid: authorization,
247
247
  amt: amount(money)
@@ -266,8 +266,7 @@ module ActiveMerchant #:nodoc:
266
266
  response = parse(action, ssl_post(self.live_url, request))
267
267
  Response.new(successful?(response), message_from(response), response,
268
268
  test: test?,
269
- authorization: authorization || response[:tid]
270
- )
269
+ authorization: authorization || response[:tid])
271
270
  end
272
271
 
273
272
  def message_from(response)
@@ -66,7 +66,7 @@ module ActiveMerchant #:nodoc:
66
66
  '43' => STANDARD_ERROR_CODE[:pickup_card]
67
67
  }
68
68
 
69
- def initialize(options={})
69
+ def initialize(options = {})
70
70
  requires!(options, :orgid, :username, :password, :tid)
71
71
 
72
72
  super
@@ -82,7 +82,7 @@ module ActiveMerchant #:nodoc:
82
82
  commit(post)
83
83
  end
84
84
 
85
- def purchase(amount, creditcard, options={})
85
+ def purchase(amount, creditcard, options = {})
86
86
  post = setup_post('sale')
87
87
  add_creditcard(post, creditcard)
88
88
  add_amount(post, amount)
@@ -92,7 +92,7 @@ module ActiveMerchant #:nodoc:
92
92
  commit(post)
93
93
  end
94
94
 
95
- def refund(amount, trans_id, options={})
95
+ def refund(amount, trans_id, options = {})
96
96
  # Attempt a void in case the transaction is unsettled
97
97
  post = setup_post('void')
98
98
  add_reference(post, trans_id)
@@ -115,7 +115,7 @@ module ActiveMerchant #:nodoc:
115
115
 
116
116
  # No void, as PayHub's void does not work on authorizations
117
117
 
118
- def verify(creditcard, options={})
118
+ def verify(creditcard, options = {})
119
119
  authorize(100, creditcard, options)
120
120
  end
121
121
 
@@ -172,7 +172,7 @@ module ActiveMerchant #:nodoc:
172
172
  success = false
173
173
 
174
174
  begin
175
- raw_response = ssl_post(live_url, post.to_json, {'Content-Type' => 'application/json'})
175
+ raw_response = ssl_post(live_url, post.to_json, { 'Content-Type' => 'application/json' })
176
176
  response = parse(raw_response)
177
177
  success = (response['RESPONSE_CODE'] == '00')
178
178
  rescue ResponseError => e
@@ -186,11 +186,10 @@ module ActiveMerchant #:nodoc:
186
186
  response_message(response),
187
187
  response,
188
188
  test: test?,
189
- avs_result: {code: response['AVS_RESULT_CODE']},
189
+ avs_result: { code: response['AVS_RESULT_CODE'] },
190
190
  cvv_result: response['VERIFICATION_RESULT_CODE'],
191
191
  error_code: (success ? nil : STANDARD_ERROR_CODE_MAPPING[response['RESPONSE_CODE']]),
192
- authorization: response['TRANSACTION_ID']
193
- )
192
+ authorization: response['TRANSACTION_ID'])
194
193
  end
195
194
 
196
195
  def response_error(raw_response)
@@ -339,8 +339,7 @@ module ActiveMerchant #:nodoc:
339
339
 
340
340
  Response.new(successful?(response), message_from(response), response,
341
341
  test: test?,
342
- authorization: response[:transaction_id] || parameters[:transaction_id]
343
- )
342
+ authorization: response[:transaction_id] || parameters[:transaction_id])
344
343
  end
345
344
 
346
345
  def successful?(response)
@@ -367,7 +366,7 @@ module ActiveMerchant #:nodoc:
367
366
  params[:version] = API_VERSION
368
367
  params[:transaction_type] = action
369
368
 
370
- params.reject { |k, v| v.blank? }.collect { |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&')
369
+ params.reject { |_k, v| v.blank? }.collect { |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&')
371
370
  end
372
371
 
373
372
  def parse(body)
@@ -12,12 +12,12 @@ module ActiveMerchant #:nodoc:
12
12
  self.money_format = :dollars
13
13
  self.supported_cardtypes = %i[visa master american_express discover]
14
14
 
15
- def initialize(options={})
15
+ def initialize(options = {})
16
16
  requires!(options, :api_login, :api_password, :api_key)
17
17
  super
18
18
  end
19
19
 
20
- def purchase(amount, payment_method, options={})
20
+ def purchase(amount, payment_method, options = {})
21
21
  post = {}
22
22
  add_invoice(post, amount, options)
23
23
  add_payment_method(post, payment_method)
@@ -26,7 +26,7 @@ module ActiveMerchant #:nodoc:
26
26
  commit('purchase', post)
27
27
  end
28
28
 
29
- def authorize(amount, payment_method, options={})
29
+ def authorize(amount, payment_method, options = {})
30
30
  post = {}
31
31
  post[:status] = 'HOLD'
32
32
  add_invoice(post, amount, options)
@@ -36,7 +36,7 @@ module ActiveMerchant #:nodoc:
36
36
  commit('authorize', post)
37
37
  end
38
38
 
39
- def capture(amount, authorization, options={})
39
+ def capture(amount, authorization, options = {})
40
40
  post = {}
41
41
  post[:status] = 'CAPTURE'
42
42
  post[:transactionId] = authorization
@@ -45,7 +45,7 @@ module ActiveMerchant #:nodoc:
45
45
  commit('capture', post)
46
46
  end
47
47
 
48
- def void(authorization, options={})
48
+ def void(authorization, options = {})
49
49
  post = {}
50
50
  post[:status] = 'VOID'
51
51
  post[:transactionId] = authorization
@@ -53,7 +53,7 @@ module ActiveMerchant #:nodoc:
53
53
  commit('void', post)
54
54
  end
55
55
 
56
- def refund(amount, authorization, options={})
56
+ def refund(amount, authorization, options = {})
57
57
  post = {}
58
58
  post[:action] = 'REFUND'
59
59
  post[:transactionId] = authorization
@@ -62,7 +62,7 @@ module ActiveMerchant #:nodoc:
62
62
  commit('refund', post)
63
63
  end
64
64
 
65
- def credit(amount, payment_method, options={})
65
+ def credit(amount, payment_method, options = {})
66
66
  post = {}
67
67
  post[:action] = 'REFUND'
68
68
  add_invoice(post, amount, options)
@@ -71,7 +71,7 @@ module ActiveMerchant #:nodoc:
71
71
  commit('credit', post)
72
72
  end
73
73
 
74
- def verify(credit_card, options={})
74
+ def verify(credit_card, options = {})
75
75
  MultiResponse.run(:use_first_response) do |r|
76
76
  r.process { authorize(100, credit_card, options) }
77
77
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -166,7 +166,7 @@ module ActiveMerchant #:nodoc:
166
166
  params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
167
167
  end
168
168
 
169
- def url(params={})
169
+ def url(params = {})
170
170
  test? ? "#{test_url}/#{params[:transactionId]}" : "#{live_url}/#{params[:transactionId]}"
171
171
  end
172
172
 
@@ -70,8 +70,7 @@ module ActiveMerchant #:nodoc:
70
70
 
71
71
  Response.new(successful?(response), message_from(response), response,
72
72
  test: test_response?(response),
73
- authorization: authorization_from(response)
74
- )
73
+ authorization: authorization_from(response))
75
74
  end
76
75
 
77
76
  def successful?(response)
@@ -104,7 +103,7 @@ module ActiveMerchant #:nodoc:
104
103
  parameters[:merchant_id] = @options[:login]
105
104
  parameters[:password] = @options[:password]
106
105
 
107
- parameters.reject { |k, v| v.blank? }.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
106
+ parameters.reject { |_k, v| v.blank? }.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
108
107
  end
109
108
  end
110
109
  end
@@ -64,10 +64,31 @@ module ActiveMerchant #:nodoc:
64
64
  super
65
65
  end
66
66
 
67
+ def add_3dsecure(post, options)
68
+ # ECI=02 => MasterCard success
69
+ # ECI=05 => Visa, Amex or JCB success
70
+ if options[:eci] == '02' || options[:eci] == '05'
71
+ post[:"3DSTATUS"] = 'Y'
72
+ post[:"3DENROLLED"] = 'Y'
73
+ post[:"3DSIGNVAL"] = 'Y'
74
+ post[:"3DERROR"] = '0'
75
+ else
76
+ post[:"3DSTATUS"] = 'N'
77
+ post[:"3DENROLLED"] = 'N'
78
+ post[:"3DSIGNVAL"] = 'N'
79
+ post[:"3DERROR"] = '10000'
80
+ end
81
+ post[:"3DECI"] = options[:eci]
82
+ post[:"3DXID"] = options[:xid]
83
+ post[:"3DCAVV"] = options[:cavv]
84
+ post[:"3DCAVVALGO"] = options[:cavv_algorithm]
85
+ end
86
+
67
87
  def authorize(money, creditcard, options = {})
68
88
  post = {}
69
89
  add_invoice(post, options)
70
90
  add_creditcard(post, creditcard)
91
+ add_3dsecure(post, options[:three_d_secure]) if options[:three_d_secure]
71
92
  add_amount(post, money, options)
72
93
 
73
94
  commit('authorization', money, post)
@@ -77,6 +98,7 @@ module ActiveMerchant #:nodoc:
77
98
  post = {}
78
99
  add_invoice(post, options)
79
100
  add_creditcard(post, creditcard)
101
+ add_3dsecure(post, options[:three_d_secure]) if options[:three_d_secure]
80
102
  add_amount(post, money, options)
81
103
 
82
104
  commit('purchase', money, post)
@@ -160,7 +182,7 @@ module ActiveMerchant #:nodoc:
160
182
  test: test?,
161
183
  authorization: response[:numappel].to_s + response[:numtrans].to_s,
162
184
  fraud_review: false,
163
- sent_params: parameters.delete_if { |key, value| %w[porteur dateval cvv].include?(key.to_s) }
185
+ sent_params: parameters.delete_if { |key, _value| %w[porteur dateval cvv].include?(key.to_s) }
164
186
  )
165
187
  end
166
188
 
@@ -45,7 +45,7 @@ module ActiveMerchant
45
45
  end
46
46
 
47
47
  def authorize(amount, payment_method, options = {})
48
- params = {transaction_type: 'authorize'}
48
+ params = { transaction_type: 'authorize' }
49
49
 
50
50
  add_invoice(params, options)
51
51
  add_reversal_id(params, options)
@@ -59,7 +59,7 @@ module ActiveMerchant
59
59
  end
60
60
 
61
61
  def capture(amount, authorization, options = {})
62
- params = {transaction_type: 'capture'}
62
+ params = { transaction_type: 'capture' }
63
63
 
64
64
  add_authorization_info(params, authorization)
65
65
  add_amount(params, amount, options)
@@ -69,7 +69,7 @@ module ActiveMerchant
69
69
  end
70
70
 
71
71
  def refund(amount, authorization, options = {})
72
- params = {transaction_type: 'refund'}
72
+ params = { transaction_type: 'refund' }
73
73
 
74
74
  add_authorization_info(params, authorization)
75
75
  add_amount(params, (amount || amount_from_authorization(authorization)), options)
@@ -78,7 +78,7 @@ module ActiveMerchant
78
78
  end
79
79
 
80
80
  def store(payment_method, options = {})
81
- params = {transaction_type: 'store'}
81
+ params = { transaction_type: 'store' }
82
82
 
83
83
  add_creditcard_for_tokenization(params, payment_method, options)
84
84
 
@@ -86,7 +86,7 @@ module ActiveMerchant
86
86
  end
87
87
 
88
88
  def void(authorization, options = {})
89
- params = {transaction_type: 'void'}
89
+ params = { transaction_type: 'void' }
90
90
 
91
91
  add_authorization_info(params, authorization, options)
92
92
  add_amount(params, amount_from_authorization(authorization), options)
@@ -94,7 +94,7 @@ module ActiveMerchant
94
94
  commit(params, options)
95
95
  end
96
96
 
97
- def verify(credit_card, options={})
97
+ def verify(credit_card, options = {})
98
98
  MultiResponse.run(:use_first_response) do |r|
99
99
  r.process { authorize(0, credit_card, options) }
100
100
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -247,16 +247,34 @@ module ActiveMerchant
247
247
  end
248
248
 
249
249
  def add_stored_credentials(params, options)
250
- if options[:sequence]
250
+ if options[:sequence] || options[:stored_credential]
251
251
  params[:stored_credentials] = {}
252
- params[:stored_credentials][:cardbrand_original_transaction_id] = options[:cardbrand_original_transaction_id] if options[:cardbrand_original_transaction_id]
253
- params[:stored_credentials][:sequence] = options[:sequence]
254
- params[:stored_credentials][:initiator] = options[:initiator] if options[:initiator]
255
- params[:stored_credentials][:is_scheduled] = options[:is_scheduled]
252
+ params[:stored_credentials][:cardbrand_original_transaction_id] = original_transaction_id(options) if original_transaction_id(options)
253
+ params[:stored_credentials][:initiator] = initiator(options) if initiator(options)
254
+ params[:stored_credentials][:sequence] = options[:sequence] || sequence(options[:stored_credential][:initial_transaction])
255
+ params[:stored_credentials][:is_scheduled] = options[:is_scheduled] || is_scheduled(options[:stored_credential][:reason_type])
256
256
  params[:stored_credentials][:auth_type_override] = options[:auth_type_override] if options[:auth_type_override]
257
257
  end
258
258
  end
259
259
 
260
+ def original_transaction_id(options)
261
+ return options[:cardbrand_original_transaction_id] if options[:cardbrand_original_transaction_id]
262
+ return options[:stored_credential][:network_transaction_id] if options.dig(:stored_credential, :network_transaction_id)
263
+ end
264
+
265
+ def initiator(options)
266
+ return options[:initiator] if options[:initiator]
267
+ return options[:stored_credential][:initiator].upcase if options.dig(:stored_credential, :initiator)
268
+ end
269
+
270
+ def sequence(initial_transaction)
271
+ initial_transaction ? 'FIRST' : 'SUBSEQUENT'
272
+ end
273
+
274
+ def is_scheduled(reason_type)
275
+ reason_type == 'recurring' ? 'true' : 'false'
276
+ end
277
+
260
278
  def commit(params, options)
261
279
  url = base_url(options) + endpoint(params)
262
280
 
@@ -278,7 +296,7 @@ module ActiveMerchant
278
296
  response,
279
297
  test: test?,
280
298
  authorization: authorization_from(params, response),
281
- avs_result: {code: response['avs']},
299
+ avs_result: { code: response['avs'] },
282
300
  cvv_result: response['cvv2'],
283
301
  error_code: error_code(response, success_from(response))
284
302
  )
@@ -306,7 +324,7 @@ module ActiveMerchant
306
324
  def post_data(params)
307
325
  return nil unless params
308
326
 
309
- params.reject { |k, v| v.blank? }.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
327
+ params.reject { |_k, v| v.blank? }.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
310
328
  end
311
329
 
312
330
  def generate_hmac(nonce, current_timestamp, payload)
@@ -405,7 +423,7 @@ module ActiveMerchant
405
423
  end
406
424
 
407
425
  def json_error(raw_response)
408
- {'error' => "Unable to parse response: #{raw_response.inspect}"}
426
+ { 'error' => "Unable to parse response: #{raw_response.inspect}" }
409
427
  end
410
428
  end
411
429
  end