activemerchant 1.45.0 → 1.126.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +2167 -2
  3. data/CONTRIBUTORS +57 -0
  4. data/README.md +62 -41
  5. data/lib/active_merchant/billing/avs_result.rb +25 -28
  6. data/lib/active_merchant/billing/base.rb +11 -35
  7. data/lib/active_merchant/billing/check.rb +28 -24
  8. data/lib/active_merchant/billing/compatibility.rb +10 -12
  9. data/lib/active_merchant/billing/credit_card.rb +141 -69
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  11. data/lib/active_merchant/billing/credit_card_methods.rb +348 -52
  12. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  13. data/lib/active_merchant/billing/gateway.rb +125 -61
  14. data/lib/active_merchant/billing/gateways/adyen.rb +633 -127
  15. data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +883 -195
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -103
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
  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 +24 -13
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  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 +143 -62
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +45 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +13 -10
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -506
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +623 -0
  33. data/lib/active_merchant/billing/gateways/bogus.rb +82 -36
  34. data/lib/active_merchant/billing/gateways/borgun.rb +61 -40
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +21 -2
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +3 -3
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +592 -203
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -4
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +116 -61
  42. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +248 -97
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +70 -26
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +73 -53
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  52. data/lib/active_merchant/billing/gateways/checkout.rb +32 -33
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +340 -0
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  57. data/lib/active_merchant/billing/gateways/conekta.rb +55 -34
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  59. data/lib/active_merchant/billing/gateways/credorax.rb +506 -0
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  61. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  62. data/lib/active_merchant/billing/gateways/cyber_source.rb +637 -221
  63. data/lib/active_merchant/billing/gateways/d_local.rb +303 -0
  64. data/lib/active_merchant/billing/gateways/data_cash.rb +57 -355
  65. data/lib/active_merchant/billing/gateways/decidir.rb +347 -0
  66. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  67. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  68. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  69. data/lib/active_merchant/billing/gateways/ebanx.rb +334 -0
  70. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  71. data/lib/active_merchant/billing/gateways/elavon.rb +377 -250
  72. data/lib/active_merchant/billing/gateways/element.rb +386 -0
  73. data/lib/active_merchant/billing/gateways/epay.rb +92 -71
  74. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  75. data/lib/active_merchant/billing/gateways/eway.rb +85 -73
  76. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  77. data/lib/active_merchant/billing/gateways/eway_rapid.rb +134 -80
  78. data/lib/active_merchant/billing/gateways/exact.rb +37 -36
  79. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  80. data/lib/active_merchant/billing/gateways/fat_zebra.rb +124 -74
  81. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  82. data/lib/active_merchant/billing/gateways/finansbank.rb +4 -5
  83. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  84. data/lib/active_merchant/billing/gateways/first_pay.rb +45 -23
  85. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +184 -87
  86. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  87. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  88. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  89. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  90. data/lib/active_merchant/billing/gateways/garanti.rb +31 -32
  91. data/lib/active_merchant/billing/gateways/global_collect.rb +507 -0
  92. data/lib/active_merchant/billing/gateways/global_transport.rb +25 -15
  93. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  94. data/lib/active_merchant/billing/gateways/hps.rb +252 -68
  95. data/lib/active_merchant/billing/gateways/iats_payments.rb +99 -38
  96. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  97. data/lib/active_merchant/billing/gateways/inspire.rb +48 -48
  98. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  99. data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
  100. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  101. data/lib/active_merchant/billing/gateways/iridium.rb +254 -244
  102. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  103. data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
  104. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +200 -80
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +277 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +95 -85
  111. data/lib/active_merchant/billing/gateways/litle.rb +371 -94
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +146 -123
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +331 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +47 -23
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +60 -44
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +76 -23
  121. data/lib/active_merchant/billing/gateways/mercury.rb +73 -54
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +33 -43
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  124. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  125. data/lib/active_merchant/billing/gateways/migs.rb +101 -37
  126. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
  128. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +30 -34
  129. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  130. data/lib/active_merchant/billing/gateways/monei.rb +422 -0
  131. data/lib/active_merchant/billing/gateways/moneris.rb +236 -72
  132. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  133. data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
  134. data/lib/active_merchant/billing/gateways/nab_transact.rb +87 -68
  135. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  136. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  137. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  138. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  139. data/lib/active_merchant/billing/gateways/netbilling.rb +82 -43
  140. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  141. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  142. data/lib/active_merchant/billing/gateways/nmi.rb +279 -174
  143. data/lib/active_merchant/billing/gateways/ogone.rb +96 -50
  144. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  145. data/lib/active_merchant/billing/gateways/openpay.rb +58 -23
  146. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  147. data/lib/active_merchant/billing/gateways/optimal_payment.rb +87 -69
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  149. data/lib/active_merchant/billing/gateways/orbital.rb +771 -328
  150. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +31 -32
  151. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  152. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  153. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  154. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  155. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +84 -68
  156. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  157. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  158. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  160. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  161. data/lib/active_merchant/billing/gateways/paybox_direct.rb +85 -49
  162. data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
  163. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +67 -41
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  166. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  167. data/lib/active_merchant/billing/gateways/payflow.rb +215 -46
  168. data/lib/active_merchant/billing/gateways/payflow_express.rb +64 -68
  169. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
  170. data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
  171. data/lib/active_merchant/billing/gateways/payment_express.rb +78 -58
  172. data/lib/active_merchant/billing/gateways/paymentez.rb +353 -0
  173. data/lib/active_merchant/billing/gateways/paymill.rb +163 -75
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -7
  175. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +1 -1
  176. data/lib/active_merchant/billing/gateways/paypal.rb +37 -18
  177. data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
  178. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +5 -5
  179. data/lib/active_merchant/billing/gateways/paypal_express.rb +12 -6
  180. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  181. data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
  182. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  183. data/lib/active_merchant/billing/gateways/paystation.rb +96 -91
  184. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  185. data/lib/active_merchant/billing/gateways/payu_latam.rb +479 -0
  186. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  187. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  188. data/lib/active_merchant/billing/gateways/pin.rb +113 -37
  189. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  190. data/lib/active_merchant/billing/gateways/priority.rb +369 -0
  191. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  192. data/lib/active_merchant/billing/gateways/psigate.rb +55 -44
  193. data/lib/active_merchant/billing/gateways/psl_card.rb +32 -40
  194. data/lib/active_merchant/billing/gateways/qbms.rb +86 -76
  195. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  196. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  197. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  200. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -353
  201. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  202. data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
  203. data/lib/active_merchant/billing/gateways/realex.rb +154 -52
  204. data/lib/active_merchant/billing/gateways/redsys.rb +488 -161
  205. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  206. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  207. data/lib/active_merchant/billing/gateways/sage.rb +404 -133
  208. data/lib/active_merchant/billing/gateways/sage_pay.rb +145 -109
  209. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  210. data/lib/active_merchant/billing/gateways/secure_net.rb +62 -54
  211. data/lib/active_merchant/billing/gateways/secure_pay.rb +32 -42
  212. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +36 -27
  213. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  214. data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
  215. data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
  216. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -54
  217. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  218. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  219. data/lib/active_merchant/billing/gateways/spreedly_core.rb +108 -43
  220. data/lib/active_merchant/billing/gateways/stripe.rb +536 -120
  221. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +516 -0
  222. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +19 -25
  223. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  224. data/lib/active_merchant/billing/gateways/tns.rb +16 -217
  225. data/lib/active_merchant/billing/gateways/trans_first.rb +148 -34
  226. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  227. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  228. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  229. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  230. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  231. data/lib/active_merchant/billing/gateways/trust_commerce.rb +162 -89
  232. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  233. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +332 -236
  234. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +185 -72
  235. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  236. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  237. data/lib/active_merchant/billing/gateways/viaklix.rb +19 -31
  238. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  239. data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
  240. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  241. data/lib/active_merchant/billing/gateways/wepay.rb +108 -62
  242. data/lib/active_merchant/billing/gateways/wirecard.rb +52 -43
  243. data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
  244. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  245. data/lib/active_merchant/billing/gateways/worldpay.rb +725 -121
  246. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  247. data/lib/active_merchant/billing/gateways/worldpay_us.rb +79 -39
  248. data/lib/active_merchant/billing/gateways.rb +8 -11
  249. data/lib/active_merchant/billing/model.rb +2 -2
  250. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  251. data/lib/active_merchant/billing/payment_token.rb +1 -1
  252. data/lib/active_merchant/billing/rails.rb +1 -1
  253. data/lib/active_merchant/billing/response.rb +19 -13
  254. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  255. data/lib/active_merchant/billing.rb +3 -0
  256. data/lib/active_merchant/connection.rb +196 -0
  257. data/lib/active_merchant/country.rb +13 -8
  258. data/lib/active_merchant/errors.rb +6 -0
  259. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  260. data/lib/active_merchant/network_connection_retries.rb +78 -0
  261. data/lib/active_merchant/post_data.rb +26 -0
  262. data/lib/active_merchant/posts_data.rb +92 -0
  263. data/lib/active_merchant/version.rb +1 -1
  264. data/lib/active_merchant.rb +14 -59
  265. data/lib/activemerchant.rb +1 -1
  266. data/lib/certs/cacert.pem +3214 -0
  267. data/lib/support/gateway_support.rb +8 -10
  268. data/lib/support/outbound_hosts.rb +13 -10
  269. data/lib/support/ssl_verify.rb +9 -14
  270. data/lib/support/ssl_version.rb +86 -0
  271. metadata +136 -94
  272. checksums.yaml.gz.sig +0 -1
  273. data/lib/active_merchant/billing/gateways/app55.rb +0 -176
  274. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  275. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  278. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  279. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  280. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -291
  281. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -87
  282. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  283. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
  284. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  285. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -385
  286. data/lib/active_merchant/offsite_payments_shim.rb +0 -19
  287. data.tar.gz.sig +0 -0
  288. metadata.gz.sig +0 -0
@@ -0,0 +1,258 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class RapydGateway < Gateway
4
+ self.test_url = 'https://sandboxapi.rapyd.net/v1/'
5
+ self.live_url = 'https://api.rapyd.net/v1/'
6
+
7
+ self.supported_countries = %w(US BR CA CL CO DO SV MX PE PT VI AU HK IN ID JP MY NZ PH SG KR TW TH VN AD AT BE BA BG HR CY CZ DK EE FI FR GE DE GI GR GL HU IS IE IL IT LV LI LT LU MK MT MD MC ME NL GB NO PL RO RU SM SK SI ZA ES SE CH TR VA)
8
+ self.default_currency = 'USD'
9
+ self.supported_cardtypes = %i[visa master american_express discover]
10
+
11
+ self.homepage_url = 'https://www.rapyd.net/'
12
+ self.display_name = 'Rapyd Gateway'
13
+
14
+ STANDARD_ERROR_CODE_MAPPING = {}
15
+
16
+ def initialize(options = {})
17
+ requires!(options, :secret_key, :access_key)
18
+ super
19
+ end
20
+
21
+ def purchase(money, payment, options = {})
22
+ post = {}
23
+ add_invoice(post, money, options)
24
+ add_payment(post, payment, options)
25
+ add_address(post, payment, options)
26
+ add_metadata(post, options)
27
+ add_ewallet(post, options)
28
+ post[:capture] = true if payment_is_card?(options)
29
+
30
+ if payment_is_ach?(options)
31
+ MultiResponse.run do |r|
32
+ r.process { commit(:post, 'payments', post) }
33
+ post = {}
34
+ post[:token] = r.authorization
35
+ post[:param2] = r.params.dig('data', 'original_amount').to_s
36
+ r.process { commit(:post, 'payments/completePayment', post) }
37
+ end
38
+ else
39
+ commit(:post, 'payments', post)
40
+ end
41
+ end
42
+
43
+ def authorize(money, payment, options = {})
44
+ post = {}
45
+ add_invoice(post, money, options)
46
+ add_payment(post, payment, options)
47
+ add_address(post, payment, options)
48
+ add_metadata(post, options)
49
+ add_ewallet(post, options)
50
+ post[:capture] = false
51
+ commit(:post, 'payments', post)
52
+ end
53
+
54
+ def capture(money, authorization, options = {})
55
+ post = {}
56
+ commit(:post, "payments/#{authorization}/capture", post)
57
+ end
58
+
59
+ def refund(money, authorization, options = {})
60
+ post = {}
61
+ post[:payment] = authorization
62
+ add_invoice(post, money, options)
63
+ add_metadata(post, options)
64
+ commit(:post, 'refunds', post)
65
+ end
66
+
67
+ def void(authorization, options = {})
68
+ post = {}
69
+ commit(:delete, "payments/#{authorization}", post)
70
+ end
71
+
72
+ # Gateway returns an error if trying to run a $0 auth as invalid payment amount
73
+ # Gateway does not support void on a card transaction and refunds can only be done on completed transactions
74
+ # (such as a purchase). Authorize transactions are considered 'active' and not 'complete' until they are captured.
75
+ def verify(credit_card, options = {})
76
+ MultiResponse.run do |r|
77
+ r.process { purchase(100, credit_card, options) }
78
+ r.process { refund(100, r.authorization, options) }
79
+ end
80
+ end
81
+
82
+ def supports_scrubbing?
83
+ true
84
+ end
85
+
86
+ def scrub(transcript)
87
+ transcript.
88
+ gsub(%r((Access_key: )\w+), '\1[FILTERED]').
89
+ gsub(%r(("number\\?":\\?")\d+), '\1[FILTERED]').
90
+ gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]')
91
+ end
92
+
93
+ private
94
+
95
+ def payment_is_ach?(options)
96
+ return unless options[:pm_type]
97
+
98
+ return true if options[:pm_type].include?('_bank')
99
+ end
100
+
101
+ def payment_is_card?(options)
102
+ return unless options[:pm_type]
103
+
104
+ return true if options[:pm_type].include?('_card')
105
+ end
106
+
107
+ def add_address(post, creditcard, options)
108
+ return unless address = options[:address]
109
+
110
+ post[:address] = {}
111
+ # name and line_1 are required at the gateway
112
+ post[:address][:name] = address[:name] if address[:name]
113
+ post[:address][:line_1] = address[:address1] if address[:address1]
114
+ post[:address][:line_2] = address[:address2] if address[:address2]
115
+ post[:address][:city] = address[:city] if address[:city]
116
+ post[:address][:state] = address[:state] if address[:state]
117
+ post[:address][:country] = address[:country] if address[:country]
118
+ post[:address][:zip] = address[:zip] if address[:zip]
119
+ post[:address][:phone_number] = address[:phone] if address[:phone]
120
+ end
121
+
122
+ def add_invoice(post, money, options)
123
+ post[:amount] = amount(money).to_f.to_s
124
+ post[:currency] = (options[:currency] || currency(money))
125
+ end
126
+
127
+ def add_payment(post, payment, options)
128
+ if payment_is_card?(options)
129
+ add_creditcard(post, payment, options)
130
+ elsif payment_is_ach?(options)
131
+ add_ach(post, payment, options)
132
+ end
133
+ end
134
+
135
+ def add_creditcard(post, payment, options)
136
+ post[:payment_method] = {}
137
+ post[:payment_method][:fields] = {}
138
+ pm_fields = post[:payment_method][:fields]
139
+
140
+ post[:payment_method][:type] = options[:pm_type]
141
+ pm_fields[:number] = payment.number
142
+ pm_fields[:expiration_month] = payment.month.to_s
143
+ pm_fields[:expiration_year] = payment.year.to_s
144
+ pm_fields[:cvv] = payment.verification_value.to_s
145
+ pm_fields[:name] = "#{payment.first_name} #{payment.last_name}"
146
+ end
147
+
148
+ def add_ach(post, payment, options)
149
+ post[:payment_method] = {}
150
+ post[:payment_method][:fields] = {}
151
+
152
+ post[:payment_method][:type] = options[:pm_type]
153
+ post[:payment_method][:fields][:proof_of_authorization] = options[:proof_of_authorization]
154
+ post[:payment_method][:fields][:first_name] = payment.first_name if payment.first_name
155
+ post[:payment_method][:fields][:last_name] = payment.last_name if payment.last_name
156
+ post[:payment_method][:fields][:routing_number] = payment.routing_number
157
+ post[:payment_method][:fields][:account_number] = payment.account_number
158
+ post[:payment_method][:fields][:payment_purpose] = options[:payment_purpose] if options[:payment_purpose]
159
+ end
160
+
161
+ def add_metadata(post, options)
162
+ post[:metadata] = options[:metadata] if options[:metadata]
163
+ end
164
+
165
+ def add_ewallet(post, options)
166
+ post[:ewallet_id] = options[:ewallet_id] if options[:ewallet_id]
167
+ end
168
+
169
+ def parse(body)
170
+ return {} if body.empty? || body.nil?
171
+
172
+ JSON.parse(body)
173
+ end
174
+
175
+ def commit(method, action, parameters)
176
+ url = (test? ? test_url : live_url) + action.to_s
177
+ rel_path = "#{method}/v1/#{action}"
178
+ response = api_request(method, url, rel_path, parameters)
179
+
180
+ Response.new(
181
+ success_from(response),
182
+ message_from(response),
183
+ response,
184
+ authorization: authorization_from(response),
185
+ avs_result: avs_result(response),
186
+ cvv_result: cvv_result(response),
187
+ test: test?,
188
+ error_code: error_code_from(response)
189
+ )
190
+ end
191
+
192
+ def api_request(method, url, rel_path, params)
193
+ params == {} ? body = '' : body = params.to_json
194
+ parse(ssl_request(method, url, body, headers(rel_path, body)))
195
+ end
196
+
197
+ def headers(rel_path, payload)
198
+ salt = SecureRandom.base64(12)
199
+ timestamp = Time.new.to_i.to_s
200
+ {
201
+ 'Content-Type' => 'application/json',
202
+ 'access_key' => @options[:access_key],
203
+ 'salt' => salt,
204
+ 'timestamp' => timestamp,
205
+ 'signature' => generate_hmac(rel_path, salt, timestamp, payload)
206
+ }
207
+ end
208
+
209
+ def generate_hmac(rel_path, salt, timestamp, payload)
210
+ signature = "#{rel_path}#{salt}#{timestamp}#{@options[:access_key]}#{@options[:secret_key]}#{payload}"
211
+ hash = Base64.urlsafe_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:secret_key], signature))
212
+ hash
213
+ end
214
+
215
+ def avs_result(response)
216
+ return nil unless (code = response.dig('data', 'payment_method_data', 'acs_check'))
217
+
218
+ AVSResult.new(code: code)
219
+ end
220
+
221
+ def cvv_result(response)
222
+ return nil unless (code = response.dig('data', 'payment_method_data', 'cvv_check'))
223
+
224
+ CVVResult.new(code)
225
+ end
226
+
227
+ def success_from(response)
228
+ response.dig('status', 'status') == 'SUCCESS' && response.dig('status', 'error') != 'ERR'
229
+ end
230
+
231
+ def message_from(response)
232
+ case response.dig('status', 'status')
233
+ when 'ERROR'
234
+ response.dig('status', 'message') == '' ? response.dig('status', 'error_code') : response.dig('status', 'message')
235
+ else
236
+ response.dig('status', 'status')
237
+ end
238
+ end
239
+
240
+ def authorization_from(response)
241
+ response.dig('data') ? response.dig('data', 'id') : response.dig('status', 'operation_id')
242
+ end
243
+
244
+ def error_code_from(response)
245
+ response.dig('status', 'error_code') unless success_from(response)
246
+ end
247
+
248
+ def handle_response(response)
249
+ case response.code.to_i
250
+ when 200...300, 400, 401, 404
251
+ response.body
252
+ else
253
+ raise ResponseError.new(response)
254
+ end
255
+ end
256
+ end
257
+ end
258
+ end
@@ -26,26 +26,24 @@ module ActiveMerchant
26
26
  'visa' => 'VISA',
27
27
  'american_express' => 'AMEX',
28
28
  'diners_club' => 'DINERS',
29
- 'switch' => 'SWITCH',
30
- 'solo' => 'SWITCH',
31
- 'laser' => 'LASER',
32
29
  'maestro' => 'MC'
33
30
  }
34
31
 
35
32
  self.money_format = :cents
36
33
  self.default_currency = 'EUR'
37
- self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ]
38
- self.supported_countries = %w(IE GB FR BE NL LU IT)
34
+ self.supported_cardtypes = %i[visa master american_express diners_club]
35
+ self.supported_countries = %w(IE GB FR BE NL LU IT US CA ES)
39
36
  self.homepage_url = 'http://www.realexpayments.com/'
40
37
  self.display_name = 'Realex'
41
38
 
42
- SUCCESS, DECLINED = "Successful", "Declined"
43
- BANK_ERROR = REALEX_ERROR = "Gateway is in maintenance. Please try again later."
44
- ERROR = CLIENT_DEACTIVATED = "Gateway Error"
39
+ SUCCESS, DECLINED = 'Successful', 'Declined'
40
+ BANK_ERROR = REALEX_ERROR = 'Gateway is in maintenance. Please try again later.'
41
+ ERROR = CLIENT_DEACTIVATED = 'Gateway Error'
45
42
 
46
43
  def initialize(options = {})
47
44
  requires!(options, :login, :password)
48
- options[:refund_hash] = Digest::SHA1.hexdigest(options[:rebate_secret]) if options.has_key?(:rebate_secret)
45
+ options[:refund_hash] = Digest::SHA1.hexdigest(options[:rebate_secret]) if options[:rebate_secret].present?
46
+ options[:credit_hash] = Digest::SHA1.hexdigest(options[:refund_secret]) if options[:refund_secret].present?
49
47
  super
50
48
  end
51
49
 
@@ -64,7 +62,7 @@ module ActiveMerchant
64
62
  end
65
63
 
66
64
  def capture(money, authorization, options = {})
67
- request = build_capture_request(authorization, options)
65
+ request = build_capture_request(money, authorization, options)
68
66
  commit(request)
69
67
  end
70
68
 
@@ -73,9 +71,9 @@ module ActiveMerchant
73
71
  commit(request)
74
72
  end
75
73
 
76
- def credit(money, authorization, options = {})
77
- ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
78
- refund(money, authorization, options)
74
+ def credit(money, creditcard, options = {})
75
+ request = build_credit_request(money, creditcard, options)
76
+ commit(request)
79
77
  end
80
78
 
81
79
  def void(authorization, options = {})
@@ -83,21 +81,36 @@ module ActiveMerchant
83
81
  commit(request)
84
82
  end
85
83
 
84
+ def verify(credit_card, options = {})
85
+ requires!(options, :order_id)
86
+
87
+ request = build_verify_request(credit_card, options)
88
+ commit(request)
89
+ end
90
+
91
+ def supports_scrubbing
92
+ true
93
+ end
94
+
95
+ def scrub(transcript)
96
+ transcript.
97
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
98
+ gsub(%r((<number>)\d+(</number>))i, '\1[FILTERED]\2')
99
+ end
100
+
86
101
  private
102
+
87
103
  def commit(request)
88
104
  response = parse(ssl_post(self.live_url, request))
89
105
 
90
106
  Response.new(
91
- (response[:result] == "00"),
107
+ (response[:result] == '00'),
92
108
  message_from(response),
93
109
  response,
94
- :test => (response[:message] =~ %r{\[ test system \]}),
95
- :authorization => authorization_from(response),
96
- :cvv_result => response[:cvnresult],
97
- :avs_result => {
98
- :street_match => response[:avspostcoderesponse],
99
- :postal_match => response[:avspostcoderesponse]
100
- }
110
+ test: (response[:message] =~ %r{\[ test system \]}),
111
+ authorization: authorization_from(response),
112
+ avs_result: AVSResult.new(code: response[:avspostcoderesponse]),
113
+ cvv_result: CVVResult.new(response[:cvnresult])
101
114
  )
102
115
  end
103
116
 
@@ -106,7 +119,7 @@ module ActiveMerchant
106
119
 
107
120
  doc = Nokogiri::XML(xml)
108
121
  doc.xpath('//response/*').each do |node|
109
- if (node.elements.size == 0)
122
+ if node.elements.size == 0
110
123
  response[node.name.downcase.to_sym] = normalize(node.text)
111
124
  else
112
125
  node.elements.each do |childnode|
@@ -125,7 +138,7 @@ module ActiveMerchant
125
138
 
126
139
  def build_purchase_or_authorization_request(action, money, credit_card, options)
127
140
  timestamp = new_timestamp
128
- xml = Builder::XmlMarkup.new :indent => 2
141
+ xml = Builder::XmlMarkup.new indent: 2
129
142
  xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'auth' do
130
143
  add_merchant_details(xml, options)
131
144
  xml.tag! 'orderid', sanitize_order_id(options[:order_id])
@@ -133,27 +146,34 @@ module ActiveMerchant
133
146
  add_card(xml, credit_card)
134
147
  xml.tag! 'autosettle', 'flag' => auto_settle_flag(action)
135
148
  add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), credit_card.number)
149
+ if credit_card.is_a?(NetworkTokenizationCreditCard)
150
+ add_network_tokenization_card(xml, credit_card)
151
+ else
152
+ add_three_d_secure(xml, options)
153
+ end
154
+ add_stored_credential(xml, options)
136
155
  add_comments(xml, options)
137
156
  add_address_and_customer_info(xml, options)
138
157
  end
139
158
  xml.target!
140
159
  end
141
160
 
142
- def build_capture_request(authorization, options)
161
+ def build_capture_request(money, authorization, options)
143
162
  timestamp = new_timestamp
144
- xml = Builder::XmlMarkup.new :indent => 2
163
+ xml = Builder::XmlMarkup.new indent: 2
145
164
  xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'settle' do
146
165
  add_merchant_details(xml, options)
166
+ add_amount(xml, money, options)
147
167
  add_transaction_identifiers(xml, authorization, options)
148
168
  add_comments(xml, options)
149
- add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), nil, nil, nil)
169
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), nil)
150
170
  end
151
171
  xml.target!
152
172
  end
153
173
 
154
174
  def build_refund_request(money, authorization, options)
155
175
  timestamp = new_timestamp
156
- xml = Builder::XmlMarkup.new :indent => 2
176
+ xml = Builder::XmlMarkup.new indent: 2
157
177
  xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'rebate' do
158
178
  add_merchant_details(xml, options)
159
179
  add_transaction_identifiers(xml, authorization, options)
@@ -166,9 +186,25 @@ module ActiveMerchant
166
186
  xml.target!
167
187
  end
168
188
 
189
+ def build_credit_request(money, credit_card, options)
190
+ timestamp = new_timestamp
191
+ xml = Builder::XmlMarkup.new indent: 2
192
+ xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'credit' do
193
+ add_merchant_details(xml, options)
194
+ xml.tag! 'orderid', sanitize_order_id(options[:order_id])
195
+ add_amount(xml, money, options)
196
+ add_card(xml, credit_card)
197
+ xml.tag! 'refundhash', @options[:credit_hash] if @options[:credit_hash]
198
+ xml.tag! 'autosettle', 'flag' => 1
199
+ add_comments(xml, options)
200
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), credit_card.number)
201
+ end
202
+ xml.target!
203
+ end
204
+
169
205
  def build_void_request(authorization, options)
170
206
  timestamp = new_timestamp
171
- xml = Builder::XmlMarkup.new :indent => 2
207
+ xml = Builder::XmlMarkup.new indent: 2
172
208
  xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'void' do
173
209
  add_merchant_details(xml, options)
174
210
  add_transaction_identifiers(xml, authorization, options)
@@ -178,16 +214,31 @@ module ActiveMerchant
178
214
  xml.target!
179
215
  end
180
216
 
217
+ # Verify initiates an OTB (Open To Buy) request
218
+ def build_verify_request(credit_card, options)
219
+ timestamp = new_timestamp
220
+ xml = Builder::XmlMarkup.new indent: 2
221
+ xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'otb' do
222
+ add_merchant_details(xml, options)
223
+ xml.tag! 'orderid', sanitize_order_id(options[:order_id])
224
+ add_card(xml, credit_card)
225
+ add_comments(xml, options)
226
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), credit_card.number)
227
+ end
228
+ xml.target!
229
+ end
230
+
181
231
  def add_address_and_customer_info(xml, options)
182
232
  billing_address = options[:billing_address] || options[:address]
183
233
  shipping_address = options[:shipping_address]
234
+ ipv4_address = ipv4?(options[:ip]) ? options[:ip] : nil
184
235
 
185
- return unless billing_address || shipping_address || options[:customer] || options[:invoice] || options[:ip]
236
+ return unless billing_address || shipping_address || options[:customer] || options[:invoice] || ipv4_address
186
237
 
187
238
  xml.tag! 'tssinfo' do
188
239
  xml.tag! 'custnum', options[:customer] if options[:customer]
189
240
  xml.tag! 'prodid', options[:invoice] if options[:invoice]
190
- xml.tag! 'custipaddress', options[:ip] if options[:ip]
241
+ xml.tag! 'custipaddress', options[:ip] if ipv4_address
191
242
 
192
243
  if billing_address
193
244
  xml.tag! 'address', 'type' => 'billing' do
@@ -207,9 +258,7 @@ module ActiveMerchant
207
258
 
208
259
  def add_merchant_details(xml, options)
209
260
  xml.tag! 'merchantid', @options[:login]
210
- if options[:account] || @options[:account]
211
- xml.tag! 'account', (options[:account] || @options[:account])
212
- end
261
+ xml.tag! 'account', (options[:account] || @options[:account]) if options[:account] || @options[:account]
213
262
  end
214
263
 
215
264
  def add_transaction_identifiers(xml, authorization, options)
@@ -221,6 +270,7 @@ module ActiveMerchant
221
270
 
222
271
  def add_comments(xml, options)
223
272
  return unless options[:description]
273
+
224
274
  xml.tag! 'comments' do
225
275
  xml.tag! 'comment', options[:description], 'id' => 1
226
276
  end
@@ -236,7 +286,7 @@ module ActiveMerchant
236
286
  xml.tag! 'expdate', expiry_date(credit_card)
237
287
  xml.tag! 'chname', credit_card.name
238
288
  xml.tag! 'type', CARD_MAPPING[card_brand(credit_card).to_s]
239
- xml.tag! 'issueno', credit_card.issue_number
289
+ xml.tag! 'issueno', ''
240
290
  xml.tag! 'cvn' do
241
291
  xml.tag! 'number', credit_card.verification_value
242
292
  xml.tag! 'presind', (options['presind'] || (credit_card.verification_value? ? 1 : nil))
@@ -244,9 +294,56 @@ module ActiveMerchant
244
294
  end
245
295
  end
246
296
 
297
+ def add_network_tokenization_card(xml, payment)
298
+ xml.tag! 'mpi' do
299
+ xml.tag! 'cavv', payment.payment_cryptogram
300
+ xml.tag! 'eci', payment.eci
301
+ end
302
+ xml.tag! 'supplementarydata' do
303
+ xml.tag! 'item', 'type' => 'mobile' do
304
+ xml.tag! 'field01', payment.source.to_s.tr('_', '-')
305
+ end
306
+ end
307
+ end
308
+
309
+ def add_three_d_secure(xml, options)
310
+ return unless three_d_secure = options[:three_d_secure]
311
+
312
+ version = three_d_secure.fetch(:version, '')
313
+ xml.tag! 'mpi' do
314
+ if /^2/.match?(version)
315
+ xml.tag! 'authentication_value', three_d_secure[:cavv]
316
+ xml.tag! 'ds_trans_id', three_d_secure[:ds_transaction_id]
317
+ else
318
+ xml.tag! 'cavv', three_d_secure[:cavv]
319
+ xml.tag! 'xid', three_d_secure[:xid]
320
+ version = '1'
321
+ end
322
+ xml.tag! 'eci', three_d_secure[:eci]
323
+ xml.tag! 'message_version', version
324
+ end
325
+ end
326
+
327
+ def add_stored_credential(xml, options)
328
+ return unless stored_credential = options[:stored_credential]
329
+
330
+ xml.tag! 'storedcredential' do
331
+ xml.tag! 'type', stored_credential_type(stored_credential[:reason_type])
332
+ xml.tag! 'initiator', stored_credential[:initiator]
333
+ xml.tag! 'sequence', stored_credential[:initial_transaction] ? 'first' : 'subsequent'
334
+ xml.tag! 'srd', stored_credential[:network_transaction_id]
335
+ end
336
+ end
337
+
338
+ def stored_credential_type(reason)
339
+ return 'oneoff' if reason == 'unscheduled'
340
+
341
+ reason
342
+ end
343
+
247
344
  def format_address_code(address)
248
345
  code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s]
249
- code.collect{|e| e.gsub(/\D/, "")}.reject{|e| e.empty?}.join("|")
346
+ code.collect { |e| e.gsub(/\D/, '') }.reject(&:empty?).join('|')
250
347
  end
251
348
 
252
349
  def new_timestamp
@@ -254,8 +351,8 @@ module ActiveMerchant
254
351
  end
255
352
 
256
353
  def add_signed_digest(xml, *values)
257
- string = Digest::SHA1.hexdigest(values.join("."))
258
- xml.tag! 'sha1hash', Digest::SHA1.hexdigest([string, @options[:password]].join("."))
354
+ string = Digest::SHA1.hexdigest(values.join('.'))
355
+ xml.tag! 'sha1hash', Digest::SHA1.hexdigest([string, @options[:password]].join('.'))
259
356
  end
260
357
 
261
358
  def auto_settle_flag(action)
@@ -267,32 +364,37 @@ module ActiveMerchant
267
364
  end
268
365
 
269
366
  def message_from(response)
270
- message = nil
271
367
  case response[:result]
272
- when "00"
273
- message = SUCCESS
274
- when "101"
275
- message = response[:message]
276
- when "102", "103"
277
- message = DECLINED
368
+ when '00'
369
+ SUCCESS
370
+ when '101'
371
+ response[:message]
372
+ when '102', '103'
373
+ DECLINED
278
374
  when /^2[0-9][0-9]/
279
- message = BANK_ERROR
375
+ BANK_ERROR
280
376
  when /^3[0-9][0-9]/
281
- message = REALEX_ERROR
377
+ REALEX_ERROR
282
378
  when /^5[0-9][0-9]/
283
- message = response[:message]
284
- when "600", "601", "603"
285
- message = ERROR
286
- when "666"
287
- message = CLIENT_DEACTIVATED
379
+ response[:message]
380
+ when '600', '601', '603'
381
+ ERROR
382
+ when '666'
383
+ CLIENT_DEACTIVATED
288
384
  else
289
- message = DECLINED
385
+ DECLINED
290
386
  end
291
387
  end
292
388
 
293
389
  def sanitize_order_id(order_id)
294
390
  order_id.to_s.gsub(/[^a-zA-Z0-9\-_]/, '')
295
391
  end
392
+
393
+ def ipv4?(ip_address)
394
+ return false if ip_address.nil?
395
+
396
+ !ip_address.match(/\A\d+\.\d+\.\d+\.\d+\z/).nil?
397
+ end
296
398
  end
297
399
  end
298
400
  end