activemerchant 1.114.0 → 1.120.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +183 -0
  3. data/README.md +4 -2
  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/check.rb +10 -0
  7. data/lib/active_merchant/billing/compatibility.rb +3 -3
  8. data/lib/active_merchant/billing/credit_card.rb +3 -0
  9. data/lib/active_merchant/billing/credit_card_methods.rb +80 -15
  10. data/lib/active_merchant/billing/gateways/adyen.rb +44 -20
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +50 -12
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +5 -1
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
  16. data/lib/active_merchant/billing/gateways/balanced.rb +4 -3
  17. data/lib/active_merchant/billing/gateways/bambora_apac.rb +7 -7
  18. data/lib/active_merchant/billing/gateways/bank_frick.rb +7 -7
  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 +22 -18
  25. data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
  26. data/lib/active_merchant/billing/gateways/borgun.rb +11 -11
  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 +60 -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 +7 -7
  36. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  37. data/lib/active_merchant/billing/gateways/cashnet.rb +7 -2
  38. data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
  39. data/lib/active_merchant/billing/gateways/cenpos.rb +10 -10
  40. data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
  41. data/lib/active_merchant/billing/gateways/checkout_v2.rb +38 -20
  42. data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
  43. data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
  44. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  45. data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
  46. data/lib/active_merchant/billing/gateways/credorax.rb +39 -23
  47. data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
  48. data/lib/active_merchant/billing/gateways/culqi.rb +9 -9
  49. data/lib/active_merchant/billing/gateways/cyber_source.rb +81 -39
  50. data/lib/active_merchant/billing/gateways/d_local.rb +12 -12
  51. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
  52. data/lib/active_merchant/billing/gateways/decidir.rb +31 -10
  53. data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
  54. data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
  55. data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
  56. data/lib/active_merchant/billing/gateways/efsnet.rb +2 -3
  57. data/lib/active_merchant/billing/gateways/elavon.rb +296 -225
  58. data/lib/active_merchant/billing/gateways/element.rb +8 -8
  59. data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
  60. data/lib/active_merchant/billing/gateways/eway.rb +3 -4
  61. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
  62. data/lib/active_merchant/billing/gateways/eway_rapid.rb +19 -6
  63. data/lib/active_merchant/billing/gateways/exact.rb +8 -9
  64. data/lib/active_merchant/billing/gateways/ezic.rb +7 -7
  65. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  66. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
  67. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  68. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
  69. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  70. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +21 -10
  71. data/lib/active_merchant/billing/gateways/flo2cash.rb +8 -8
  72. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  73. data/lib/active_merchant/billing/gateways/forte.rb +26 -8
  74. data/lib/active_merchant/billing/gateways/global_collect.rb +35 -16
  75. data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
  76. data/lib/active_merchant/billing/gateways/hdfc.rb +9 -9
  77. data/lib/active_merchant/billing/gateways/hps.rb +72 -9
  78. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  79. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  80. data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
  81. data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
  82. data/lib/active_merchant/billing/gateways/ipp.rb +5 -5
  83. data/lib/active_merchant/billing/gateways/iridium.rb +14 -15
  84. data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
  85. data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
  86. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
  87. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
  88. data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
  89. data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
  90. data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -5
  91. data/lib/active_merchant/billing/gateways/litle.rb +32 -16
  92. data/lib/active_merchant/billing/gateways/mastercard.rb +10 -10
  93. data/lib/active_merchant/billing/gateways/mercado_pago.rb +9 -9
  94. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
  95. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  96. data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
  97. data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
  98. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
  99. data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
  100. data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
  101. data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
  102. data/lib/active_merchant/billing/gateways/migs.rb +3 -4
  103. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
  104. data/lib/active_merchant/billing/gateways/monei.rb +7 -7
  105. data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
  106. data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
  107. data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
  108. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
  109. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
  110. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
  111. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  112. data/lib/active_merchant/billing/gateways/netbanx.rb +45 -10
  113. data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
  114. data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
  115. data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
  116. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  117. data/lib/active_merchant/billing/gateways/omise.rb +13 -13
  118. data/lib/active_merchant/billing/gateways/openpay.rb +3 -4
  119. data/lib/active_merchant/billing/gateways/opp.rb +9 -9
  120. data/lib/active_merchant/billing/gateways/optimal_payment.rb +2 -3
  121. data/lib/active_merchant/billing/gateways/orbital.rb +225 -105
  122. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
  123. data/lib/active_merchant/billing/gateways/pagarme.rb +8 -8
  124. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  125. data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
  126. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
  127. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
  128. data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -3
  129. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
  130. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
  131. data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
  132. data/lib/active_merchant/billing/gateways/payeezy.rb +62 -20
  133. data/lib/active_merchant/billing/gateways/payex.rb +6 -7
  134. data/lib/active_merchant/billing/gateways/payflow.rb +1 -1
  135. data/lib/active_merchant/billing/gateways/payment_express.rb +11 -7
  136. data/lib/active_merchant/billing/gateways/paymentez.rb +26 -6
  137. data/lib/active_merchant/billing/gateways/paymill.rb +7 -7
  138. data/lib/active_merchant/billing/gateways/paypal.rb +10 -2
  139. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -0
  140. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
  141. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  142. data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
  143. data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
  144. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  145. data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
  146. data/lib/active_merchant/billing/gateways/payway.rb +8 -9
  147. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  148. data/lib/active_merchant/billing/gateways/pin.rb +11 -0
  149. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -2
  150. data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
  151. data/lib/active_merchant/billing/gateways/psigate.rb +2 -3
  152. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
  153. data/lib/active_merchant/billing/gateways/qbms.rb +1 -2
  154. data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
  155. data/lib/active_merchant/billing/gateways/quickbooks.rb +1 -1
  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 +31 -17
  159. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/redsys.rb +105 -9
  161. data/lib/active_merchant/billing/gateways/s5.rb +7 -7
  162. data/lib/active_merchant/billing/gateways/safe_charge.rb +51 -18
  163. data/lib/active_merchant/billing/gateways/sage.rb +3 -5
  164. data/lib/active_merchant/billing/gateways/sage_pay.rb +2 -3
  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 +2 -3
  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 +18 -18
  176. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +91 -25
  177. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
  178. data/lib/active_merchant/billing/gateways/telr.rb +8 -8
  179. data/lib/active_merchant/billing/gateways/trans_first.rb +2 -2
  180. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +12 -12
  181. data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
  182. data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -2
  183. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +32 -32
  185. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +3 -4
  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/vpos.rb +172 -0
  191. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  192. data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
  193. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
  194. data/lib/active_merchant/billing/gateways/worldpay.rb +43 -22
  195. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
  196. data/lib/active_merchant/billing/gateways/worldpay_us.rb +7 -7
  197. data/lib/active_merchant/billing/response.rb +3 -2
  198. data/lib/active_merchant/country.rb +1 -1
  199. data/lib/active_merchant/network_connection_retries.rb +2 -2
  200. data/lib/active_merchant/post_data.rb +1 -1
  201. data/lib/active_merchant/posts_data.rb +1 -1
  202. data/lib/active_merchant/version.rb +1 -1
  203. data/lib/certs/cacert.pem +1582 -2431
  204. data/lib/support/ssl_verify.rb +2 -2
  205. data/lib/support/ssl_version.rb +2 -2
  206. metadata +5 -3
@@ -16,12 +16,12 @@ module ActiveMerchant #:nodoc:
16
16
 
17
17
  self.homepage_url = 'https://www.borgun.is/'
18
18
 
19
- def initialize(options={})
19
+ def initialize(options = {})
20
20
  requires!(options, :processor, :merchant_id, :username, :password)
21
21
  super
22
22
  end
23
23
 
24
- def purchase(money, payment, options={})
24
+ def purchase(money, payment, options = {})
25
25
  post = {}
26
26
  post[:TransType] = '1'
27
27
  add_invoice(post, money, options)
@@ -29,7 +29,7 @@ module ActiveMerchant #:nodoc:
29
29
  commit('sale', post)
30
30
  end
31
31
 
32
- def authorize(money, payment, options={})
32
+ def authorize(money, payment, options = {})
33
33
  post = {}
34
34
  post[:TransType] = '5'
35
35
  add_invoice(post, money, options)
@@ -37,7 +37,7 @@ module ActiveMerchant #:nodoc:
37
37
  commit('authonly', post, options)
38
38
  end
39
39
 
40
- def capture(money, authorization, options={})
40
+ def capture(money, authorization, options = {})
41
41
  post = {}
42
42
  post[:TransType] = '1'
43
43
  add_invoice(post, money, options)
@@ -45,7 +45,7 @@ module ActiveMerchant #:nodoc:
45
45
  commit('capture', post)
46
46
  end
47
47
 
48
- def refund(money, authorization, options={})
48
+ def refund(money, authorization, options = {})
49
49
  post = {}
50
50
  post[:TransType] = '3'
51
51
  add_invoice(post, money, options)
@@ -53,7 +53,7 @@ module ActiveMerchant #:nodoc:
53
53
  commit('refund', post)
54
54
  end
55
55
 
56
- def void(authorization, options={})
56
+ def void(authorization, options = {})
57
57
  post = {}
58
58
  # TransType, TrAmount, and currency must match original values from auth or purchase.
59
59
  _, _, _, _, _, transtype, tramount, currency = split_authorization(authorization)
@@ -76,7 +76,7 @@ module ActiveMerchant #:nodoc:
76
76
 
77
77
  private
78
78
 
79
- CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
79
+ CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
80
80
  CURRENCY_CODES['ISK'] = '352'
81
81
  CURRENCY_CODES['EUR'] = '978'
82
82
  CURRENCY_CODES['USD'] = '840'
@@ -125,7 +125,7 @@ module ActiveMerchant #:nodoc:
125
125
  response
126
126
  end
127
127
 
128
- def commit(action, post, options={})
128
+ def commit(action, post, options = {})
129
129
  post[:Version] = '1000'
130
130
  post[:Processor] = @options[:processor]
131
131
  post[:MerchantID] = @options[:merchant_id]
@@ -180,7 +180,7 @@ module ActiveMerchant #:nodoc:
180
180
  }
181
181
  end
182
182
 
183
- def build_request(action, post, options={})
183
+ def build_request(action, post, options = {})
184
184
  mode = action == 'void' ? 'cancel' : 'get'
185
185
  xml = Builder::XmlMarkup.new indent: 18
186
186
  xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
@@ -205,7 +205,7 @@ module ActiveMerchant #:nodoc:
205
205
  end
206
206
 
207
207
  def envelope(mode)
208
- <<-EOS
208
+ <<-XML
209
209
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aut="http://Borgun/Heimir/pub/ws/Authorization">
210
210
  <soapenv:Header/>
211
211
  <soapenv:Body>
@@ -216,7 +216,7 @@ module ActiveMerchant #:nodoc:
216
216
  </aut:#{mode}AuthorizationInput>
217
217
  </soapenv:Body>
218
218
  </soapenv:Envelope>
219
- EOS
219
+ XML
220
220
  end
221
221
 
222
222
  def url(action)
@@ -12,12 +12,12 @@ module ActiveMerchant #:nodoc:
12
12
  self.homepage_url = 'https://www.bpoint.com.au/bpoint'
13
13
  self.display_name = 'BPoint'
14
14
 
15
- def initialize(options={})
15
+ def initialize(options = {})
16
16
  requires!(options, :username, :password, :merchant_number)
17
17
  super
18
18
  end
19
19
 
20
- def store(credit_card, options={})
20
+ def store(credit_card, options = {})
21
21
  options[:crn1] ||= 'DEFAULT'
22
22
  request_body = soap_request do |xml|
23
23
  add_token(xml, credit_card, options)
@@ -25,7 +25,7 @@ module ActiveMerchant #:nodoc:
25
25
  commit(request_body)
26
26
  end
27
27
 
28
- def purchase(amount, credit_card, options={})
28
+ def purchase(amount, credit_card, options = {})
29
29
  request_body = soap_request do |xml|
30
30
  process_payment(xml) do |payment_xml|
31
31
  add_purchase(payment_xml, amount, credit_card, options)
@@ -34,7 +34,7 @@ module ActiveMerchant #:nodoc:
34
34
  commit(request_body)
35
35
  end
36
36
 
37
- def authorize(amount, credit_card, options={})
37
+ def authorize(amount, credit_card, options = {})
38
38
  request_body = soap_request do |xml|
39
39
  process_payment(xml) do |payment_xml|
40
40
  add_authorize(payment_xml, amount, credit_card, options)
@@ -43,7 +43,7 @@ module ActiveMerchant #:nodoc:
43
43
  commit(request_body)
44
44
  end
45
45
 
46
- def capture(amount, authorization, options={})
46
+ def capture(amount, authorization, options = {})
47
47
  request_body = soap_request do |xml|
48
48
  process_payment(xml) do |payment_xml|
49
49
  add_capture(payment_xml, amount, authorization, options)
@@ -52,7 +52,7 @@ module ActiveMerchant #:nodoc:
52
52
  commit(request_body)
53
53
  end
54
54
 
55
- def refund(amount, authorization, options={})
55
+ def refund(amount, authorization, options = {})
56
56
  request_body = soap_request do |xml|
57
57
  process_payment(xml) do |payment_xml|
58
58
  add_refund(payment_xml, amount, authorization, options)
@@ -61,7 +61,7 @@ module ActiveMerchant #:nodoc:
61
61
  commit(request_body)
62
62
  end
63
63
 
64
- def void(authorization, options={})
64
+ def void(authorization, options = {})
65
65
  request_body = soap_request do |xml|
66
66
  process_payment(xml) do |payment_xml|
67
67
  add_void(payment_xml, authorization, options)
@@ -70,7 +70,7 @@ module ActiveMerchant #:nodoc:
70
70
  commit(request_body)
71
71
  end
72
72
 
73
- def verify(credit_card, options={})
73
+ def verify(credit_card, options = {})
74
74
  MultiResponse.run(:use_first_response) do |r|
75
75
  r.process { authorize(100, credit_card, options) }
76
76
  r.process(:ignore_result) { void(r.authorization, options.merge(amount: 100)) }
@@ -7,7 +7,7 @@ module ActiveMerchant #:nodoc:
7
7
 
8
8
  self.abstract_class = true
9
9
 
10
- def self.new(options={})
10
+ def self.new(options = {})
11
11
  if options.has_key?(:login)
12
12
  BraintreeOrangeGateway.new(options)
13
13
  else
@@ -7,7 +7,7 @@ rescue LoadError
7
7
  raise 'Could not load the braintree gem. Use `gem install braintree` to install it.'
8
8
  end
9
9
 
10
- raise "Need braintree gem >= 2.78.0. Run `gem install braintree --version '~>2.78'` to get the correct version." unless Braintree::Version::Major == 2 && Braintree::Version::Minor >= 78
10
+ raise "Need braintree gem >= 3.0.0. Run `gem install braintree --version '~>3.0.0'` to get the correct version." unless Braintree::Version::Major == 3 && Braintree::Version::Minor == 0
11
11
 
12
12
  module ActiveMerchant #:nodoc:
13
13
  module Billing #:nodoc:
@@ -115,10 +115,36 @@ module ActiveMerchant #:nodoc:
115
115
  end
116
116
  end
117
117
 
118
- def verify(credit_card, options = {})
119
- MultiResponse.run(:use_first_response) do |r|
120
- r.process { authorize(100, credit_card, options) }
121
- r.process(:ignore_result) { void(r.authorization, options) }
118
+ def verify(creditcard, options = {})
119
+ if options[:allow_card_verification] == true
120
+ options.delete(:allow_card_verification)
121
+ exp_month = creditcard.month.to_s
122
+ exp_year = creditcard.year.to_s
123
+ expiration = "#{exp_month}/#{exp_year}"
124
+ payload = {
125
+ credit_card: {
126
+ number: creditcard.number,
127
+ expiration_date: expiration,
128
+ cvv: creditcard.verification_value,
129
+ billing_address: {
130
+ postal_code: options[:billing_address][:zip]
131
+ }
132
+ }
133
+ }
134
+ commit do
135
+ result = @braintree_gateway.verification.create(payload)
136
+ response = Response.new(result.success?, message_from_transaction_result(result), response_options(result))
137
+ response.cvv_result['message'] = ''
138
+ response.cvv_result['code'] = response.params['cvv_result']
139
+ response.avs_result['code'] = response.params['avs_result'][:code]
140
+ response
141
+ end
142
+
143
+ else
144
+ MultiResponse.run(:use_first_response) do |r|
145
+ r.process { authorize(100, creditcard, options) }
146
+ r.process(:ignore_result) { void(r.authorization, options) }
147
+ end
122
148
  end
123
149
  end
124
150
 
@@ -163,12 +189,10 @@ module ActiveMerchant #:nodoc:
163
189
  email: scrub_email(options[:email]),
164
190
  phone: options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
165
191
  options[:billing_address][:phone]),
166
- credit_card: credit_card_params
167
- )
192
+ credit_card: credit_card_params)
168
193
  Response.new(result.success?, message_from_result(result),
169
194
  braintree_customer: (customer_hash(@braintree_gateway.customer.find(vault_id), :include_credit_cards) if result.success?),
170
- customer_vault_id: (result.customer.id if result.success?)
171
- )
195
+ customer_vault_id: (result.customer.id if result.success?))
172
196
  end
173
197
  end
174
198
 
@@ -182,7 +206,7 @@ module ActiveMerchant #:nodoc:
182
206
  Response.new(true, 'OK')
183
207
  end
184
208
  end
185
- alias_method :delete, :unstore
209
+ alias delete unstore
186
210
 
187
211
  def supports_network_tokenization?
188
212
  true
@@ -205,9 +229,9 @@ module ActiveMerchant #:nodoc:
205
229
  def check_customer_exists(customer_vault_id)
206
230
  commit do
207
231
  @braintree_gateway.customer.find(customer_vault_id)
208
- ActiveMerchant::Billing::Response.new(true, 'Customer found', {exists: true}, authorization: customer_vault_id)
232
+ ActiveMerchant::Billing::Response.new(true, 'Customer found', { exists: true }, authorization: customer_vault_id)
209
233
  rescue Braintree::NotFoundError
210
- ActiveMerchant::Billing::Response.new(true, 'Customer not found', {exists: false})
234
+ ActiveMerchant::Billing::Response.new(true, 'Customer not found', { exists: false })
211
235
  end
212
236
  end
213
237
 
@@ -243,8 +267,7 @@ module ActiveMerchant #:nodoc:
243
267
  customer_vault_id: (result.customer.id if result.success?),
244
268
  credit_card_token: (result.customer.credit_cards[0].token if result.success?)
245
269
  },
246
- authorization: (result.customer.id if result.success?)
247
- )
270
+ authorization: (result.customer.id if result.success?))
248
271
  end
249
272
  end
250
273
 
@@ -371,7 +394,11 @@ module ActiveMerchant #:nodoc:
371
394
 
372
395
  def response_options(result)
373
396
  options = {}
374
- if result.transaction
397
+ if result.credit_card_verification
398
+ options[:authorization] = result.credit_card_verification.id
399
+ options[:avs_result] = { code: avs_code_from(result.credit_card_verification) }
400
+ options[:cvv_result] = result.credit_card_verification.cvv_response_code
401
+ elsif result.transaction
375
402
  options[:authorization] = result.transaction.id
376
403
  options[:avs_result] = { code: avs_code_from(result.transaction) }
377
404
  options[:cvv_result] = result.transaction.cvv_response_code
@@ -464,7 +491,7 @@ module ActiveMerchant #:nodoc:
464
491
  end
465
492
  end
466
493
 
467
- def customer_hash(customer, include_credit_cards=false)
494
+ def customer_hash(customer, include_credit_cards = false)
468
495
  hash = {
469
496
  'email' => customer.email,
470
497
  'phone' => customer.phone,
@@ -586,6 +613,7 @@ module ActiveMerchant #:nodoc:
586
613
  parameters[:device_data] = options[:device_data] if options[:device_data]
587
614
  parameters[:service_fee_amount] = options[:service_fee_amount] if options[:service_fee_amount]
588
615
 
616
+ add_account_type(parameters, options) if options[:account_type]
589
617
  add_skip_options(parameters, options)
590
618
  add_merchant_account_id(parameters, options)
591
619
 
@@ -594,6 +622,7 @@ module ActiveMerchant #:nodoc:
594
622
  add_addresses(parameters, options)
595
623
 
596
624
  add_descriptor(parameters, options)
625
+ add_risk_data(parameters, options)
597
626
  add_travel_data(parameters, options) if options[:travel_data]
598
627
  add_lodging_data(parameters, options) if options[:lodging_data]
599
628
  add_channel(parameters, options)
@@ -612,6 +641,11 @@ module ActiveMerchant #:nodoc:
612
641
  parameters
613
642
  end
614
643
 
644
+ def add_account_type(parameters, options)
645
+ parameters[:options][:credit_card] = {}
646
+ parameters[:options][:credit_card][:account_type] = options[:account_type]
647
+ end
648
+
615
649
  def add_skip_options(parameters, options)
616
650
  parameters[:options][:skip_advanced_fraud_checking] = options[:skip_advanced_fraud_checking] if options[:skip_advanced_fraud_checking]
617
651
  parameters[:options][:skip_avs] = options[:skip_avs] if options[:skip_avs]
@@ -649,6 +683,15 @@ module ActiveMerchant #:nodoc:
649
683
  }
650
684
  end
651
685
 
686
+ def add_risk_data(parameters, options)
687
+ return unless options[:risk_data]
688
+
689
+ parameters[:risk_data] = {
690
+ customer_browser: options[:risk_data][:customer_browser],
691
+ customer_ip: options[:risk_data][:customer_ip]
692
+ }
693
+ end
694
+
652
695
  def add_level_2_data(parameters, options)
653
696
  parameters[:tax_amount] = options[:tax_amount] if options[:tax_amount]
654
697
  parameters[:tax_exempt] = options[:tax_exempt] if options[:tax_exempt]
@@ -758,7 +801,7 @@ module ActiveMerchant #:nodoc:
758
801
  eci_indicator: credit_card_or_vault_id.eci
759
802
  }
760
803
  elsif credit_card_or_vault_id.source == :android_pay || credit_card_or_vault_id.source == :google_pay
761
- parameters[:android_pay_card] = {
804
+ parameters[:google_pay_card] = {
762
805
  number: credit_card_or_vault_id.number,
763
806
  cryptogram: credit_card_or_vault_id.payment_cryptogram,
764
807
  expiration_month: credit_card_or_vault_id.month.to_s.rjust(2, '0'),
@@ -13,12 +13,12 @@ module ActiveMerchant #:nodoc:
13
13
  self.default_currency = 'USD'
14
14
  self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
15
15
 
16
- def initialize(options={})
16
+ def initialize(options = {})
17
17
  requires!(options, :user_name, :password)
18
18
  super
19
19
  end
20
20
 
21
- def purchase(amount, payment_method, options={})
21
+ def purchase(amount, payment_method, options = {})
22
22
  post = initialize_required_fields('Sale')
23
23
 
24
24
  # Allow the same amount in multiple transactions.
@@ -30,7 +30,7 @@ module ActiveMerchant #:nodoc:
30
30
  commit(post)
31
31
  end
32
32
 
33
- def authorize(amount, payment_method, options={})
33
+ def authorize(amount, payment_method, options = {})
34
34
  post = initialize_required_fields('Auth')
35
35
 
36
36
  add_invoice(post, amount, options)
@@ -40,7 +40,7 @@ module ActiveMerchant #:nodoc:
40
40
  commit(post)
41
41
  end
42
42
 
43
- def capture(amount, authorization, options={})
43
+ def capture(amount, authorization, options = {})
44
44
  post = initialize_required_fields('Force')
45
45
 
46
46
  add_invoice(post, amount, options)
@@ -50,7 +50,7 @@ module ActiveMerchant #:nodoc:
50
50
  commit(post)
51
51
  end
52
52
 
53
- def refund(amount, authorization, options={})
53
+ def refund(amount, authorization, options = {})
54
54
  post = initialize_required_fields('Return')
55
55
 
56
56
  add_invoice(post, amount, options)
@@ -59,7 +59,7 @@ module ActiveMerchant #:nodoc:
59
59
  commit(post)
60
60
  end
61
61
 
62
- def void(authorization, options={})
62
+ def void(authorization, options = {})
63
63
  post = initialize_required_fields('Void')
64
64
 
65
65
  add_reference(post, authorization)
@@ -74,7 +74,7 @@ module ActiveMerchant #:nodoc:
74
74
  end
75
75
  end
76
76
 
77
- def store(creditcard, options={})
77
+ def store(creditcard, options = {})
78
78
  post = initialize_required_fields('')
79
79
  post[:transaction] = 'Create'
80
80
  post[:CardNumber] = creditcard.number
@@ -67,12 +67,12 @@ module ActiveMerchant #:nodoc:
67
67
  '894' => STANDARD_ERROR_CODE[:processing_error]
68
68
  }
69
69
 
70
- def initialize(options={})
70
+ def initialize(options = {})
71
71
  requires!(options, :username, :password)
72
72
  super
73
73
  end
74
74
 
75
- def purchase(money, payment, options={})
75
+ def purchase(money, payment, options = {})
76
76
  post = {}
77
77
  add_invoice(post, money, options)
78
78
 
@@ -86,7 +86,7 @@ module ActiveMerchant #:nodoc:
86
86
  commit('sale', post)
87
87
  end
88
88
 
89
- def authorize(money, payment, options={})
89
+ def authorize(money, payment, options = {})
90
90
  post = {}
91
91
  add_invoice(post, money, options)
92
92
  add_payment(post, payment)
@@ -95,7 +95,7 @@ module ActiveMerchant #:nodoc:
95
95
  commit('auth', post)
96
96
  end
97
97
 
98
- def capture(money, authorization, options={})
98
+ def capture(money, authorization, options = {})
99
99
  post = {}
100
100
  add_reference(post, authorization)
101
101
  add_invoice(post, money, options)
@@ -103,20 +103,20 @@ module ActiveMerchant #:nodoc:
103
103
  commit('capture', post)
104
104
  end
105
105
 
106
- def refund(money, authorization, options={})
106
+ def refund(money, authorization, options = {})
107
107
  post = {}
108
108
  add_reference(post, authorization)
109
109
  add_invoice(post, money, options)
110
110
  commit('refund', post)
111
111
  end
112
112
 
113
- def void(authorization, options={})
113
+ def void(authorization, options = {})
114
114
  post = {}
115
115
  add_reference(post, authorization)
116
116
  commit('void', post)
117
117
  end
118
118
 
119
- def verify(credit_card, options={})
119
+ def verify(credit_card, options = {})
120
120
  post = {}
121
121
  add_invoice(post, 0, options)
122
122
  add_payment(post, credit_card)
@@ -138,7 +138,7 @@ module ActiveMerchant #:nodoc:
138
138
 
139
139
  private
140
140
 
141
- def add_address(post, creditcard, options={})
141
+ def add_address(post, creditcard, options = {})
142
142
  post[:firstname] = creditcard.first_name
143
143
  post[:lastname] = creditcard.last_name
144
144