activemerchant 1.100.0 → 1.133.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +1057 -0
  3. data/README.md +11 -9
  4. data/lib/active_merchant/billing/avs_result.rb +9 -9
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +49 -17
  7. data/lib/active_merchant/billing/compatibility.rb +5 -4
  8. data/lib/active_merchant/billing/credit_card.rb +55 -8
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
  10. data/lib/active_merchant/billing/credit_card_methods.rb +209 -36
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +38 -36
  13. data/lib/active_merchant/billing/gateways/adyen.rb +399 -78
  14. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  15. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +14 -14
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +200 -130
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +27 -20
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +48 -51
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +13 -15
  21. data/lib/active_merchant/billing/gateways/balanced.rb +43 -36
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +16 -20
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +13 -13
  24. data/lib/active_merchant/billing/gateways/banwire.rb +5 -5
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +43 -30
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +5 -5
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +37 -36
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +21 -3
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +53 -28
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +176 -54
  33. data/lib/active_merchant/billing/gateways/bogus.rb +24 -20
  34. data/lib/active_merchant/billing/gateways/borgun.rb +92 -38
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +15 -15
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +8 -2
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -175
  40. data/lib/active_merchant/billing/gateways/bridge_pay.rb +13 -13
  41. data/lib/active_merchant/billing/gateways/cams.rb +10 -10
  42. data/lib/active_merchant/billing/gateways/card_connect.rb +33 -14
  43. data/lib/active_merchant/billing/gateways/card_save.rb +3 -4
  44. data/lib/active_merchant/billing/gateways/card_stream.rb +67 -40
  45. data/lib/active_merchant/billing/gateways/cardknox.rb +13 -13
  46. data/lib/active_merchant/billing/gateways/cardprocess.rb +4 -2
  47. data/lib/active_merchant/billing/gateways/cashnet.rb +28 -12
  48. data/lib/active_merchant/billing/gateways/cc5.rb +9 -9
  49. data/lib/active_merchant/billing/gateways/cecabank.rb +38 -38
  50. data/lib/active_merchant/billing/gateways/cenpos.rb +29 -28
  51. data/lib/active_merchant/billing/gateways/checkout.rb +7 -9
  52. data/lib/active_merchant/billing/gateways/checkout_v2.rb +316 -68
  53. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -2
  54. data/lib/active_merchant/billing/gateways/clearhaus.rb +32 -33
  55. data/lib/active_merchant/billing/gateways/commerce_hub.rb +370 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
  57. data/lib/active_merchant/billing/gateways/conekta.rb +8 -6
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +18 -17
  59. data/lib/active_merchant/billing/gateways/credorax.rb +152 -63
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +15 -14
  61. data/lib/active_merchant/billing/gateways/culqi.rb +30 -28
  62. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  63. data/lib/active_merchant/billing/gateways/cyber_source.rb +496 -187
  64. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  65. data/lib/active_merchant/billing/gateways/d_local.rb +148 -31
  66. data/lib/active_merchant/billing/gateways/data_cash.rb +34 -37
  67. data/lib/active_merchant/billing/gateways/decidir.rb +134 -21
  68. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +10 -10
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +11 -8
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +90 -40
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +36 -36
  73. data/lib/active_merchant/billing/gateways/elavon.rb +349 -194
  74. data/lib/active_merchant/billing/gateways/element.rb +71 -21
  75. data/lib/active_merchant/billing/gateways/epay.rb +43 -43
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +12 -13
  77. data/lib/active_merchant/billing/gateways/eway.rb +9 -9
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +55 -56
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +37 -22
  80. data/lib/active_merchant/billing/gateways/exact.rb +19 -20
  81. data/lib/active_merchant/billing/gateways/ezic.rb +9 -9
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -19
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -7
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +5 -4
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +7 -7
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +39 -38
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +51 -31
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +24 -24
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  91. data/lib/active_merchant/billing/gateways/forte.rb +38 -22
  92. data/lib/active_merchant/billing/gateways/garanti.rb +12 -15
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +333 -89
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +8 -9
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +22 -23
  96. data/lib/active_merchant/billing/gateways/hps.rb +171 -50
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +47 -25
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  99. data/lib/active_merchant/billing/gateways/inspire.rb +22 -27
  100. data/lib/active_merchant/billing/gateways/instapay.rb +5 -8
  101. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  102. data/lib/active_merchant/billing/gateways/ipp.rb +9 -9
  103. data/lib/active_merchant/billing/gateways/iridium.rb +30 -31
  104. data/lib/active_merchant/billing/gateways/itransact.rb +11 -10
  105. data/lib/active_merchant/billing/gateways/iveri.rb +62 -23
  106. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  107. data/lib/active_merchant/billing/gateways/jetpay.rb +10 -17
  108. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +13 -18
  109. data/lib/active_merchant/billing/gateways/komoju.rb +1 -1
  110. data/lib/active_merchant/billing/gateways/kushki.rb +100 -22
  111. data/lib/active_merchant/billing/gateways/latitude19.rb +20 -19
  112. data/lib/active_merchant/billing/gateways/linkpoint.rb +71 -72
  113. data/lib/active_merchant/billing/gateways/litle.rb +181 -45
  114. data/lib/active_merchant/billing/gateways/mastercard.rb +16 -22
  115. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  116. data/lib/active_merchant/billing/gateways/mercado_pago.rb +89 -18
  117. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +58 -24
  118. data/lib/active_merchant/billing/gateways/merchant_one.rb +7 -10
  119. data/lib/active_merchant/billing/gateways/merchant_partners.rb +19 -19
  120. data/lib/active_merchant/billing/gateways/merchant_ware.rb +18 -22
  121. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +15 -17
  122. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +46 -8
  123. data/lib/active_merchant/billing/gateways/mercury.rb +19 -23
  124. data/lib/active_merchant/billing/gateways/metrics_global.rb +24 -33
  125. data/lib/active_merchant/billing/gateways/micropayment.rb +11 -12
  126. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  127. data/lib/active_merchant/billing/gateways/migs.rb +18 -21
  128. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  129. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +10 -12
  130. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  131. data/lib/active_merchant/billing/gateways/monei.rb +236 -150
  132. data/lib/active_merchant/billing/gateways/moneris.rb +122 -53
  133. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -7
  134. data/lib/active_merchant/billing/gateways/mundipagg.rb +69 -23
  135. data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -20
  136. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +10 -12
  137. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -9
  138. data/lib/active_merchant/billing/gateways/netaxept.rb +12 -12
  139. data/lib/active_merchant/billing/gateways/netbanx.rb +128 -46
  140. data/lib/active_merchant/billing/gateways/netbilling.rb +18 -21
  141. data/lib/active_merchant/billing/gateways/netpay.rb +5 -4
  142. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -10
  143. data/lib/active_merchant/billing/gateways/nmi.rb +69 -27
  144. data/lib/active_merchant/billing/gateways/ogone.rb +62 -31
  145. data/lib/active_merchant/billing/gateways/omise.rb +15 -16
  146. data/lib/active_merchant/billing/gateways/openpay.rb +33 -15
  147. data/lib/active_merchant/billing/gateways/opp.rb +39 -33
  148. data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -42
  149. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
  150. data/lib/active_merchant/billing/gateways/orbital.rb +623 -362
  151. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +20 -20
  152. data/lib/active_merchant/billing/gateways/pagarme.rb +16 -23
  153. data/lib/active_merchant/billing/gateways/pago_facil.rb +4 -6
  154. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  155. data/lib/active_merchant/billing/gateways/pay_conex.rb +17 -17
  156. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -33
  157. data/lib/active_merchant/billing/gateways/pay_hub.rb +10 -10
  158. data/lib/active_merchant/billing/gateways/pay_junction.rb +31 -31
  159. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +36 -18
  160. data/lib/active_merchant/billing/gateways/pay_secure.rb +10 -11
  161. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  162. data/lib/active_merchant/billing/gateways/paybox_direct.rb +64 -40
  163. data/lib/active_merchant/billing/gateways/payeezy.rb +130 -27
  164. data/lib/active_merchant/billing/gateways/payex.rb +24 -25
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +17 -17
  166. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  167. data/lib/active_merchant/billing/gateways/payflow.rb +103 -25
  168. data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
  169. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -1
  170. data/lib/active_merchant/billing/gateways/payment_express.rb +22 -18
  171. data/lib/active_merchant/billing/gateways/paymentez.rb +89 -24
  172. data/lib/active_merchant/billing/gateways/paymill.rb +14 -16
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  175. data/lib/active_merchant/billing/gateways/paypal.rb +13 -5
  176. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  177. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
  178. data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -1
  179. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  180. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  181. data/lib/active_merchant/billing/gateways/payscout.rb +8 -9
  182. data/lib/active_merchant/billing/gateways/paystation.rb +6 -9
  183. data/lib/active_merchant/billing/gateways/payu_in.rb +20 -19
  184. data/lib/active_merchant/billing/gateways/payu_latam.rb +70 -37
  185. data/lib/active_merchant/billing/gateways/payway.rb +22 -22
  186. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  187. data/lib/active_merchant/billing/gateways/pin.rb +60 -21
  188. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  189. data/lib/active_merchant/billing/gateways/plugnpay.rb +20 -21
  190. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  191. data/lib/active_merchant/billing/gateways/pro_pay.rb +13 -14
  192. data/lib/active_merchant/billing/gateways/psigate.rb +29 -29
  193. data/lib/active_merchant/billing/gateways/psl_card.rb +7 -8
  194. data/lib/active_merchant/billing/gateways/qbms.rb +25 -26
  195. data/lib/active_merchant/billing/gateways/quantum.rb +9 -11
  196. data/lib/active_merchant/billing/gateways/quickbooks.rb +126 -39
  197. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +98 -98
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +19 -23
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
  200. data/lib/active_merchant/billing/gateways/quickpay.rb +0 -1
  201. data/lib/active_merchant/billing/gateways/qvalent.rb +36 -20
  202. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  203. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  204. data/lib/active_merchant/billing/gateways/realex.rb +42 -16
  205. data/lib/active_merchant/billing/gateways/redsys.rb +191 -86
  206. data/lib/active_merchant/billing/gateways/s5.rb +10 -9
  207. data/lib/active_merchant/billing/gateways/safe_charge.rb +70 -33
  208. data/lib/active_merchant/billing/gateways/sage.rb +19 -21
  209. data/lib/active_merchant/billing/gateways/sage_pay.rb +57 -57
  210. data/lib/active_merchant/billing/gateways/sallie_mae.rb +3 -4
  211. data/lib/active_merchant/billing/gateways/secure_net.rb +19 -26
  212. data/lib/active_merchant/billing/gateways/secure_pay.rb +24 -33
  213. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +18 -20
  214. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +4 -5
  215. data/lib/active_merchant/billing/gateways/securion_pay.rb +48 -7
  216. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  217. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  218. data/lib/active_merchant/billing/gateways/skip_jack.rb +19 -19
  219. data/lib/active_merchant/billing/gateways/smart_ps.rb +26 -32
  220. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +24 -25
  221. data/lib/active_merchant/billing/gateways/spreedly_core.rb +27 -21
  222. data/lib/active_merchant/billing/gateways/stripe.rb +126 -53
  223. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +441 -113
  224. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +7 -8
  225. data/lib/active_merchant/billing/gateways/telr.rb +17 -18
  226. data/lib/active_merchant/billing/gateways/tns.rb +3 -7
  227. data/lib/active_merchant/billing/gateways/trans_first.rb +10 -9
  228. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +28 -24
  229. data/lib/active_merchant/billing/gateways/transact_pro.rb +13 -15
  230. data/lib/active_merchant/billing/gateways/transax.rb +1 -2
  231. data/lib/active_merchant/billing/gateways/trexle.rb +5 -2
  232. data/lib/active_merchant/billing/gateways/trust_commerce.rb +57 -47
  233. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -2
  234. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +176 -184
  235. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +60 -48
  236. data/lib/active_merchant/billing/gateways/vanco.rb +17 -8
  237. data/lib/active_merchant/billing/gateways/verifi.rb +13 -14
  238. data/lib/active_merchant/billing/gateways/viaklix.rb +9 -14
  239. data/lib/active_merchant/billing/gateways/visanet_peru.rb +26 -21
  240. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  241. data/lib/active_merchant/billing/gateways/webpay.rb +4 -4
  242. data/lib/active_merchant/billing/gateways/wepay.rb +14 -16
  243. data/lib/active_merchant/billing/gateways/wirecard.rb +14 -16
  244. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  245. data/lib/active_merchant/billing/gateways/world_net.rb +36 -35
  246. data/lib/active_merchant/billing/gateways/worldpay.rb +556 -190
  247. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +47 -54
  248. data/lib/active_merchant/billing/gateways/worldpay_us.rb +16 -16
  249. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +2 -2
  250. data/lib/active_merchant/billing/response.rb +25 -6
  251. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  252. data/lib/active_merchant/billing.rb +1 -0
  253. data/lib/active_merchant/connection.rb +14 -15
  254. data/lib/active_merchant/country.rb +3 -1
  255. data/lib/active_merchant/errors.rb +4 -1
  256. data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
  257. data/lib/active_merchant/network_connection_retries.rb +15 -17
  258. data/lib/active_merchant/post_data.rb +3 -2
  259. data/lib/active_merchant/posts_data.rb +2 -2
  260. data/lib/active_merchant/version.rb +1 -1
  261. data/lib/active_merchant.rb +2 -2
  262. data/lib/certs/cacert.pem +1587 -2361
  263. data/lib/support/gateway_support.rb +1 -1
  264. data/lib/support/ssl_verify.rb +3 -7
  265. data/lib/support/ssl_version.rb +2 -3
  266. metadata +86 -34
  267. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -1,12 +1,12 @@
1
1
  module ActiveMerchant
2
2
  module Billing
3
3
  module MastercardGateway
4
- def initialize(options={})
4
+ def initialize(options = {})
5
5
  requires!(options, :userid, :password)
6
6
  super
7
7
  end
8
8
 
9
- def purchase(amount, payment_method, options={})
9
+ def purchase(amount, payment_method, options = {})
10
10
  if options[:pay_mode]
11
11
  post = new_post
12
12
  add_invoice(post, amount, options)
@@ -24,7 +24,7 @@ module ActiveMerchant
24
24
  end
25
25
  end
26
26
 
27
- def authorize(amount, payment_method, options={})
27
+ def authorize(amount, payment_method, options = {})
28
28
  post = new_post
29
29
  add_invoice(post, amount, options)
30
30
  add_reference(post, *new_authorization)
@@ -35,7 +35,7 @@ module ActiveMerchant
35
35
  commit('authorize', post)
36
36
  end
37
37
 
38
- def capture(amount, authorization, options={})
38
+ def capture(amount, authorization, options = {})
39
39
  post = new_post
40
40
  add_invoice(post, amount, options, :transaction)
41
41
  add_reference(post, *next_authorization(authorization))
@@ -45,7 +45,7 @@ module ActiveMerchant
45
45
  commit('capture', post)
46
46
  end
47
47
 
48
- def refund(amount, authorization, options={})
48
+ def refund(amount, authorization, options = {})
49
49
  post = new_post
50
50
  add_invoice(post, amount, options, :transaction)
51
51
  add_reference(post, *next_authorization(authorization))
@@ -54,14 +54,14 @@ module ActiveMerchant
54
54
  commit('refund', post)
55
55
  end
56
56
 
57
- def void(authorization, options={})
57
+ def void(authorization, options = {})
58
58
  post = new_post
59
59
  add_reference(post, *next_authorization(authorization), :targetTransactionId)
60
60
 
61
61
  commit('void', post)
62
62
  end
63
63
 
64
- def verify(credit_card, options={})
64
+ def verify(credit_card, options = {})
65
65
  MultiResponse.run(:use_first_response) do |r|
66
66
  r.process { authorize(100, credit_card, options) }
67
67
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -105,16 +105,16 @@ module ActiveMerchant
105
105
  billing: {},
106
106
  device: {},
107
107
  shipping: {},
108
- transaction: {},
108
+ transaction: {}
109
109
  }
110
110
  end
111
111
 
112
- def add_invoice(post, amount, options, node=:order)
112
+ def add_invoice(post, amount, options, node = :order)
113
113
  post[node][:amount] = amount(amount)
114
114
  post[node][:currency] = (options[:currency] || currency(amount))
115
115
  end
116
116
 
117
- def add_reference(post, orderid, transactionid, transaction_reference, reference_key=:reference)
117
+ def add_reference(post, orderid, transactionid, transaction_reference, reference_key = :reference)
118
118
  post[:orderid] = orderid
119
119
  post[:transactionid] = transactionid
120
120
  post[:transaction][reference_key] = transaction_reference if transaction_reference
@@ -175,7 +175,8 @@ module ActiveMerchant
175
175
 
176
176
  def add_3dsecure_id(post, options)
177
177
  return unless options[:threed_secure_id]
178
- post.merge!({'3DSecureId' => options[:threed_secure_id]})
178
+
179
+ post.merge!({ '3DSecureId' => options[:threed_secure_id] })
179
180
  end
180
181
 
181
182
  def country_code(country)
@@ -189,7 +190,7 @@ module ActiveMerchant
189
190
  def headers
190
191
  {
191
192
  'Authorization' => 'Basic ' + Base64.encode64("merchant.#{@options[:userid]}:#{@options[:password]}").strip.delete("\r\n"),
192
- 'Content-Type' => 'application/json',
193
+ 'Content-Type' => 'application/json'
193
194
  }
194
195
  end
195
196
 
@@ -206,8 +207,8 @@ module ActiveMerchant
206
207
  succeeded,
207
208
  message_from(succeeded, raw),
208
209
  raw,
209
- :authorization => authorization_from(post, raw),
210
- :test => test?
210
+ authorization: authorization_from(post, raw),
211
+ test: test?
211
212
  )
212
213
  end
213
214
 
@@ -217,14 +218,7 @@ module ActiveMerchant
217
218
 
218
219
  def base_url
219
220
  if test?
220
- case @options[:region]
221
- when 'asia_pacific'
222
- test_ap_url
223
- when 'europe'
224
- test_eu_url
225
- when 'north_america', nil
226
- test_na_url
227
- end
221
+ test_url
228
222
  else
229
223
  case @options[:region]
230
224
  when 'asia_pacific'
@@ -11,7 +11,7 @@ module ActiveMerchant #:nodoc:
11
11
  self.supported_countries = ['BR']
12
12
  self.default_currency = 'BRL'
13
13
  self.money_format = :dollars
14
- self.supported_cardtypes = [:visa, :master, :discover, :american_express, :diners_club]
14
+ self.supported_cardtypes = %i[visa master discover american_express diners_club]
15
15
  self.homepage_url = 'http://www.maxipago.com/'
16
16
  self.display_name = 'maxiPago!'
17
17
 
@@ -212,7 +212,7 @@ module ActiveMerchant #:nodoc:
212
212
  end
213
213
 
214
214
  def add_order_id(xml, authorization)
215
- order_id, _ = split_authorization(authorization)
215
+ order_id, = split_authorization(authorization)
216
216
  xml.orderID order_id
217
217
  end
218
218
  end
@@ -3,19 +3,19 @@ module ActiveMerchant #:nodoc:
3
3
  class MercadoPagoGateway < Gateway
4
4
  self.live_url = self.test_url = 'https://api.mercadopago.com/v1'
5
5
 
6
- self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY']
7
- self.supported_cardtypes = [:visa, :master, :american_express, :elo, :cabal, :naranja]
6
+ self.supported_countries = %w[AR BR CL CO MX PE UY]
7
+ self.supported_cardtypes = %i[visa master american_express elo cabal naranja creditel]
8
8
 
9
9
  self.homepage_url = 'https://www.mercadopago.com/'
10
10
  self.display_name = 'Mercado Pago'
11
11
  self.money_format = :dollars
12
12
 
13
- def initialize(options={})
13
+ def initialize(options = {})
14
14
  requires!(options, :access_token)
15
15
  super
16
16
  end
17
17
 
18
- def purchase(money, payment, options={})
18
+ def purchase(money, payment, options = {})
19
19
  MultiResponse.run do |r|
20
20
  r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
21
21
  options[:card_token] = r.authorization.split('|').first
@@ -23,7 +23,7 @@ module ActiveMerchant #:nodoc:
23
23
  end
24
24
  end
25
25
 
26
- def authorize(money, payment, options={})
26
+ def authorize(money, payment, options = {})
27
27
  MultiResponse.run do |r|
28
28
  r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
29
29
  options[:card_token] = r.authorization.split('|').first
@@ -31,34 +31,40 @@ module ActiveMerchant #:nodoc:
31
31
  end
32
32
  end
33
33
 
34
- def capture(money, authorization, options={})
34
+ def capture(money, authorization, options = {})
35
35
  post = {}
36
- authorization, _ = authorization.split('|')
36
+ authorization, = authorization.split('|')
37
37
  post[:capture] = true
38
38
  post[:transaction_amount] = amount(money).to_f
39
39
  commit('capture', "payments/#{authorization}", post)
40
40
  end
41
41
 
42
- def refund(money, authorization, options={})
42
+ def refund(money, authorization, options = {})
43
43
  post = {}
44
44
  authorization, original_amount = authorization.split('|')
45
45
  post[:amount] = amount(money).to_f if original_amount && original_amount.to_f > amount(money).to_f
46
46
  commit('refund', "payments/#{authorization}/refunds", post)
47
47
  end
48
48
 
49
- def void(authorization, options={})
50
- authorization, _ = authorization.split('|')
49
+ def void(authorization, options = {})
50
+ authorization, = authorization.split('|')
51
51
  post = { status: 'cancelled' }
52
52
  commit('void', "payments/#{authorization}", post)
53
53
  end
54
54
 
55
- def verify(credit_card, options={})
55
+ def verify(credit_card, options = {})
56
+ verify_amount = 100
57
+ verify_amount = options[:amount].to_i if options[:amount]
56
58
  MultiResponse.run(:use_first_response) do |r|
57
- r.process { authorize(100, credit_card, options) }
59
+ r.process { authorize(verify_amount, credit_card, options) }
58
60
  r.process(:ignore_result) { void(r.authorization, options) }
59
61
  end
60
62
  end
61
63
 
64
+ def inquire(authorization, options = {})
65
+ commit('inquire', inquire_path(authorization, options), {})
66
+ end
67
+
62
68
  def supports_scrubbing?
63
69
  true
64
70
  end
@@ -96,25 +102,31 @@ module ActiveMerchant #:nodoc:
96
102
  add_customer_data(post, payment, options)
97
103
  add_address(post, options)
98
104
  add_processing_mode(post, options)
105
+ add_net_amount(post, options)
106
+ add_taxes(post, options)
107
+ add_notification_url(post, options)
99
108
  post[:binary_mode] = (options[:binary_mode].nil? ? true : options[:binary_mode])
100
109
  post
101
110
  end
102
111
 
103
112
  def authorize_request(money, payment, options = {})
104
113
  post = purchase_request(money, payment, options)
105
- post[:capture] = false
114
+ post[:capture] = options[:capture] || false
106
115
  post
107
116
  end
108
117
 
109
118
  def add_processing_mode(post, options)
110
119
  return unless options[:processing_mode]
120
+
111
121
  post[:processing_mode] = options[:processing_mode]
112
122
  post[:merchant_account_id] = options[:merchant_account_id] if options[:merchant_account_id]
123
+ post[:payment_method_option_id] = options[:payment_method_option_id] if options[:payment_method_option_id]
113
124
  add_merchant_services(post, options)
114
125
  end
115
126
 
116
127
  def add_merchant_services(post, options)
117
128
  return unless options[:fraud_scoring] || options[:fraud_manual_review]
129
+
118
130
  merchant_services = {}
119
131
  merchant_services[:fraud_scoring] = options[:fraud_scoring] if options[:fraud_scoring]
120
132
  merchant_services[:fraud_manual_review] = options[:fraud_manual_review] if options[:fraud_manual_review]
@@ -123,6 +135,7 @@ module ActiveMerchant #:nodoc:
123
135
 
124
136
  def add_additional_data(post, options)
125
137
  post[:sponsor_id] = options[:sponsor_id]
138
+ post[:metadata] = options[:metadata] if options[:metadata]
126
139
  post[:device_id] = options[:device_id] if options[:device_id]
127
140
  post[:additional_info] = {
128
141
  ip_address: options[:ip_address]
@@ -137,7 +150,7 @@ module ActiveMerchant #:nodoc:
137
150
  email: options[:email],
138
151
  first_name: payment.first_name,
139
152
  last_name: payment.last_name
140
- }
153
+ }.merge(options[:payer] || {})
141
154
  end
142
155
 
143
156
  def add_address(post, options)
@@ -185,7 +198,7 @@ module ActiveMerchant #:nodoc:
185
198
  post[:description] = options[:description]
186
199
  post[:installments] = options[:installments] ? options[:installments].to_i : 1
187
200
  post[:statement_descriptor] = options[:statement_descriptor] if options[:statement_descriptor]
188
- post[:external_reference] = options[:order_id] || SecureRandom.hex(16)
201
+ post[:external_reference] = options[:order_id] || options[:external_reference] || SecureRandom.hex(16)
189
202
  end
190
203
 
191
204
  def add_payment(post, options)
@@ -194,6 +207,51 @@ module ActiveMerchant #:nodoc:
194
207
  post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id]
195
208
  end
196
209
 
210
+ def add_net_amount(post, options)
211
+ post[:net_amount] = Float(options[:net_amount]) if options[:net_amount]
212
+ end
213
+
214
+ def add_notification_url(post, options)
215
+ post[:notification_url] = options[:notification_url] if options[:notification_url]
216
+ end
217
+
218
+ def add_taxes(post, options)
219
+ return unless (tax_object = options[:taxes])
220
+
221
+ if tax_object.is_a?(Array)
222
+ post[:taxes] = process_taxes_array(tax_object)
223
+ elsif tax_object.is_a?(Hash)
224
+ post[:taxes] = process_taxes_hash(tax_object)
225
+ else
226
+ raise taxes_error
227
+ end
228
+ end
229
+
230
+ def process_taxes_hash(tax_object)
231
+ [sanitize_taxes_hash(tax_object)]
232
+ end
233
+
234
+ def process_taxes_array(taxes_array)
235
+ taxes_array.map do |tax_object|
236
+ raise taxes_error unless tax_object.is_a?(Hash)
237
+
238
+ sanitize_taxes_hash(tax_object)
239
+ end
240
+ end
241
+
242
+ def sanitize_taxes_hash(tax_object)
243
+ tax_value = tax_object['value'] || tax_object[:value]
244
+ tax_type = tax_object['type'] || tax_object[:type]
245
+
246
+ raise taxes_error if tax_value.nil? || tax_type.nil?
247
+
248
+ { value: Float(tax_value), type: tax_type }
249
+ end
250
+
251
+ def taxes_error
252
+ ArgumentError.new("Taxes should be a single object or array of objects with the shape: { value: 500, type: 'IVA' }")
253
+ end
254
+
197
255
  def parse(body)
198
256
  JSON.parse(body)
199
257
  rescue JSON::ParserError
@@ -205,8 +263,12 @@ module ActiveMerchant #:nodoc:
205
263
  end
206
264
 
207
265
  def commit(action, path, parameters)
208
- if ['capture', 'void'].include?(action)
266
+ if %w[capture void].include?(action)
209
267
  response = parse(ssl_request(:put, url(path), post_data(parameters), headers))
268
+ elsif action == 'inquire'
269
+ response = parse(ssl_get(url(path), headers))
270
+
271
+ response = response[0]['results'][0] if response.is_a?(Array)
210
272
  else
211
273
  response = parse(ssl_post(url(path), post_data(parameters), headers(parameters)))
212
274
  end
@@ -225,7 +287,7 @@ module ActiveMerchant #:nodoc:
225
287
  if action == 'refund'
226
288
  response['status'] != 404 && response['error'].nil?
227
289
  else
228
- ['active', 'approved', 'authorized', 'cancelled', 'in_process'].include?(response['status'])
290
+ %w[active approved authorized cancelled in_process].include?(response['status'])
229
291
  end
230
292
  end
231
293
 
@@ -241,6 +303,15 @@ module ActiveMerchant #:nodoc:
241
303
  parameters.clone.tap { |p| p.delete(:device_id) }.to_json
242
304
  end
243
305
 
306
+ def inquire_path(authorization, options)
307
+ if authorization
308
+ authorization, = authorization.split('|')
309
+ "payments/#{authorization}"
310
+ else
311
+ "payments/search?external_reference=#{options[:order_id] || options[:external_reference]}"
312
+ end
313
+ end
314
+
244
315
  def error_code_from(action, response)
245
316
  unless success_from(action, response)
246
317
  if cause = response['cause']
@@ -260,7 +331,7 @@ module ActiveMerchant #:nodoc:
260
331
  headers = {
261
332
  'Content-Type' => 'application/json'
262
333
  }
263
- headers['X-Device-Session-ID'] = options[:device_id] if options[:device_id]
334
+ headers['X-meli-session-id'] = options[:device_id] if options[:device_id]
264
335
  headers
265
336
  end
266
337
 
@@ -10,7 +10,7 @@ module ActiveMerchant #:nodoc:
10
10
  self.supported_countries = ['US']
11
11
 
12
12
  # The card types supported by the payment gateway
13
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb]
13
+ self.supported_cardtypes = %i[visa master american_express discover jcb]
14
14
 
15
15
  # The homepage URL of the gateway
16
16
  self.homepage_url = 'http://www.merchante-solutions.com/'
@@ -18,6 +18,8 @@ module ActiveMerchant #:nodoc:
18
18
  # The name of the gateway
19
19
  self.display_name = 'Merchant e-Solutions'
20
20
 
21
+ SUCCESS_RESPONSE_CODES = %w(000 085)
22
+
21
23
  def initialize(options = {})
22
24
  requires!(options, :login, :password)
23
25
  super
@@ -25,28 +27,26 @@ module ActiveMerchant #:nodoc:
25
27
 
26
28
  def authorize(money, creditcard_or_card_id, options = {})
27
29
  post = {}
28
- post[:client_reference_number] = options[:customer] if options.has_key?(:customer)
29
- post[:moto_ecommerce_ind] = options[:moto_ecommerce_ind] if options.has_key?(:moto_ecommerce_ind)
30
30
  add_invoice(post, options)
31
31
  add_payment_source(post, creditcard_or_card_id, options)
32
32
  add_address(post, options)
33
33
  add_3dsecure_params(post, options)
34
+ add_stored_credentials(post, options)
34
35
  commit('P', money, post)
35
36
  end
36
37
 
37
38
  def purchase(money, creditcard_or_card_id, options = {})
38
39
  post = {}
39
- post[:client_reference_number] = options[:customer] if options.has_key?(:customer)
40
- post[:moto_ecommerce_ind] = options[:moto_ecommerce_ind] if options.has_key?(:moto_ecommerce_ind)
41
40
  add_invoice(post, options)
42
41
  add_payment_source(post, creditcard_or_card_id, options)
43
42
  add_address(post, options)
44
43
  add_3dsecure_params(post, options)
44
+ add_stored_credentials(post, options)
45
45
  commit('D', money, post)
46
46
  end
47
47
 
48
48
  def capture(money, transaction_id, options = {})
49
- post ={}
49
+ post = {}
50
50
  post[:transaction_id] = transaction_id
51
51
  post[:client_reference_number] = options[:customer] if options.has_key?(:customer)
52
52
  add_invoice(post, options)
@@ -55,10 +55,10 @@ module ActiveMerchant #:nodoc:
55
55
  end
56
56
 
57
57
  def store(creditcard, options = {})
58
- post = {}
59
- post[:client_reference_number] = options[:customer] if options.has_key?(:customer)
60
- add_creditcard(post, creditcard, options)
61
- commit('T', nil, post)
58
+ MultiResponse.run do |r|
59
+ r.process { temporary_store(creditcard, options) }
60
+ r.process { verify(r.authorization, { store_card: 'y' }) }
61
+ end
62
62
  end
63
63
 
64
64
  def unstore(card_id, options = {})
@@ -94,6 +94,13 @@ module ActiveMerchant #:nodoc:
94
94
  commit('V', nil, options.merge(post))
95
95
  end
96
96
 
97
+ def verify(credit_card, options = {})
98
+ post = {}
99
+ post[:store_card] = options[:store_card] if options[:store_card]
100
+ add_payment_source(post, credit_card, options)
101
+ commit('A', 0, post)
102
+ end
103
+
97
104
  def supports_scrubbing?
98
105
  true
99
106
  end
@@ -107,6 +114,13 @@ module ActiveMerchant #:nodoc:
107
114
 
108
115
  private
109
116
 
117
+ def temporary_store(creditcard, options = {})
118
+ post = {}
119
+ post[:client_reference_number] = options[:customer] if options.has_key?(:customer)
120
+ add_creditcard(post, creditcard, options)
121
+ commit('T', nil, post)
122
+ end
123
+
110
124
  def add_address(post, options)
111
125
  if address = options[:billing_address] || options[:address]
112
126
  post[:cardholder_street_address] = address[:address1].to_s.gsub(/[^\w.]/, '+')
@@ -133,9 +147,9 @@ module ActiveMerchant #:nodoc:
133
147
  end
134
148
 
135
149
  def add_creditcard(post, creditcard, options)
136
- post[:card_number] = creditcard.number
150
+ post[:card_number] = creditcard.number
137
151
  post[:cvv2] = creditcard.verification_value if creditcard.verification_value?
138
- post[:card_exp_date] = expdate(creditcard)
152
+ post[:card_exp_date] = expdate(creditcard)
139
153
  end
140
154
 
141
155
  def add_3dsecure_params(post, options)
@@ -145,6 +159,16 @@ module ActiveMerchant #:nodoc:
145
159
  post[:ucaf_auth_data] = options[:ucaf_auth_data] unless empty?(options[:ucaf_auth_data])
146
160
  end
147
161
 
162
+ def add_stored_credentials(post, options)
163
+ post[:client_reference_number] = options[:client_reference_number] if options[:client_reference_number]
164
+ post[:moto_ecommerce_ind] = options[:moto_ecommerce_ind] if options[:moto_ecommerce_ind]
165
+ post[:recurring_pmt_num] = options[:recurring_pmt_num] if options[:recurring_pmt_num]
166
+ post[:recurring_pmt_count] = options[:recurring_pmt_count] if options[:recurring_pmt_count]
167
+ post[:card_on_file] = options[:card_on_file] if options[:card_on_file]
168
+ post[:cit_mit_indicator] = options[:cit_mit_indicator] if options[:cit_mit_indicator]
169
+ post[:account_data_source] = options[:account_data_source] if options[:account_data_source]
170
+ end
171
+
148
172
  def parse(body)
149
173
  results = {}
150
174
  body.split(/&/).each do |pair|
@@ -156,20 +180,30 @@ module ActiveMerchant #:nodoc:
156
180
 
157
181
  def commit(action, money, parameters)
158
182
  url = test? ? self.test_url : self.live_url
159
- parameters[:transaction_amount] = amount(money) if money unless action == 'V'
183
+ parameters[:transaction_amount] = amount(money) if money unless action == 'V'
160
184
 
161
- response = begin
162
- parse(ssl_post(url, post_data(action, parameters)))
163
- rescue ActiveMerchant::ResponseError => e
164
- { 'error_code' => '404', 'auth_response_text' => e.to_s }
165
- end
185
+ response =
186
+ begin
187
+ parse(ssl_post(url, post_data(action, parameters)))
188
+ rescue ActiveMerchant::ResponseError => e
189
+ { 'error_code' => '404', 'auth_response_text' => e.to_s }
190
+ end
191
+
192
+ Response.new(success_from(response), message_from(response), response,
193
+ authorization: authorization_from(response),
194
+ test: test?,
195
+ cvv_result: response['cvv2_result'],
196
+ avs_result: { code: response['avs_result'] })
197
+ end
198
+
199
+ def authorization_from(response)
200
+ return response['card_id'] if response['card_id']
201
+
202
+ response['transaction_id']
203
+ end
166
204
 
167
- Response.new(response['error_code'] == '000', message_from(response), response,
168
- :authorization => response['transaction_id'],
169
- :test => test?,
170
- :cvv_result => response['cvv2_result'],
171
- :avs_result => { :code => response['avs_result'] }
172
- )
205
+ def success_from(response)
206
+ SUCCESS_RESPONSE_CODES.include?(response['error_code'])
173
207
  end
174
208
 
175
209
  def message_from(response)
@@ -3,7 +3,6 @@ require 'cgi'
3
3
  module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
5
  class MerchantOneGateway < Gateway
6
-
7
6
  class MerchantOneSslConnection < ActiveMerchant::Connection
8
7
  def configure_ssl(http)
9
8
  super(http)
@@ -14,7 +13,7 @@ module ActiveMerchant #:nodoc:
14
13
  BASE_URL = 'https://secure.merchantonegateway.com/api/transact.php'
15
14
 
16
15
  self.supported_countries = ['US']
17
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
16
+ self.supported_cardtypes = %i[visa master american_express discover]
18
17
  self.homepage_url = 'http://merchantone.com/'
19
18
  self.display_name = 'Merchant One Gateway'
20
19
  self.money_format = :dollars
@@ -77,10 +76,10 @@ module ActiveMerchant #:nodoc:
77
76
  def add_creditcard(post, creditcard)
78
77
  post['cvv'] = creditcard.verification_value
79
78
  post['ccnumber'] = creditcard.number
80
- post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{creditcard.year.to_s[-2, 2]}"
79
+ post['ccexp'] = "#{sprintf('%02d', creditcard.month)}#{creditcard.year.to_s[-2, 2]}"
81
80
  end
82
81
 
83
- def commit(action, money, parameters={})
82
+ def commit(action, money, parameters = {})
84
83
  parameters['username'] = @options[:username]
85
84
  parameters['password'] = @options[:password]
86
85
  parse(ssl_post(BASE_URL, post_data(action, parameters)))
@@ -91,21 +90,19 @@ module ActiveMerchant #:nodoc:
91
90
  ret = ''
92
91
  for key in parameters.keys
93
92
  ret += "#{key}=#{CGI.escape(parameters[key].to_s)}"
94
- if key != parameters.keys.last
95
- ret += '&'
96
- end
93
+ ret += '&' if key != parameters.keys.last
97
94
  end
98
95
  ret.to_s
99
96
  end
100
97
 
101
98
  def parse(data)
102
- responses = CGI.parse(data).inject({}) { |h, (k, v)| h[k] = v.first; h }
99
+ responses = CGI.parse(data).inject({}) { |h, (k, v)| h[k] = v.first; h }
103
100
  Response.new(
104
101
  (responses['response'].to_i == 1),
105
102
  responses['responsetext'],
106
103
  responses,
107
- :test => test?,
108
- :authorization => responses['transactionid']
104
+ test: test?,
105
+ authorization: responses['transactionid']
109
106
  )
110
107
  end
111
108
  end