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
@@ -5,61 +5,61 @@ module ActiveMerchant #:nodoc:
5
5
  class VerifiGateway < Gateway
6
6
  class VerifiPostData < PostData
7
7
  # Fields that will be sent even if they are blank
8
- self.required_fields = [ :amount, :type, :ccnumber, :ccexp, :firstname, :lastname,
9
- :company, :address1, :address2, :city, :state, :zip, :country, :phone ]
8
+ self.required_fields = %i[amount type ccnumber ccexp firstname lastname
9
+ company address1 address2 city state zip country phone]
10
10
  end
11
11
 
12
12
  self.live_url = self.test_url = 'https://secure.verifi.com/gw/api/transact.php'
13
13
 
14
14
  RESPONSE_CODE_MESSAGES = {
15
- "100" => "Transaction was Approved",
16
- "200" => "Transaction was Declined by Processor",
17
- "201" => "Do Not Honor",
18
- "202" => "Insufficient Funds",
19
- "203" => "Over Limit",
20
- "204" => "Transaction not allowed",
21
- "220" => "Incorrect payment Data",
22
- "221" => "No Such Card Issuer",
23
- "222" => "No Card Number on file with Issuer",
24
- "223" => "Expired Card",
25
- "224" => "Invalid Expiration Date",
26
- "225" => "Invalid Card Security Code",
27
- "240" => "Call Issuer for Further Information",
28
- "250" => "Pick Up Card",
29
- "251" => "Lost Card",
30
- "252" => "Stolen Card",
31
- "253" => "Fraudulent Card",
32
- "260" => "Declined With further Instructions Available (see response text)",
33
- "261" => "Declined - Stop All Recurring Payments",
34
- "262" => "Declined - Stop this Recurring Program",
35
- "263" => "Declined - Update Cardholder Data Available",
36
- "264" => "Declined - Retry in a few days",
37
- "300" => "Transaction was Rejected by Gateway",
38
- "400" => "Transaction Error Returned by Processor",
39
- "410" => "Invalid Merchant Configuration",
40
- "411" => "Merchant Account is Inactive",
41
- "420" => "Communication Error",
42
- "421" => "Communication Error with Issuer",
43
- "430" => "Duplicate Transaction at Processor",
44
- "440" => "Processor Format Error",
45
- "441" => "Invalid Transaction Information",
46
- "460" => "Processor Feature Not Available",
47
- "461" => "Unsupported Card Type"
15
+ '100' => 'Transaction was Approved',
16
+ '200' => 'Transaction was Declined by Processor',
17
+ '201' => 'Do Not Honor',
18
+ '202' => 'Insufficient Funds',
19
+ '203' => 'Over Limit',
20
+ '204' => 'Transaction not allowed',
21
+ '220' => 'Incorrect payment Data',
22
+ '221' => 'No Such Card Issuer',
23
+ '222' => 'No Card Number on file with Issuer',
24
+ '223' => 'Expired Card',
25
+ '224' => 'Invalid Expiration Date',
26
+ '225' => 'Invalid Card Security Code',
27
+ '240' => 'Call Issuer for Further Information',
28
+ '250' => 'Pick Up Card',
29
+ '251' => 'Lost Card',
30
+ '252' => 'Stolen Card',
31
+ '253' => 'Fraudulent Card',
32
+ '260' => 'Declined With further Instructions Available (see response text)',
33
+ '261' => 'Declined - Stop All Recurring Payments',
34
+ '262' => 'Declined - Stop this Recurring Program',
35
+ '263' => 'Declined - Update Cardholder Data Available',
36
+ '264' => 'Declined - Retry in a few days',
37
+ '300' => 'Transaction was Rejected by Gateway',
38
+ '400' => 'Transaction Error Returned by Processor',
39
+ '410' => 'Invalid Merchant Configuration',
40
+ '411' => 'Merchant Account is Inactive',
41
+ '420' => 'Communication Error',
42
+ '421' => 'Communication Error with Issuer',
43
+ '430' => 'Duplicate Transaction at Processor',
44
+ '440' => 'Processor Format Error',
45
+ '441' => 'Invalid Transaction Information',
46
+ '460' => 'Processor Feature Not Available',
47
+ '461' => 'Unsupported Card Type'
48
48
  }
49
49
 
50
50
  SUCCESS = 1
51
51
 
52
52
  TRANSACTIONS = {
53
- :authorization => 'auth',
54
- :purchase => 'sale',
55
- :capture => 'capture',
56
- :void => 'void',
57
- :credit => 'credit',
58
- :refund => 'refund'
53
+ authorization: 'auth',
54
+ purchase: 'sale',
55
+ capture: 'capture',
56
+ void: 'void',
57
+ credit: 'credit',
58
+ refund: 'refund'
59
59
  }
60
60
 
61
61
  self.supported_countries = ['US']
62
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
62
+ self.supported_cardtypes = %i[visa master american_express discover]
63
63
  self.homepage_url = 'http://www.verifi.com/'
64
64
  self.display_name = 'Verifi'
65
65
 
@@ -180,10 +180,10 @@ module ActiveMerchant #:nodoc:
180
180
  # MD5(username|password|orderid|amount|time)
181
181
  now = Time.now.to_i.to_s
182
182
  md5 = Digest::MD5.new
183
- md5 << @options[:login].to_s + "|"
184
- md5 << @options[:password].to_s + "|"
185
- md5 << options[:order_id].to_s + "|"
186
- md5 << amount(money).to_s + "|"
183
+ md5 << @options[:login].to_s + '|'
184
+ md5 << @options[:password].to_s + '|'
185
+ md5 << options[:order_id].to_s + '|'
186
+ md5 << amount(money).to_s + '|'
187
187
  md5 << now
188
188
  post[:key] = md5.hexdigest
189
189
  post[:time] = now
@@ -192,18 +192,17 @@ module ActiveMerchant #:nodoc:
192
192
  def commit(trx_type, money, post)
193
193
  post[:amount] = amount(money)
194
194
 
195
- response = parse( ssl_post(self.live_url, post_data(trx_type, post)) )
195
+ response = parse(ssl_post(self.live_url, post_data(trx_type, post)))
196
196
 
197
197
  Response.new(response[:response].to_i == SUCCESS, message_from(response), response,
198
- :test => test?,
199
- :authorization => response[:transactionid],
200
- :avs_result => { :code => response[:avsresponse] },
201
- :cvv_result => response[:cvvresponse]
202
- )
198
+ test: test?,
199
+ authorization: response[:transactionid],
200
+ avs_result: { code: response[:avsresponse] },
201
+ cvv_result: response[:cvvresponse])
203
202
  end
204
203
 
205
204
  def message_from(response)
206
- response[:response_code_message] ? response[:response_code_message] : ""
205
+ response[:response_code_message] || ''
207
206
  end
208
207
 
209
208
  def parse(body)
@@ -8,13 +8,13 @@ module ActiveMerchant #:nodoc:
8
8
  self.delimiter = "\r\n"
9
9
 
10
10
  self.actions = {
11
- :purchase => 'SALE',
12
- :credit => 'CREDIT'
11
+ purchase: 'SALE',
12
+ credit: 'CREDIT'
13
13
  }
14
14
 
15
15
  APPROVED = '0'
16
16
 
17
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
17
+ self.supported_cardtypes = %i[visa master american_express discover]
18
18
  self.supported_countries = ['US']
19
19
  self.display_name = 'ViaKLIX'
20
20
  self.homepage_url = 'http://viaklix.com'
@@ -49,9 +49,7 @@ module ActiveMerchant #:nodoc:
49
49
  # Make a credit to a card (Void can only be done from the virtual terminal)
50
50
  # Viaklix does not support credits by reference. You must pass in the credit card
51
51
  def credit(money, creditcard, options = {})
52
- if creditcard.is_a?(String)
53
- raise ArgumentError, "Reference credits are not supported. Please supply the original credit card"
54
- end
52
+ raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card' if creditcard.is_a?(String)
55
53
 
56
54
  form = {}
57
55
  add_invoice(form, options)
@@ -63,6 +61,7 @@ module ActiveMerchant #:nodoc:
63
61
  end
64
62
 
65
63
  private
64
+
66
65
  def add_test_mode(form, options)
67
66
  form[:test_mode] = 'TRUE' if options[:test_mode]
68
67
  end
@@ -72,12 +71,12 @@ module ActiveMerchant #:nodoc:
72
71
  form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank?
73
72
  end
74
73
 
75
- def add_invoice(form,options)
74
+ def add_invoice(form, options)
76
75
  form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
77
76
  form[:description] = options[:description].to_s.slice(0, 255)
78
77
  end
79
78
 
80
- def add_address(form,options)
79
+ def add_address(form, options)
81
80
  billing_address = options[:billing_address] || options[:address]
82
81
 
83
82
  if billing_address
@@ -108,9 +107,7 @@ module ActiveMerchant #:nodoc:
108
107
  form[:card_number] = creditcard.number
109
108
  form[:exp_date] = expdate(creditcard)
110
109
 
111
- if creditcard.verification_value?
112
- add_verification_value(form, creditcard)
113
- end
110
+ add_verification_value(form, creditcard) if creditcard.verification_value?
114
111
 
115
112
  form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
116
113
  form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
@@ -137,14 +134,13 @@ module ActiveMerchant #:nodoc:
137
134
  parameters[:amount] = amount(money)
138
135
  parameters[:transaction_type] = self.actions[action]
139
136
 
140
- response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)) )
137
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)))
141
138
 
142
139
  Response.new(response['result'] == APPROVED, message_from(response), response,
143
- :test => @options[:test] || test?,
144
- :authorization => authorization_from(response),
145
- :avs_result => { :code => response['avs_response'] },
146
- :cvv_result => response['cvv2_response']
147
- )
140
+ test: @options[:test] || test?,
141
+ authorization: authorization_from(response),
142
+ avs_result: { code: response['avs_response'] },
143
+ cvv_result: response['cvv2_response'])
148
144
  end
149
145
 
150
146
  def authorization_from(response)
@@ -158,16 +154,16 @@ module ActiveMerchant #:nodoc:
158
154
  def post_data(parameters)
159
155
  result = preamble
160
156
  result.merge!(parameters)
161
- result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
157
+ result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
162
158
  end
163
159
 
164
160
  # Parse the response message
165
161
  def parse(msg)
166
162
  resp = {}
167
- msg.split(self.delimiter).collect{|li|
168
- key, value = li.split("=")
169
- resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip
170
- }
163
+ msg.split(self.delimiter).collect { |li|
164
+ key, value = li.split('=')
165
+ resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip
166
+ }
171
167
  resp
172
168
  end
173
169
  end
@@ -2,30 +2,30 @@ module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class VisanetPeruGateway < Gateway
4
4
  include Empty
5
- self.display_name = "VisaNet Peru Gateway"
6
- self.homepage_url = "http://www.visanet.com.pe"
5
+ self.display_name = 'VisaNet Peru Gateway'
6
+ self.homepage_url = 'http://www.visanet.com.pe'
7
7
 
8
- self.test_url = "https://devapi.vnforapps.com/api.tokenization/api/v2/merchant"
9
- self.live_url = "https://api.vnforapps.com/api.tokenization/api/v2/merchant"
8
+ self.test_url = 'https://devapi.vnforapps.com/api.tokenization/api/v2/merchant'
9
+ self.live_url = 'https://api.vnforapps.com/api.tokenization/api/v2/merchant'
10
10
 
11
- self.supported_countries = ["US", "PE"]
12
- self.default_currency = "PEN"
11
+ self.supported_countries = %w[US PE]
12
+ self.default_currency = 'PEN'
13
13
  self.money_format = :dollars
14
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
14
+ self.supported_cardtypes = %i[visa master american_express discover]
15
15
 
16
- def initialize(options={})
16
+ def initialize(options = {})
17
17
  requires!(options, :access_key_id, :secret_access_key, :merchant_id)
18
18
  super
19
19
  end
20
20
 
21
- def purchase(amount, payment_method, options={})
21
+ def purchase(amount, payment_method, options = {})
22
22
  MultiResponse.run() do |r|
23
23
  r.process { authorize(amount, payment_method, options) }
24
- r.process { capture(r.authorization, options) }
24
+ r.process { capture(amount, r.authorization, options) }
25
25
  end
26
26
  end
27
27
 
28
- def authorize(amount, payment_method, options={})
28
+ def authorize(amount, payment_method, options = {})
29
29
  params = {}
30
30
 
31
31
  add_invoice(params, amount, options)
@@ -34,28 +34,38 @@ module ActiveMerchant #:nodoc:
34
34
  params[:email] = options[:email] || 'unknown@email.com'
35
35
  params[:createAlias] = false
36
36
 
37
- commit("authorize", params)
37
+ commit('authorize', params, options)
38
38
  end
39
39
 
40
- def capture(authorization, options={})
40
+ def capture(amount, authorization, options = {})
41
41
  params = {}
42
+ options[:id_unico] = split_authorization(authorization)[1]
42
43
  add_auth_order_id(params, authorization, options)
43
- commit("deposit", params)
44
+ commit('deposit', params, options)
44
45
  end
45
46
 
46
- def void(authorization, options={})
47
+ def void(authorization, options = {})
47
48
  params = {}
48
49
  add_auth_order_id(params, authorization, options)
49
- commit("void", params)
50
+ commit('void', params, options)
50
51
  end
51
52
 
52
- def refund(amount, authorization, options={})
53
+ def refund(amount, authorization, options = {})
53
54
  params = {}
55
+ params[:amount] = amount(amount) if amount
54
56
  add_auth_order_id(params, authorization, options)
55
- commit("cancelDeposit", params)
57
+ response = commit('cancelDeposit', params, options)
58
+ return response if response.success? || split_authorization(authorization).length == 1 || !options[:force_full_refund_if_unsettled]
59
+
60
+ # Attempt RefundSingleTransaction if unsettled (and stash the original
61
+ # response message so it will be included it in the follow-up response
62
+ # message)
63
+ options[:error_message] = response.message
64
+ prepare_refund_data(params, authorization, options)
65
+ commit('refund', params, options)
56
66
  end
57
67
 
58
- def verify(credit_card, options={})
68
+ def verify(credit_card, options = {})
59
69
  MultiResponse.run(:use_first_response) do |r|
60
70
  r.process { authorize(100, credit_card, options) }
61
71
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -75,20 +85,21 @@ module ActiveMerchant #:nodoc:
75
85
 
76
86
  private
77
87
 
78
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
79
- CURRENCY_CODES["USD"] = 840
80
- CURRENCY_CODES["PEN"] = 604
88
+ CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
89
+ CURRENCY_CODES['USD'] = 840
90
+ CURRENCY_CODES['PEN'] = 604
81
91
 
82
92
  def add_invoice(params, money, options)
83
- # Visanet Peru expects a 9-digit numeric purchaseNumber
84
- params[:purchaseNumber] = (SecureRandom.random_number(900_000_000) + 100_000_000).to_s
93
+ # Visanet Peru expects a 12-digit alphanumeric purchaseNumber
94
+ params[:purchaseNumber] = generate_purchase_number_stamp
85
95
  params[:externalTransactionId] = options[:order_id]
86
96
  params[:amount] = amount(money)
87
97
  params[:currencyId] = CURRENCY_CODES[options[:currency] || currency(money)]
88
98
  end
89
99
 
90
100
  def add_auth_order_id(params, authorization, options)
91
- params[:purchaseNumber] = authorization
101
+ purchase_number, = split_authorization(authorization)
102
+ params[:purchaseNumber] = purchase_number
92
103
  params[:externalTransactionId] = options[:order_id]
93
104
  end
94
105
 
@@ -118,48 +129,66 @@ module ActiveMerchant #:nodoc:
118
129
  params[:antifraud] = antifraud
119
130
  end
120
131
 
121
- def commit(action, params)
122
- begin
123
- raw_response = ssl_request(method(action), url(action, params), params.to_json, headers)
124
- response = parse(raw_response)
125
- rescue ResponseError => e
126
- raw_response = e.response.body
127
- response_error(raw_response)
128
- rescue JSON::ParserError
129
- unparsable_response(raw_response)
130
- else
131
- Response.new(
132
- success_from(response),
133
- message_from(response),
134
- response,
135
- :test => test?,
136
- :authorization => authorization_from(params),
137
- :error_code => response["errorCode"]
138
- )
139
- end
132
+ def prepare_refund_data(params, authorization, options)
133
+ params.delete(:purchaseNumber)
134
+ params[:externalReferenceId] = params.delete(:externalTransactionId)
135
+ _, transaction_id = split_authorization(authorization)
136
+
137
+ options.update(transaction_id: transaction_id)
138
+ params[:ruc] = options[:ruc]
139
+ end
140
+
141
+ def split_authorization(authorization)
142
+ authorization.split('|')
143
+ end
144
+
145
+ def generate_purchase_number_stamp
146
+ Time.now.to_f.to_s.delete('.')[1..10] + rand(99).to_s
147
+ end
148
+
149
+ def commit(action, params, options = {})
150
+ raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
151
+ response = parse(raw_response)
152
+ rescue ResponseError => e
153
+ raw_response = e.response.body
154
+ response_error(raw_response, options, action)
155
+ rescue JSON::ParserError
156
+ unparsable_response(raw_response)
157
+ else
158
+ Response.new(
159
+ success_from(response),
160
+ message_from(response, options, action),
161
+ response,
162
+ test: test?,
163
+ authorization: authorization_from(params, response, options),
164
+ error_code: response['errorCode']
165
+ )
140
166
  end
141
167
 
142
168
  def headers
143
169
  {
144
- "Authorization" => "Basic " + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip,
145
- "Content-Type" => "application/json"
170
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip,
171
+ 'Content-Type' => 'application/json'
146
172
  }
147
173
  end
148
174
 
149
- def url(action, params)
150
- if (action == "authorize")
175
+ def url(action, params, options = {})
176
+ if action == 'authorize'
151
177
  "#{base_url}/#{@options[:merchant_id]}"
178
+ elsif action == 'refund'
179
+ "#{base_url}/#{@options[:merchant_id]}/#{action}/#{options[:transaction_id]}"
152
180
  else
153
181
  "#{base_url}/#{@options[:merchant_id]}/#{action}/#{params[:purchaseNumber]}"
154
182
  end
155
183
  end
156
184
 
157
185
  def method(action)
158
- (action == "authorize") ? :post : :put
186
+ %w(authorize refund).include?(action) ? :post : :put
159
187
  end
160
188
 
161
- def authorization_from(params)
162
- params[:purchaseNumber]
189
+ def authorization_from(params, response, options)
190
+ id_unico = response['data']['ID_UNICO'] || options[:id_unico]
191
+ "#{params[:purchaseNumber]}|#{id_unico}"
163
192
  end
164
193
 
165
194
  def base_url
@@ -171,36 +200,48 @@ module ActiveMerchant #:nodoc:
171
200
  end
172
201
 
173
202
  def success_from(response)
174
- response["errorCode"] == 0
203
+ response['errorCode'] == 0
175
204
  end
176
205
 
177
- def message_from(response)
178
- if empty?(response["errorMessage"]) || response["errorMessage"] == "[ ]"
179
- response["data"]["DSC_COD_ACCION"]
180
- else
181
- response["errorMessage"]
182
- end
206
+ def message_from(response, options, action)
207
+ message_from_messages(
208
+ response['errorMessage'],
209
+ action_code_description(response),
210
+ options[:error_message]
211
+ )
183
212
  end
184
213
 
185
- def response_error(raw_response)
186
- begin
187
- response = parse(raw_response)
188
- rescue JSON::ParserError
189
- unparsable_response(raw_response)
190
- else
191
- return Response.new(
192
- false,
193
- message_from(response),
194
- response,
195
- :test => test?,
196
- :authorization => response["transactionUUID"],
197
- :error_code => response["errorCode"]
198
- )
199
- end
214
+ def message_from_messages(*args)
215
+ args.reject { |m| error_message_empty?(m) }.join(' | ')
216
+ end
217
+
218
+ def action_code_description(response)
219
+ return nil unless response['data']
220
+
221
+ response['data']['DSC_COD_ACCION']
222
+ end
223
+
224
+ def error_message_empty?(error_message)
225
+ empty?(error_message) || error_message == '[ ]'
226
+ end
227
+
228
+ def response_error(raw_response, options, action)
229
+ response = parse(raw_response)
230
+ rescue JSON::ParserError
231
+ unparsable_response(raw_response)
232
+ else
233
+ return Response.new(
234
+ false,
235
+ message_from(response, options, action),
236
+ response,
237
+ test: test?,
238
+ authorization: response['transactionUUID'],
239
+ error_code: response['errorCode']
240
+ )
200
241
  end
201
242
 
202
243
  def unparsable_response(raw_response)
203
- message = "Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message."
244
+ message = 'Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message.'
204
245
  message += " (The raw response returned by the API was #{raw_response.inspect})"
205
246
  return Response.new(false, message)
206
247
  end