activemerchant 1.79.2 → 1.129.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +1391 -0
  3. data/README.md +29 -14
  4. data/lib/active_merchant/billing/avs_result.rb +25 -28
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +55 -22
  7. data/lib/active_merchant/billing/compatibility.rb +10 -12
  8. data/lib/active_merchant/billing/credit_card.rb +82 -62
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  10. data/lib/active_merchant/billing/credit_card_methods.rb +328 -58
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +61 -56
  13. data/lib/active_merchant/billing/gateways/adyen.rb +562 -87
  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 +35 -36
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +297 -196
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +94 -98
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +64 -66
  21. data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
  24. data/lib/active_merchant/billing/gateways/banwire.rb +12 -12
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +140 -69
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +115 -115
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +39 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -2
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +87 -58
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +405 -104
  33. data/lib/active_merchant/billing/gateways/bogus.rb +34 -30
  34. data/lib/active_merchant/billing/gateways/borgun.rb +97 -47
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +20 -20
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -3
  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 +561 -259
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +53 -54
  42. data/lib/active_merchant/billing/gateways/cams.rb +31 -31
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +85 -33
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +187 -169
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +24 -25
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +9 -7
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +43 -27
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +62 -52
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +63 -62
  52. data/lib/active_merchant/billing/gateways/checkout.rb +21 -23
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +391 -113
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -3
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +40 -41
  56. data/lib/active_merchant/billing/gateways/commerce_hub.rb +361 -0
  57. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  58. data/lib/active_merchant/billing/gateways/conekta.rb +35 -30
  59. data/lib/active_merchant/billing/gateways/creditcall.rb +59 -59
  60. data/lib/active_merchant/billing/gateways/credorax.rb +326 -145
  61. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  62. data/lib/active_merchant/billing/gateways/culqi.rb +53 -53
  63. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  64. data/lib/active_merchant/billing/gateways/cyber_source.rb +566 -208
  65. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +456 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +342 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +40 -56
  68. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  69. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  70. data/lib/active_merchant/billing/gateways/dibs.rb +34 -40
  71. data/lib/active_merchant/billing/gateways/digitzs.rb +48 -45
  72. data/lib/active_merchant/billing/gateways/ebanx.rb +110 -60
  73. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  74. data/lib/active_merchant/billing/gateways/elavon.rb +351 -189
  75. data/lib/active_merchant/billing/gateways/element.rb +106 -56
  76. data/lib/active_merchant/billing/gateways/epay.rb +74 -64
  77. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  78. data/lib/active_merchant/billing/gateways/eway.rb +74 -73
  79. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  80. data/lib/active_merchant/billing/gateways/eway_rapid.rb +105 -60
  81. data/lib/active_merchant/billing/gateways/exact.rb +29 -37
  82. data/lib/active_merchant/billing/gateways/ezic.rb +21 -22
  83. data/lib/active_merchant/billing/gateways/fat_zebra.rb +70 -48
  84. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  85. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -4
  86. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  87. data/lib/active_merchant/billing/gateways/first_pay.rb +33 -13
  88. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +106 -105
  89. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash.rb +36 -36
  91. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +2 -2
  92. data/lib/active_merchant/billing/gateways/forte.rb +70 -40
  93. data/lib/active_merchant/billing/gateways/garanti.rb +24 -31
  94. data/lib/active_merchant/billing/gateways/global_collect.rb +378 -154
  95. data/lib/active_merchant/billing/gateways/global_transport.rb +12 -13
  96. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  97. data/lib/active_merchant/billing/gateways/hps.rb +236 -69
  98. data/lib/active_merchant/billing/gateways/iats_payments.rb +61 -39
  99. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  100. data/lib/active_merchant/billing/gateways/inspire.rb +41 -47
  101. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  102. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  103. data/lib/active_merchant/billing/gateways/ipp.rb +25 -24
  104. data/lib/active_merchant/billing/gateways/iridium.rb +243 -244
  105. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  106. data/lib/active_merchant/billing/gateways/iveri.rb +73 -34
  107. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  108. data/lib/active_merchant/billing/gateways/jetpay.rb +145 -152
  109. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +154 -159
  110. data/lib/active_merchant/billing/gateways/komoju.rb +16 -16
  111. data/lib/active_merchant/billing/gateways/kushki.rb +127 -57
  112. data/lib/active_merchant/billing/gateways/latitude19.rb +111 -115
  113. data/lib/active_merchant/billing/gateways/linkpoint.rb +82 -85
  114. data/lib/active_merchant/billing/gateways/litle.rb +247 -53
  115. data/lib/active_merchant/billing/gateways/mastercard.rb +41 -23
  116. data/lib/active_merchant/billing/gateways/maxipago.rb +5 -5
  117. data/lib/active_merchant/billing/gateways/mercado_pago.rb +135 -49
  118. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +62 -29
  119. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  120. data/lib/active_merchant/billing/gateways/merchant_partners.rb +40 -40
  121. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  122. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +42 -44
  123. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +52 -14
  124. data/lib/active_merchant/billing/gateways/mercury.rb +47 -51
  125. data/lib/active_merchant/billing/gateways/metrics_global.rb +32 -42
  126. data/lib/active_merchant/billing/gateways/micropayment.rb +42 -45
  127. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  128. data/lib/active_merchant/billing/gateways/migs.rb +45 -40
  129. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  130. data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -2
  131. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +29 -31
  132. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  133. data/lib/active_merchant/billing/gateways/monei.rb +255 -138
  134. data/lib/active_merchant/billing/gateways/moneris.rb +226 -88
  135. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  136. data/lib/active_merchant/billing/gateways/mundipagg.rb +117 -43
  137. data/lib/active_merchant/billing/gateways/nab_transact.rb +28 -31
  138. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +13 -15
  139. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  140. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  141. data/lib/active_merchant/billing/gateways/netbanx.rb +167 -80
  142. data/lib/active_merchant/billing/gateways/netbilling.rb +27 -30
  143. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  144. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  145. data/lib/active_merchant/billing/gateways/nmi.rb +134 -48
  146. data/lib/active_merchant/billing/gateways/ogone.rb +88 -58
  147. data/lib/active_merchant/billing/gateways/omise.rb +30 -31
  148. data/lib/active_merchant/billing/gateways/openpay.rb +45 -26
  149. data/lib/active_merchant/billing/gateways/opp.rb +166 -144
  150. data/lib/active_merchant/billing/gateways/optimal_payment.rb +67 -64
  151. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  152. data/lib/active_merchant/billing/gateways/orbital.rb +726 -382
  153. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +26 -27
  154. data/lib/active_merchant/billing/gateways/pagarme.rb +47 -56
  155. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  156. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  157. data/lib/active_merchant/billing/gateways/pay_conex.rb +39 -40
  158. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +65 -65
  159. data/lib/active_merchant/billing/gateways/pay_hub.rb +39 -39
  160. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  161. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +70 -54
  162. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  163. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  164. data/lib/active_merchant/billing/gateways/paybox_direct.rb +71 -47
  165. data/lib/active_merchant/billing/gateways/payeezy.rb +159 -32
  166. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  167. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +41 -36
  168. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  169. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  170. data/lib/active_merchant/billing/gateways/payflow.rb +178 -54
  171. data/lib/active_merchant/billing/gateways/payflow_express.rb +61 -65
  172. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +0 -1
  173. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -2
  174. data/lib/active_merchant/billing/gateways/payment_express.rb +66 -58
  175. data/lib/active_merchant/billing/gateways/paymentez.rb +114 -25
  176. data/lib/active_merchant/billing/gateways/paymill.rb +134 -133
  177. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  178. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  179. data/lib/active_merchant/billing/gateways/paypal.rb +27 -14
  180. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  181. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +2 -2
  182. data/lib/active_merchant/billing/gateways/paypal_express.rb +5 -2
  183. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  185. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  186. data/lib/active_merchant/billing/gateways/paystation.rb +79 -82
  187. data/lib/active_merchant/billing/gateways/payu_in.rb +59 -58
  188. data/lib/active_merchant/billing/gateways/payu_latam.rb +139 -97
  189. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  190. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  191. data/lib/active_merchant/billing/gateways/pin.rb +87 -34
  192. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  193. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  194. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  195. data/lib/active_merchant/billing/gateways/pro_pay.rb +139 -140
  196. data/lib/active_merchant/billing/gateways/psigate.rb +44 -44
  197. data/lib/active_merchant/billing/gateways/psl_card.rb +29 -37
  198. data/lib/active_merchant/billing/gateways/qbms.rb +75 -76
  199. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  200. data/lib/active_merchant/billing/gateways/quickbooks.rb +142 -55
  201. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +103 -107
  202. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +156 -158
  203. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +7 -8
  204. data/lib/active_merchant/billing/gateways/quickpay.rb +1 -3
  205. data/lib/active_merchant/billing/gateways/qvalent.rb +137 -68
  206. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  207. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  208. data/lib/active_merchant/billing/gateways/realex.rb +132 -50
  209. data/lib/active_merchant/billing/gateways/redsys.rb +382 -186
  210. data/lib/active_merchant/billing/gateways/s5.rb +16 -16
  211. data/lib/active_merchant/billing/gateways/safe_charge.rb +83 -47
  212. data/lib/active_merchant/billing/gateways/sage.rb +49 -48
  213. data/lib/active_merchant/billing/gateways/sage_pay.rb +76 -83
  214. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  215. data/lib/active_merchant/billing/gateways/secure_net.rb +32 -40
  216. data/lib/active_merchant/billing/gateways/secure_pay.rb +30 -40
  217. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +23 -26
  218. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  219. data/lib/active_merchant/billing/gateways/securion_pay.rb +69 -31
  220. data/lib/active_merchant/billing/gateways/shift4.rb +342 -0
  221. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  222. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -53
  223. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  224. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  225. data/lib/active_merchant/billing/gateways/spreedly_core.rb +66 -47
  226. data/lib/active_merchant/billing/gateways/stripe.rb +309 -148
  227. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +556 -0
  228. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +18 -23
  229. data/lib/active_merchant/billing/gateways/telr.rb +46 -48
  230. data/lib/active_merchant/billing/gateways/tns.rb +8 -7
  231. data/lib/active_merchant/billing/gateways/trans_first.rb +37 -37
  232. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +249 -245
  233. data/lib/active_merchant/billing/gateways/transact_pro.rb +25 -27
  234. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  235. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  236. data/lib/active_merchant/billing/gateways/trexle.rb +22 -18
  237. data/lib/active_merchant/billing/gateways/trust_commerce.rb +161 -88
  238. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  239. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +231 -238
  240. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +129 -55
  241. data/lib/active_merchant/billing/gateways/vanco.rb +42 -33
  242. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  243. data/lib/active_merchant/billing/gateways/viaklix.rb +18 -22
  244. data/lib/active_merchant/billing/gateways/visanet_peru.rb +115 -74
  245. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  246. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  247. data/lib/active_merchant/billing/gateways/wepay.rb +38 -41
  248. data/lib/active_merchant/billing/gateways/wirecard.rb +36 -37
  249. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  250. data/lib/active_merchant/billing/gateways/world_net.rb +39 -38
  251. data/lib/active_merchant/billing/gateways/worldpay.rb +756 -142
  252. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +73 -83
  253. data/lib/active_merchant/billing/gateways/worldpay_us.rb +31 -31
  254. data/lib/active_merchant/billing/model.rb +2 -2
  255. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +3 -3
  256. data/lib/active_merchant/billing/rails.rb +1 -1
  257. data/lib/active_merchant/billing/response.rb +32 -13
  258. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  259. data/lib/active_merchant/billing.rb +1 -0
  260. data/lib/active_merchant/connection.rb +24 -38
  261. data/lib/active_merchant/country.rb +9 -5
  262. data/lib/active_merchant/errors.rb +4 -1
  263. data/lib/active_merchant/net_http_ssl_connection.rb +2 -0
  264. data/lib/active_merchant/network_connection_retries.rb +28 -31
  265. data/lib/active_merchant/post_data.rb +5 -3
  266. data/lib/active_merchant/posts_data.rb +5 -7
  267. data/lib/active_merchant/version.rb +1 -1
  268. data/lib/active_merchant.rb +3 -3
  269. data/lib/activemerchant.rb +1 -1
  270. data/lib/certs/cacert.pem +1592 -2329
  271. data/lib/support/gateway_support.rb +8 -10
  272. data/lib/support/ssl_verify.rb +9 -14
  273. data/lib/support/ssl_version.rb +9 -10
  274. metadata +98 -37
  275. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  278. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  279. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -309
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  require 'rexml/document'
3
4
 
4
5
  module ActiveMerchant #:nodoc:
@@ -119,25 +120,23 @@ module ActiveMerchant #:nodoc:
119
120
  'KO' => 'N',
120
121
  'NO' => 'R' }
121
122
 
122
- SUCCESS_MESSAGE = "The transaction was successful"
123
+ SUCCESS_MESSAGE = 'The transaction was successful'
124
+
125
+ THREE_D_SECURE_DISPLAY_WAYS = { main_window: 'MAINW', # display the identification page in the main window (default value).
123
126
 
124
- THREE_D_SECURE_DISPLAY_WAYS = { :main_window => 'MAINW', # display the identification page in the main window
125
- # (default value).
126
- :pop_up => 'POPUP', # display the identification page in a pop-up window
127
- # and return to the main window at the end.
128
- :pop_ix => 'POPIX' } # display the identification page in a pop-up window
129
- # and remain in the pop-up window.
127
+ pop_up: 'POPUP', # display the identification page in a pop-up window and return to the main window at the end.
128
+ pop_ix: 'POPIX' } # display the identification page in a pop-up window and remain in the pop-up window.
130
129
 
131
- OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE = "Signature usage will be the default for a future release of ActiveMerchant. You should either begin using it, or update your configuration to explicitly disable it (signature_encryptor: none)"
130
+ OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE = 'Signature usage will be the default for a future release of ActiveMerchant. You should either begin using it, or update your configuration to explicitly disable it (signature_encryptor: none)'
132
131
  OGONE_STORE_OPTION_DEPRECATION_MESSAGE = "The 'store' option has been renamed to 'billing_id', and its usage is deprecated."
133
132
 
134
- self.test_url = "https://secure.ogone.com/ncol/test/"
135
- self.live_url = "https://secure.ogone.com/ncol/prod/"
133
+ self.test_url = 'https://secure.ogone.com/ncol/test/'
134
+ self.live_url = 'https://secure.ogone.com/ncol/prod/'
136
135
 
137
- self.supported_countries = ['BE', 'DE', 'FR', 'NL', 'AT', 'CH']
136
+ self.supported_countries = %w[BE DE FR NL AT CH]
138
137
  # also supports Airplus and UATP
139
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro]
140
- self.homepage_url = 'http://www.ogone.com/'
138
+ self.supported_cardtypes = %i[visa master american_express diners_club discover jcb maestro]
139
+ self.homepage_url = 'https://www.ingenico.com/login/ogone/'
141
140
  self.display_name = 'Ogone'
142
141
  self.default_currency = 'EUR'
143
142
  self.money_format = :cents
@@ -150,7 +149,7 @@ module ActiveMerchant #:nodoc:
150
149
  # Verify and reserve the specified amount on the account, without actually doing the transaction.
151
150
  def authorize(money, payment_source, options = {})
152
151
  post = {}
153
- action = (payment_source.brand == "mastercard") ? "PAU" : "RES"
152
+ action = payment_source.brand == 'mastercard' ? 'PAU' : 'RES'
154
153
  add_invoice(post, options)
155
154
  add_payment_source(post, payment_source, options)
156
155
  add_address(post, payment_source, options)
@@ -205,7 +204,7 @@ module ActiveMerchant #:nodoc:
205
204
  perform_reference_credit(money, reference, options)
206
205
  end
207
206
 
208
- def verify(credit_card, options={})
207
+ def verify(credit_card, options = {})
209
208
  MultiResponse.run(:use_first_response) do |r|
210
209
  r.process { authorize(100, credit_card, options) }
211
210
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -214,7 +213,7 @@ module ActiveMerchant #:nodoc:
214
213
 
215
214
  # Store a credit card by creating an Ogone Alias
216
215
  def store(payment_source, options = {})
217
- options.merge!(:alias_operation => 'BYPSP') unless(options.has_key?(:billing_id) || options.has_key?(:store))
216
+ options[:alias_operation] = 'BYPSP' unless options.has_key?(:billing_id) || options.has_key?(:store)
218
217
  response = authorize(@options[:store_amount] || 1, payment_source, options)
219
218
  void(response.authorization) if response.success?
220
219
  response
@@ -226,21 +225,22 @@ module ActiveMerchant #:nodoc:
226
225
 
227
226
  def scrub(transcript)
228
227
  transcript.
229
- gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
230
- gsub(%r((&?cardno=)[^&]*)i, '\1[FILTERED]').
231
- gsub(%r((&?cvc=)[^&]*)i, '\1[FILTERED]').
232
- gsub(%r((&?pswd=)[^&]*)i, '\1[FILTERED]')
228
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
229
+ gsub(%r((&?cardno=)[^&]*)i, '\1[FILTERED]').
230
+ gsub(%r((&?cvc=)[^&]*)i, '\1[FILTERED]').
231
+ gsub(%r((&?pswd=)[^&]*)i, '\1[FILTERED]')
233
232
  end
234
233
 
235
234
  private
236
235
 
237
236
  def reference_from(authorization)
238
- authorization.split(";").first
237
+ authorization.split(';').first
239
238
  end
240
239
 
241
240
  def reference_transaction?(identifier)
242
241
  return false unless identifier.is_a?(String)
243
- _, action = identifier.split(";")
242
+
243
+ _, action = identifier.split(';')
244
244
  !action.nil?
245
245
  end
246
246
 
@@ -264,7 +264,6 @@ module ActiveMerchant #:nodoc:
264
264
 
265
265
  def add_payment_source(post, payment_source, options)
266
266
  add_d3d(post, options) if options[:d3d]
267
-
268
267
  if payment_source.is_a?(String)
269
268
  add_alias(post, payment_source, options[:alias_operation])
270
269
  add_eci(post, options[:eci] || '9')
@@ -285,25 +284,54 @@ module ActiveMerchant #:nodoc:
285
284
  THREE_D_SECURE_DISPLAY_WAYS[options[:win_3ds]] :
286
285
  THREE_D_SECURE_DISPLAY_WAYS[:main_window]
287
286
  add_pair post, 'WIN3DS', win_3ds
288
-
289
- add_pair post, 'HTTP_ACCEPT', options[:http_accept] || "*/*"
290
287
  add_pair post, 'HTTP_USER_AGENT', options[:http_user_agent] if options[:http_user_agent]
291
288
  add_pair post, 'ACCEPTURL', options[:accept_url] if options[:accept_url]
292
289
  add_pair post, 'DECLINEURL', options[:decline_url] if options[:decline_url]
293
290
  add_pair post, 'EXCEPTIONURL', options[:exception_url] if options[:exception_url]
294
291
  add_pair post, 'CANCELURL', options[:cancel_url] if options[:cancel_url]
295
- add_pair post, 'PARAMVAR', options[:paramvar] if options[:paramvar]
292
+ add_pair post, 'PARAMVAR', options[:paramvar] if options[:paramvar]
296
293
  add_pair post, 'PARAMPLUS', options[:paramplus] if options[:paramplus]
297
294
  add_pair post, 'COMPLUS', options[:complus] if options[:complus]
298
295
  add_pair post, 'LANGUAGE', options[:language] if options[:language]
296
+ if options[:three_ds_2]
297
+ browser_info = options[:three_ds_2][:browser_info]
298
+ ecom_postal = options[:billing_address]
299
+ if browser_info
300
+ add_pair post, 'BROWSERACCEPTHEADER', browser_info[:accept_header]
301
+ add_pair post, 'BROWSERCOLORDEPTH', browser_info[:depth]
302
+
303
+ # for 3ds v2.1 to v2.2 add BROWSERJAVASCRIPTENABLED: This boolean indicates whether your customers have enabled JavaScript in their browsers when making a purchase.
304
+ # the following BROWSER<tag> parameters will remain mandatory unless browser_info[:javascript] = false
305
+ # her documentation https://epayments-support.ingenico.com/en/integration-solutions/integrations/directlink#directlink_integration_guides_secure_payment_with_3_d_secure
306
+ add_pair post, 'BROWSERJAVASCRIPTENABLED', browser_info[:javascript]
307
+ add_pair post, 'BROWSERJAVAENABLED', browser_info[:java]
308
+ add_pair post, 'BROWSERLANGUAGE', browser_info[:language]
309
+ add_pair post, 'BROWSERSCREENHEIGHT', browser_info[:height]
310
+ add_pair post, 'BROWSERSCREENWIDTH', browser_info[:width]
311
+ add_pair post, 'BROWSERTIMEZONE', browser_info[:timezone]
312
+ add_pair post, 'BROWSERUSERAGENT', browser_info[:user_agent]
313
+ end
314
+ # recommended
315
+ if ecom_postal
316
+ add_pair post, 'ECOM_BILLTO_POSTAL_CITY', ecom_postal[:city]
317
+ add_pair post, 'ECOM_BILLTO_POSTAL_COUNTRYCODE', ecom_postal[:country]
318
+ add_pair post, 'ECOM_BILLTO_POSTAL_STREET_LINE1', ecom_postal[:address1]
319
+ add_pair post, 'ECOM_BILLTO_POSTAL_STREET_LINE2', ecom_postal[:address2]
320
+ add_pair post, 'ECOM_BILLTO_POSTAL_POSTALCODE', ecom_postal[:zip]
321
+ end
322
+ # optional
323
+ add_pair post, 'Mpi.threeDSRequestorChallengeIndicator', options[:three_ds_reqchallengeind]
324
+ else
325
+ add_pair post, 'HTTP_ACCEPT', options[:http_accept] || '*/*'
326
+ end
299
327
  end
300
328
 
301
329
  def add_eci(post, eci)
302
330
  add_pair post, 'ECI', eci.to_s
303
331
  end
304
332
 
305
- def add_alias(post, _alias, alias_operation = nil)
306
- add_pair post, 'ALIAS', _alias
333
+ def add_alias(post, alias_name, alias_operation = nil)
334
+ add_pair post, 'ALIAS', alias_name
307
335
  add_pair post, 'ALIASOPERATION', alias_operation unless alias_operation.nil?
308
336
  end
309
337
 
@@ -323,6 +351,7 @@ module ActiveMerchant #:nodoc:
323
351
 
324
352
  def add_address(post, creditcard, options)
325
353
  return unless options[:billing_address]
354
+
326
355
  add_pair post, 'Owneraddress', options[:billing_address][:address1]
327
356
  add_pair post, 'OwnerZip', options[:billing_address][:zip]
328
357
  add_pair post, 'ownertown', options[:billing_address][:city]
@@ -339,7 +368,7 @@ module ActiveMerchant #:nodoc:
339
368
  def add_creditcard(post, creditcard)
340
369
  add_pair post, 'CN', creditcard.name
341
370
  add_pair post, 'CARDNO', creditcard.number
342
- add_pair post, 'ED', "%02d%02s" % [creditcard.month, creditcard.year.to_s[-2..-1]]
371
+ add_pair post, 'ED', '%02d%02s' % [creditcard.month, creditcard.year.to_s[-2..-1]]
343
372
  add_pair post, 'CVC', creditcard.verification_value
344
373
  end
345
374
 
@@ -349,8 +378,8 @@ module ActiveMerchant #:nodoc:
349
378
 
350
379
  # Add HTML_ANSWER element (3-D Secure specific to the response's params)
351
380
  # Note: HTML_ANSWER is not an attribute so we add it "by hand" to the response
352
- if html_answer = REXML::XPath.first(xml_root, "//HTML_ANSWER")
353
- response["HTML_ANSWER"] = html_answer.text
381
+ if html_answer = REXML::XPath.first(xml_root, '//HTML_ANSWER')
382
+ response['HTML_ANSWER'] = html_answer.text
354
383
  end
355
384
 
356
385
  response
@@ -365,27 +394,27 @@ module ActiveMerchant #:nodoc:
365
394
  response = parse(ssl_post(url(parameters['PAYID']), post_data(action, parameters)))
366
395
 
367
396
  options = {
368
- :authorization => [response["PAYID"], action].join(";"),
369
- :test => test?,
370
- :avs_result => { :code => AVS_MAPPING[response["AAVCheck"]] },
371
- :cvv_result => CVV_MAPPING[response["CVCCheck"]]
397
+ authorization: [response['PAYID'], action].join(';'),
398
+ test: test?,
399
+ avs_result: { code: AVS_MAPPING[response['AAVCheck']] },
400
+ cvv_result: CVV_MAPPING[response['CVCCheck']]
372
401
  }
373
402
  OgoneResponse.new(successful?(response), message_from(response), response, options)
374
403
  end
375
404
 
376
405
  def url(payid)
377
- (test? ? test_url : live_url) + (payid ? "maintenancedirect.asp" : "orderdirect.asp")
406
+ (test? ? test_url : live_url) + (payid ? 'maintenancedirect.asp' : 'orderdirect.asp')
378
407
  end
379
408
 
380
409
  def successful?(response)
381
- response["NCERROR"] == "0"
410
+ response['NCERROR'] == '0'
382
411
  end
383
412
 
384
413
  def message_from(response)
385
414
  if successful?(response)
386
415
  SUCCESS_MESSAGE
387
416
  else
388
- format_error_message(response["NCERRORPLUS"])
417
+ format_error_message(response['NCERRORPLUS'])
389
418
  end
390
419
  end
391
420
 
@@ -393,9 +422,9 @@ module ActiveMerchant #:nodoc:
393
422
  raw_message = message.to_s.strip
394
423
  case raw_message
395
424
  when /\|/
396
- raw_message.split("|").join(", ").capitalize
425
+ raw_message.split('|').join(', ').capitalize
397
426
  when /\//
398
- raw_message.split("/").first.to_s.capitalize
427
+ raw_message.split('/').first.to_s.capitalize
399
428
  else
400
429
  raw_message.to_s.capitalize
401
430
  end
@@ -409,30 +438,31 @@ module ActiveMerchant #:nodoc:
409
438
 
410
439
  def add_signature(parameters)
411
440
  if @options[:signature].blank?
412
- ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == "none")
413
- return
441
+ ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless @options[:signature_encryptor] == 'none'
442
+ return
414
443
  end
415
444
 
416
- add_pair parameters, 'SHASign', calculate_signature(parameters, @options[:signature_encryptor], @options[:signature])
445
+ add_pair parameters, 'SHASIGN', calculate_signature(parameters, @options[:signature_encryptor], @options[:signature])
417
446
  end
418
447
 
419
448
  def calculate_signature(signed_parameters, algorithm, secret)
420
449
  return legacy_calculate_signature(signed_parameters, secret) unless algorithm
421
450
 
422
- sha_encryptor = case algorithm
423
- when 'sha256'
424
- Digest::SHA256
425
- when 'sha512'
426
- Digest::SHA512
427
- when 'sha1'
428
- Digest::SHA1
429
- else
430
- raise "Unknown signature algorithm #{algorithm}"
431
- end
451
+ sha_encryptor =
452
+ case algorithm
453
+ when 'sha256'
454
+ Digest::SHA256
455
+ when 'sha512'
456
+ Digest::SHA512
457
+ when 'sha1'
458
+ Digest::SHA1
459
+ else
460
+ raise "Unknown signature algorithm #{algorithm}"
461
+ end
432
462
 
433
- filtered_params = signed_parameters.select{|k,v| !v.blank?}
463
+ filtered_params = signed_parameters.compact
434
464
  sha_encryptor.hexdigest(
435
- filtered_params.sort_by{|k,v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join("")
465
+ filtered_params.sort_by { |k, _v| k.upcase }.map { |k, v| "#{k.upcase}=#{v}#{secret}" }.join('')
436
466
  ).upcase
437
467
  end
438
468
 
@@ -447,14 +477,14 @@ module ActiveMerchant #:nodoc:
447
477
  PSPID
448
478
  Operation
449
479
  ALIAS
450
- ).map{|key| parameters[key]} +
480
+ ).map { |key| parameters[key] } +
451
481
  [secret]
452
- ).join("")
482
+ ).join('')
453
483
  ).upcase
454
484
  end
455
485
 
456
486
  def add_pair(post, key, value)
457
- post[key] = value if !value.blank?
487
+ post[key] = value unless value.nil?
458
488
  end
459
489
 
460
490
  def convert_attributes_to_hash(rexml_attributes)
@@ -19,15 +19,15 @@ module ActiveMerchant #:nodoc:
19
19
  self.default_currency = 'THB'
20
20
  self.money_format = :cents
21
21
 
22
- #Country supported by Omise
22
+ # Country supported by Omise
23
23
  # * Thailand
24
- self.supported_countries = %w( TH JP )
24
+ self.supported_countries = %w(TH JP)
25
25
 
26
26
  # Credit cards supported by Omise
27
27
  # * VISA
28
28
  # * MasterCard
29
29
  # * JCB
30
- self.supported_cardtypes = [:visa, :master, :jcb]
30
+ self.supported_cardtypes = %i[visa master jcb]
31
31
 
32
32
  # Omise main page
33
33
  self.homepage_url = 'https://www.omise.co/'
@@ -46,7 +46,7 @@ module ActiveMerchant #:nodoc:
46
46
  # * <tt>:api_version</tt> -- Omise's API Version (OPTIONAL), default version is '2014-07-27'
47
47
  # See version at page https://dashboard.omise.co/api-version/edit
48
48
 
49
- def initialize(options={})
49
+ def initialize(options = {})
50
50
  requires!(options, :public_key, :secret_key)
51
51
  @public_key = options[:public_key]
52
52
  @secret_key = options[:secret_key]
@@ -79,7 +79,7 @@ module ActiveMerchant #:nodoc:
79
79
  #
80
80
  # purchase(money, nil, { :customer_id => customer_id })
81
81
 
82
- def purchase(money, payment_method, options={})
82
+ def purchase(money, payment_method, options = {})
83
83
  create_charge(money, payment_method, options)
84
84
  end
85
85
 
@@ -91,7 +91,7 @@ module ActiveMerchant #:nodoc:
91
91
  # * <tt>payment_method</tt> -- The CreditCard object
92
92
  # * <tt>options</tt> -- An optional parameters, such as token or capture
93
93
 
94
- def authorize(money, payment_method, options={})
94
+ def authorize(money, payment_method, options = {})
95
95
  options[:capture] = 'false'
96
96
  create_charge(money, payment_method, options)
97
97
  end
@@ -104,7 +104,7 @@ module ActiveMerchant #:nodoc:
104
104
  # * <tt>charge_id</tt> -- The CreditCard object
105
105
  # * <tt>options</tt> -- An optional parameters, such as token or capture
106
106
 
107
- def capture(money, charge_id, options={})
107
+ def capture(money, charge_id, options = {})
108
108
  post = {}
109
109
  add_amount(post, money, options)
110
110
  commit(:post, "charges/#{CGI.escape(charge_id)}/capture", post, options)
@@ -118,7 +118,7 @@ module ActiveMerchant #:nodoc:
118
118
  # * <tt>charge_id</tt> -- The CreditCard object
119
119
  # * <tt>options</tt> -- An optional parameters, such as token or capture
120
120
 
121
- def refund(money, charge_id, options={})
121
+ def refund(money, charge_id, options = {})
122
122
  options[:amount] = money if money
123
123
  commit(:post, "charges/#{CGI.escape(charge_id)}/refunds", options)
124
124
  end
@@ -132,7 +132,7 @@ module ActiveMerchant #:nodoc:
132
132
  # 'email' (A customer email)
133
133
  # 'description' (A customer description)
134
134
 
135
- def store(payment_method, options={})
135
+ def store(payment_method, options = {})
136
136
  post, card_params = {}, {}
137
137
  add_customer_data(post, options)
138
138
  add_token(card_params, payment_method, options)
@@ -145,7 +145,7 @@ module ActiveMerchant #:nodoc:
145
145
  #
146
146
  # * <tt>customer_id</tt> -- The Customer identifier (REQUIRED).
147
147
 
148
- def unstore(customer_id, options={})
148
+ def unstore(customer_id, options = {})
149
149
  commit(:delete, "customers/#{CGI.escape(customer_id)}")
150
150
  end
151
151
 
@@ -164,7 +164,7 @@ module ActiveMerchant #:nodoc:
164
164
  transcript.
165
165
  gsub(/(Authorization: Basic )\w+/i, '\1[FILTERED]').
166
166
  gsub(/(\\"number\\":)\\"\d+\\"/, '\1[FILTERED]').
167
- gsub(/(\\"security_code\\":)\\"\d+\\"/,'\1[FILTERED]')
167
+ gsub(/(\\"security_code\\":)\\"\d+\\"/, '\1[FILTERED]')
168
168
  end
169
169
 
170
170
  private
@@ -178,11 +178,11 @@ module ActiveMerchant #:nodoc:
178
178
  commit(:post, 'charges', post, options)
179
179
  end
180
180
 
181
- def headers(options={})
181
+ def headers(options = {})
182
182
  key = options[:key] || @secret_key
183
183
  {
184
184
  'Content-Type' => 'application/json;utf-8',
185
- 'Omise-Version' => @api_version || "2014-07-27",
185
+ 'Omise-Version' => @api_version || '2014-07-27',
186
186
  'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION} Ruby/#{RUBY_VERSION}",
187
187
  'Authorization' => 'Basic ' + Base64.encode64(key.to_s + ':').strip,
188
188
  'Accept-Encoding' => 'utf-8'
@@ -197,7 +197,7 @@ module ActiveMerchant #:nodoc:
197
197
  parameters.present? ? parameters.to_json : nil
198
198
  end
199
199
 
200
- def https_request(method, endpoint, parameters=nil, options={})
200
+ def https_request(method, endpoint, parameters = nil, options = {})
201
201
  raw_response = response = nil
202
202
  begin
203
203
  raw_response = ssl_request(method, url_for(endpoint), post_data(parameters), headers(options))
@@ -216,12 +216,12 @@ module ActiveMerchant #:nodoc:
216
216
  end
217
217
 
218
218
  def json_error(raw_response)
219
- msg = "Invalid response received from Omise API. Please contact support@omise.co if you continue to receive this message."
219
+ msg = 'Invalid response received from Omise API. Please contact support@omise.co if you continue to receive this message.'
220
220
  msg += "The raw response returned by the API was #{raw_response.inspect})"
221
221
  { message: msg }
222
222
  end
223
223
 
224
- def commit(method, endpoint, params=nil, options={})
224
+ def commit(method, endpoint, params = nil, options = {})
225
225
  response = https_request(method, endpoint, params, options)
226
226
  Response.new(
227
227
  successful?(response),
@@ -246,16 +246,16 @@ module ActiveMerchant #:nodoc:
246
246
  def message_to_standard_error_code_from(response)
247
247
  message = response['message'] if response['code'] == 'invalid_card'
248
248
  case message
249
- when /brand not supported/
250
- STANDARD_ERROR_CODE[:invalid_number]
251
- when /number is invalid/
252
- STANDARD_ERROR_CODE[:incorrect_number]
253
- when /expiration date cannot be in the past/
254
- STANDARD_ERROR_CODE[:expired_card]
255
- when /expiration \w+ is invalid/
256
- STANDARD_ERROR_CODE[:invalid_expiry_date]
257
- else
258
- STANDARD_ERROR_CODE[:processing_error]
249
+ when /brand not supported/
250
+ STANDARD_ERROR_CODE[:invalid_number]
251
+ when /number is invalid/
252
+ STANDARD_ERROR_CODE[:incorrect_number]
253
+ when /expiration date cannot be in the past/
254
+ STANDARD_ERROR_CODE[:expired_card]
255
+ when /expiration \w+ is invalid/
256
+ STANDARD_ERROR_CODE[:invalid_expiry_date]
257
+ else
258
+ STANDARD_ERROR_CODE[:processing_error]
259
259
  end
260
260
  end
261
261
 
@@ -263,7 +263,7 @@ module ActiveMerchant #:nodoc:
263
263
  if successful?(response)
264
264
  'Success'
265
265
  else
266
- (response['message'] ? response['message'] : response['failure_message'])
266
+ response['message'] || response['failure_message']
267
267
  end
268
268
  end
269
269
 
@@ -284,7 +284,7 @@ module ActiveMerchant #:nodoc:
284
284
  commit(:post, 'tokens', post, { key: @public_key })
285
285
  end
286
286
 
287
- def add_token(post, credit_card, options={})
287
+ def add_token(post, credit_card, options = {})
288
288
  if options[:token_id].present?
289
289
  post[:card] = options[:token_id]
290
290
  else
@@ -304,11 +304,11 @@ module ActiveMerchant #:nodoc:
304
304
  post[:card] = card
305
305
  end
306
306
 
307
- def add_customer(post, options={})
307
+ def add_customer(post, options = {})
308
308
  post[:customer] = options[:customer_id] if options[:customer_id]
309
309
  end
310
310
 
311
- def add_customer_data(post, options={})
311
+ def add_customer_data(post, options = {})
312
312
  post[:description] = options[:description] if options[:description]
313
313
  post[:email] = options[:email] if options[:email]
314
314
  end
@@ -318,7 +318,6 @@ module ActiveMerchant #:nodoc:
318
318
  post[:currency] = (options[:currency] || currency(money))
319
319
  post[:description] = options[:description] if options.key?(:description)
320
320
  end
321
-
322
321
  end
323
322
  end
324
323
  end
@@ -1,11 +1,18 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class OpenpayGateway < Gateway
4
- self.live_url = 'https://api.openpay.mx/v1/'
5
- self.test_url = 'https://sandbox-api.openpay.mx/v1/'
6
-
7
- self.supported_countries = ['MX']
8
- self.supported_cardtypes = [:visa, :master, :american_express]
4
+ class_attribute :mx_live_url, :mx_test_url
5
+ class_attribute :co_live_url, :co_test_url
6
+
7
+ self.co_live_url = 'https://api.openpay.co/v1/'
8
+ self.co_test_url = 'https://sandbox-api.openpay.co/v1/'
9
+ self.mx_live_url = 'https://api.openpay.mx/v1/'
10
+ self.mx_test_url = 'https://sandbox-api.openpay.mx/v1/'
11
+ self.live_url = self.co_live_url
12
+ self.test_url = self.co_test_url
13
+
14
+ self.supported_countries = %w(CO MX)
15
+ self.supported_cardtypes = %i[visa master american_express carnet]
9
16
  self.homepage_url = 'http://www.openpay.mx/'
10
17
  self.display_name = 'Openpay'
11
18
  self.default_currency = 'MXN'
@@ -24,6 +31,16 @@ module ActiveMerchant #:nodoc:
24
31
  super
25
32
  end
26
33
 
34
+ def gateway_url(options = {})
35
+ country = options[:merchant_country] || @options[:merchant_country]
36
+
37
+ if country == 'MX'
38
+ test? ? mx_test_url : mx_live_url
39
+ else
40
+ test? ? co_test_url : co_live_url
41
+ end
42
+ end
43
+
27
44
  def purchase(money, creditcard, options = {})
28
45
  post = create_post_for_auth_or_purchase(money, creditcard, options)
29
46
  commit(:post, 'charges', post, options)
@@ -38,6 +55,7 @@ module ActiveMerchant #:nodoc:
38
55
  def capture(money, authorization, options = {})
39
56
  post = {}
40
57
  post[:amount] = amount(money) if money
58
+ post[:payments] = options[:payments] if options[:payments]
41
59
  commit(:post, "charges/#{CGI.escape(authorization)}/capture", post, options)
42
60
  end
43
61
 
@@ -74,7 +92,7 @@ module ActiveMerchant #:nodoc:
74
92
  MultiResponse.run(:first) do |r|
75
93
  r.process { commit(:post, 'customers', post, options) }
76
94
 
77
- if(r.success? && !r.params['id'].blank?)
95
+ if r.success? && !r.params['id'].blank?
78
96
  customer_id = r.params['id']
79
97
  r.process { commit(:post, "customers/#{customer_id}/cards", card, options) }
80
98
  end
@@ -103,6 +121,7 @@ module ActiveMerchant #:nodoc:
103
121
  gsub(%r((cvv2\\?":\\?")\\?"), '\1[BLANK]"').
104
122
  gsub(%r((cvv2\\?":\\?")\s+), '\1[BLANK]')
105
123
  end
124
+
106
125
  private
107
126
 
108
127
  def create_post_for_auth_or_purchase(money, creditcard, options)
@@ -114,6 +133,7 @@ module ActiveMerchant #:nodoc:
114
133
  post[:device_session_id] = options[:device_session_id]
115
134
  post[:currency] = (options[:currency] || currency(money)).upcase
116
135
  post[:use_card_points] = options[:use_card_points] if options[:use_card_points]
136
+ post[:payment_plan] = { payments: options[:payments] } if options[:payments]
117
137
  add_creditcard(post, creditcard, options)
118
138
  post
119
139
  end
@@ -124,8 +144,8 @@ module ActiveMerchant #:nodoc:
124
144
  elsif creditcard.respond_to?(:number)
125
145
  card = {
126
146
  card_number: creditcard.number,
127
- expiration_month: "#{sprintf("%02d", creditcard.month)}",
128
- expiration_year: "#{"#{creditcard.year}"[-2, 2]}",
147
+ expiration_month: sprintf('%02d', creditcard.month),
148
+ expiration_year: creditcard.year.to_s[-2, 2],
129
149
  cvv2: creditcard.verification_value,
130
150
  holder_name: creditcard.name
131
151
  }
@@ -148,6 +168,7 @@ module ActiveMerchant #:nodoc:
148
168
 
149
169
  def add_address(card, options)
150
170
  return unless card.kind_of?(Hash)
171
+
151
172
  if address = (options[:billing_address] || options[:address])
152
173
  card[:address] = {
153
174
  line1: address[:address1],
@@ -163,15 +184,16 @@ module ActiveMerchant #:nodoc:
163
184
 
164
185
  def headers(options = {})
165
186
  {
166
- "Content-Type" => "application/json",
167
- "Authorization" => "Basic " + Base64.strict_encode64(@api_key.to_s + ":").strip,
168
- "User-Agent" => "Openpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
169
- "X-Openpay-Client-User-Agent" => user_agent
187
+ 'Content-Type' => 'application/json',
188
+ 'Authorization' => 'Basic ' + Base64.strict_encode64(@api_key.to_s + ':').strip,
189
+ 'User-Agent' => "Openpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
190
+ 'X-Openpay-Client-User-Agent' => user_agent
170
191
  }
171
192
  end
172
193
 
173
194
  def parse(body)
174
195
  return {} unless body
196
+
175
197
  JSON.parse(body)
176
198
  end
177
199
 
@@ -182,13 +204,12 @@ module ActiveMerchant #:nodoc:
182
204
  Response.new(success,
183
205
  (success ? response['error_code'] : response['description']),
184
206
  response,
185
- :test => test?,
186
- :authorization => response['id']
187
- )
207
+ test: test?,
208
+ authorization: response['id'])
188
209
  end
189
210
 
190
- def http_request(method, resource, parameters={}, options={})
191
- url = (test? ? self.test_url : self.live_url) + @merchant_id + '/' + resource
211
+ def http_request(method, resource, parameters = {}, options = {})
212
+ url = gateway_url(options) + @merchant_id + '/' + resource
192
213
  raw_response = nil
193
214
  begin
194
215
  raw_response = ssl_request(method, url, (parameters ? parameters.to_json : nil), headers(options))
@@ -202,24 +223,22 @@ module ActiveMerchant #:nodoc:
202
223
  end
203
224
 
204
225
  def error?(response)
205
- response.key?('error_code')
226
+ response['error_code'] && !response['error_code'].blank?
206
227
  end
207
228
 
208
229
  def response_error(raw_response)
209
- begin
210
- parse(raw_response)
211
- rescue JSON::ParserError
212
- json_error(raw_response)
213
- end
230
+ parse(raw_response)
231
+ rescue JSON::ParserError
232
+ json_error(raw_response)
214
233
  end
215
234
 
216
235
  def json_error(raw_response)
217
236
  msg = 'Invalid response received from the Openpay API. Please contact soporte@openpay.mx if you continue to receive this message.'
218
237
  msg += " (The raw response returned by the API was #{raw_response.inspect})"
219
238
  {
220
- 'category' => 'request',
221
- 'error_code' => '9999',
222
- 'description' => msg
239
+ 'category' => 'request',
240
+ 'error_code' => '9999',
241
+ 'description' => msg
223
242
  }
224
243
  end
225
244
  end