archetype2142_activemerchant 1.124.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (271) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +3640 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +249 -0
  6. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  7. data/lib/active_merchant/billing/avs_result.rb +95 -0
  8. data/lib/active_merchant/billing/base.rb +48 -0
  9. data/lib/active_merchant/billing/check.rb +80 -0
  10. data/lib/active_merchant/billing/compatibility.rb +118 -0
  11. data/lib/active_merchant/billing/credit_card.rb +414 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +444 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +37 -0
  15. data/lib/active_merchant/billing/gateway.rb +331 -0
  16. data/lib/active_merchant/billing/gateways/adyen.rb +712 -0
  17. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +1107 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
  21. data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
  22. data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
  23. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  24. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  25. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  26. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +396 -0
  27. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  28. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  29. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
  30. data/lib/active_merchant/billing/gateways/beanstream.rb +220 -0
  31. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  32. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
  33. data/lib/active_merchant/billing/gateways/blue_snap.rb +613 -0
  34. data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
  35. data/lib/active_merchant/billing/gateways/borgun.rb +231 -0
  36. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  37. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +23 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +832 -0
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  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 +21 -0
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +371 -0
  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 +225 -0
  49. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  52. data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +311 -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 +142 -0
  57. data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  59. data/lib/active_merchant/billing/gateways/credorax.rb +496 -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 +1074 -0
  63. data/lib/active_merchant/billing/gateways/d_local.rb +253 -0
  64. data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
  65. data/lib/active_merchant/billing/gateways/decidir.rb +331 -0
  66. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  67. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  68. data/lib/active_merchant/billing/gateways/ebanx.rb +333 -0
  69. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  70. data/lib/active_merchant/billing/gateways/elavon.rb +472 -0
  71. data/lib/active_merchant/billing/gateways/element.rb +386 -0
  72. data/lib/active_merchant/billing/gateways/epay.rb +296 -0
  73. data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
  74. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  75. data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
  76. data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
  77. data/lib/active_merchant/billing/gateways/exact.rb +219 -0
  78. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  79. data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
  80. data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
  81. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  82. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  83. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  84. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  85. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  86. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  87. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  88. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  89. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  90. data/lib/active_merchant/billing/gateways/global_collect.rb +463 -0
  91. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  92. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  93. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  94. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  95. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  96. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  97. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  98. data/lib/active_merchant/billing/gateways/ipg.rb +390 -0
  99. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  100. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  101. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  102. data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
  103. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  104. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  105. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  106. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  107. data/lib/active_merchant/billing/gateways/kushki.rb +270 -0
  108. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  109. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  110. data/lib/active_merchant/billing/gateways/litle.rb +531 -0
  111. data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
  112. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  113. data/lib/active_merchant/billing/gateways/mercado_pago.rb +329 -0
  114. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
  115. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  116. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  117. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  119. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  120. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  121. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  122. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  123. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  124. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  125. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  126. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  128. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  129. data/lib/active_merchant/billing/gateways/monei.rb +422 -0
  130. data/lib/active_merchant/billing/gateways/moneris.rb +446 -0
  131. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  132. data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
  133. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  134. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  135. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  136. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  137. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  138. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  139. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  140. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  141. data/lib/active_merchant/billing/gateways/nmi.rb +356 -0
  142. data/lib/active_merchant/billing/gateways/ogone.rb +481 -0
  143. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  144. data/lib/active_merchant/billing/gateways/openpay.rb +229 -0
  145. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  146. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  147. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  148. data/lib/active_merchant/billing/gateways/orbital.rb +1209 -0
  149. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  150. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  151. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  152. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  153. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  154. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  155. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  156. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  157. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  158. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  159. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  160. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  161. data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
  162. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  163. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  166. data/lib/active_merchant/billing/gateways/payflow.rb +411 -0
  167. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  168. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  169. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  170. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  171. data/lib/active_merchant/billing/gateways/paymentez.rb +327 -0
  172. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  175. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  176. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  177. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  178. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  179. data/lib/active_merchant/billing/gateways/paypal_express.rb +270 -0
  180. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  181. data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
  182. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  183. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  184. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  185. data/lib/active_merchant/billing/gateways/payu_latam.rb +469 -0
  186. data/lib/active_merchant/billing/gateways/payu_polska.rb +178 -0
  187. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  188. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  189. data/lib/active_merchant/billing/gateways/pin.rb +246 -0
  190. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  191. data/lib/active_merchant/billing/gateways/priority.rb +390 -0
  192. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  193. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  194. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  195. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  196. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  197. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  200. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  201. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  202. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  203. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  204. data/lib/active_merchant/billing/gateways/redsys.rb +718 -0
  205. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  206. data/lib/active_merchant/billing/gateways/safe_charge.rb +301 -0
  207. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  208. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  209. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  210. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  211. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  212. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  213. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  214. data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
  215. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  216. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  217. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  218. data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
  219. data/lib/active_merchant/billing/gateways/stripe.rb +813 -0
  220. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +463 -0
  221. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  222. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  223. data/lib/active_merchant/billing/gateways/tns.rb +26 -0
  224. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  225. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  226. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  227. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  228. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  229. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  230. data/lib/active_merchant/billing/gateways/trust_commerce.rb +489 -0
  231. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  232. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  233. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +353 -0
  234. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  235. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  236. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  237. data/lib/active_merchant/billing/gateways/visanet_peru.rb +246 -0
  238. data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
  239. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  240. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  241. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  242. data/lib/active_merchant/billing/gateways/wompi.rb +153 -0
  243. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  244. data/lib/active_merchant/billing/gateways/worldpay.rb +923 -0
  245. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  246. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  247. data/lib/active_merchant/billing/gateways.rb +14 -0
  248. data/lib/active_merchant/billing/model.rb +30 -0
  249. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  250. data/lib/active_merchant/billing/payment_token.rb +21 -0
  251. data/lib/active_merchant/billing/rails.rb +3 -0
  252. data/lib/active_merchant/billing/response.rb +97 -0
  253. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  254. data/lib/active_merchant/billing.rb +16 -0
  255. data/lib/active_merchant/connection.rb +196 -0
  256. data/lib/active_merchant/country.rb +337 -0
  257. data/lib/active_merchant/empty.rb +20 -0
  258. data/lib/active_merchant/errors.rb +35 -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 +3 -0
  264. data/lib/active_merchant.rb +63 -0
  265. data/lib/activemerchant.rb +1 -0
  266. data/lib/certs/cacert.pem +3214 -0
  267. data/lib/support/gateway_support.rb +69 -0
  268. data/lib/support/outbound_hosts.rb +28 -0
  269. data/lib/support/ssl_verify.rb +88 -0
  270. data/lib/support/ssl_version.rb +86 -0
  271. metadata +463 -0
@@ -0,0 +1,496 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CredoraxGateway < Gateway
4
+ class_attribute :test_url, :live_na_url, :live_eu_url
5
+
6
+ self.display_name = 'Credorax Gateway'
7
+ self.homepage_url = 'https://www.credorax.com/'
8
+
9
+ # NOTE: the IP address you run the remote tests from will need to be
10
+ # whitelisted by Credorax; contact support@credorax.com as necessary to
11
+ # request your IP address be added to the whitelist for your test
12
+ # account.
13
+ self.test_url = 'https://intconsole.credorax.com/intenv/service/gateway'
14
+
15
+ # The live URL is assigned on a per merchant basis once certification has passed
16
+ # See the Credorax remote tests for the full certification test suite
17
+ #
18
+ # Once you have your assigned subdomain, you can override the live URL in your application via:
19
+ # ActiveMerchant::Billing::CredoraxGateway.live_url = "https://assigned-subdomain.credorax.net/crax_gate/service/gateway"
20
+ self.live_url = 'https://assigned-subdomain.credorax.net/crax_gate/service/gateway'
21
+
22
+ self.supported_countries = %w(AD AT BE BG HR CY CZ DK EE FR DE GI GR GG HU IS IE IM IT JE LV LI LT LU MT MC NO PL PT RO SM SK ES SE CH GB)
23
+
24
+ self.default_currency = 'EUR'
25
+ self.currencies_without_fractions = %w(BIF CLP DJF GNF ISK JPY KMF KRW PYG RWF VND VUV XAF XOF XPF)
26
+ self.currencies_with_three_decimal_places = %w(BHD IQD JOD KWD LYD OMR TND)
27
+
28
+ self.money_format = :cents
29
+ self.supported_cardtypes = %i[visa master maestro american_express]
30
+
31
+ RESPONSE_MESSAGES = {
32
+ '00' => 'Approved or completed successfully',
33
+ '01' => 'Refer to card issuer',
34
+ '02' => 'Refer to card issuer special condition',
35
+ '03' => 'Invalid merchant',
36
+ '04' => 'Pick up card',
37
+ '05' => 'Do not Honour',
38
+ '06' => 'Error',
39
+ '07' => 'Pick up card special condition',
40
+ '08' => 'Honour with identification',
41
+ '09' => 'Request in progress',
42
+ '10' => 'Approved for partial amount',
43
+ '11' => 'Approved (VIP)',
44
+ '12' => 'Invalid transaction',
45
+ '13' => 'Invalid amount',
46
+ '14' => 'Invalid card number',
47
+ '15' => 'No such issuer',
48
+ '16' => 'Approved, update track 3',
49
+ '17' => 'Customer cancellation',
50
+ '18' => 'Customer dispute',
51
+ '19' => 'Re-enter transaction',
52
+ '20' => 'Invalid response',
53
+ '21' => 'No action taken',
54
+ '22' => 'Suspected malfunction',
55
+ '23' => 'Unacceptable transaction fee',
56
+ '24' => 'File update not supported by receiver',
57
+ '25' => 'No such record',
58
+ '26' => 'Duplicate record update, old record replaced',
59
+ '27' => 'File update field edit error',
60
+ '28' => 'File locked out while update',
61
+ '29' => 'File update error, contact acquirer',
62
+ '30' => 'Format error',
63
+ '31' => 'Issuer signed-off',
64
+ '32' => 'Completed partially',
65
+ '33' => 'Pick-up, expired card',
66
+ '34' => 'Suspect Fraud',
67
+ '35' => 'Pick-up, card acceptor contact acquirer',
68
+ '36' => 'Pick up, card restricted',
69
+ '37' => 'Pick up, call acquirer security',
70
+ '38' => 'Pick up, Allowable PIN tries exceeded',
71
+ '39' => 'Transaction Not Allowed',
72
+ '40' => 'Requested function not supported',
73
+ '41' => 'Lost Card, Pickup',
74
+ '42' => 'No universal account',
75
+ '43' => 'Pick up, stolen card',
76
+ '44' => 'No investment account',
77
+ '50' => 'Do not renew',
78
+ '51' => 'Not sufficient funds',
79
+ '52' => 'No checking Account',
80
+ '53' => 'No savings account',
81
+ '54' => 'Expired card',
82
+ '55' => 'Pin incorrect',
83
+ '56' => 'No card record',
84
+ '57' => 'Transaction not allowed for cardholder',
85
+ '58' => 'Transaction not allowed for merchant',
86
+ '59' => 'Suspected Fraud',
87
+ '60' => 'Card acceptor contact acquirer',
88
+ '61' => 'Exceeds withdrawal amount limit',
89
+ '62' => 'Restricted card',
90
+ '63' => 'Security violation',
91
+ '64' => 'Wrong original amount',
92
+ '65' => 'Activity count limit exceeded',
93
+ '66' => 'Call acquirers security department',
94
+ '67' => 'Card to be picked up at ATM',
95
+ '68' => 'Response received too late.',
96
+ '70' => 'Invalid transaction; contact card issuer',
97
+ '71' => 'Decline PIN not changed',
98
+ '75' => 'Pin tries exceeded',
99
+ '76' => 'Wrong PIN, number of PIN tries exceeded',
100
+ '77' => 'Wrong Reference No.',
101
+ '78' => 'Record Not Found',
102
+ '79' => 'Already reversed',
103
+ '80' => 'Network error',
104
+ '81' => 'Foreign network error / PIN cryptographic error',
105
+ '82' => 'Time out at issuer system',
106
+ '83' => 'Transaction failed',
107
+ '84' => 'Pre-authorization timed out',
108
+ '85' => 'No reason to decline',
109
+ '86' => 'Cannot verify pin',
110
+ '87' => 'Purchase amount only, no cashback allowed',
111
+ '88' => 'MAC sync Error',
112
+ '89' => 'Authentication failure',
113
+ '91' => 'Issuer not available',
114
+ '92' => 'Unable to route at acquirer Module',
115
+ '93' => 'Cannot be completed, violation of law',
116
+ '94' => 'Duplicate Transmission',
117
+ '95' => 'Reconcile error / Auth Not found',
118
+ '96' => 'System malfunction',
119
+ 'R0' => 'Stop Payment Order',
120
+ 'R1' => 'Revocation of Authorisation Order',
121
+ 'R3' => 'Revocation of all Authorisations Order',
122
+ '1A' => 'Strong Customer Authentication required'
123
+ }
124
+
125
+ def initialize(options = {})
126
+ requires!(options, :merchant_id, :cipher_key)
127
+ super
128
+ end
129
+
130
+ def purchase(amount, payment_method, options = {})
131
+ post = {}
132
+ add_invoice(post, amount, options)
133
+ add_payment_method(post, payment_method)
134
+ add_customer_data(post, options)
135
+ add_email(post, options)
136
+ add_3d_secure(post, options)
137
+ add_3ds_2_optional_fields(post, options)
138
+ add_echo(post, options)
139
+ add_submerchant_id(post, options)
140
+ add_stored_credential(post, options)
141
+ add_processor(post, options)
142
+
143
+ commit(:purchase, post)
144
+ end
145
+
146
+ def authorize(amount, payment_method, options = {})
147
+ post = {}
148
+ add_invoice(post, amount, options)
149
+ add_payment_method(post, payment_method)
150
+ add_customer_data(post, options)
151
+ add_email(post, options)
152
+ add_3d_secure(post, options)
153
+ add_3ds_2_optional_fields(post, options)
154
+ add_echo(post, options)
155
+ add_submerchant_id(post, options)
156
+ add_stored_credential(post, options)
157
+ add_processor(post, options)
158
+ add_authorization_details(post, options)
159
+
160
+ commit(:authorize, post)
161
+ end
162
+
163
+ def capture(amount, authorization, options = {})
164
+ post = {}
165
+ add_invoice(post, amount, options)
166
+ add_reference(post, authorization)
167
+ add_customer_data(post, options)
168
+ add_echo(post, options)
169
+ add_submerchant_id(post, options)
170
+ add_processor(post, options)
171
+
172
+ commit(:capture, post)
173
+ end
174
+
175
+ def void(authorization, options = {})
176
+ post = {}
177
+ add_customer_data(post, options)
178
+ reference_action = add_reference(post, authorization)
179
+ add_echo(post, options)
180
+ add_submerchant_id(post, options)
181
+ post[:a1] = generate_unique_id
182
+ add_processor(post, options)
183
+
184
+ commit(:void, post, reference_action)
185
+ end
186
+
187
+ def refund(amount, authorization, options = {})
188
+ post = {}
189
+ add_invoice(post, amount, options)
190
+ add_reference(post, authorization)
191
+ add_customer_data(post, options)
192
+ add_echo(post, options)
193
+ add_submerchant_id(post, options)
194
+ add_processor(post, options)
195
+ add_email(post, options)
196
+
197
+ if options[:referral_cft]
198
+ add_customer_name(post, options)
199
+ commit(:referral_cft, post)
200
+ else
201
+ commit(:refund, post)
202
+ end
203
+ end
204
+
205
+ def credit(amount, payment_method, options = {})
206
+ post = {}
207
+ add_invoice(post, amount, options)
208
+ add_payment_method(post, payment_method)
209
+ add_customer_data(post, options)
210
+ add_email(post, options)
211
+ add_echo(post, options)
212
+ add_submerchant_id(post, options)
213
+ add_transaction_type(post, options)
214
+ add_processor(post, options)
215
+
216
+ commit(:credit, post)
217
+ end
218
+
219
+ def verify(credit_card, options = {})
220
+ MultiResponse.run(:use_first_response) do |r|
221
+ r.process { authorize(100, credit_card, options) }
222
+ r.process(:ignore_result) { void(r.authorization, options) }
223
+ end
224
+ end
225
+
226
+ def supports_scrubbing?
227
+ true
228
+ end
229
+
230
+ def scrub(transcript)
231
+ transcript.
232
+ gsub(%r((b1=)\d+), '\1[FILTERED]').
233
+ gsub(%r((b5=)\d+), '\1[FILTERED]')
234
+ end
235
+
236
+ def add_3ds_2_optional_fields(post, options)
237
+ three_ds = options[:three_ds_2] || {}
238
+
239
+ if three_ds.has_key?(:optional)
240
+ three_ds[:optional].each do |key, value|
241
+ normalized_value = normalize(value)
242
+ next if normalized_value.nil?
243
+
244
+ if key == :'3ds_homephonecountry'
245
+ next unless options[:billing_address] && options[:billing_address][:phone]
246
+ end
247
+
248
+ post[key] = normalized_value unless post[key]
249
+ end
250
+ end
251
+
252
+ post
253
+ end
254
+
255
+ private
256
+
257
+ def add_invoice(post, money, options)
258
+ currency = options[:currency] || currency(money)
259
+
260
+ post[:a4] = localized_amount(money, currency)
261
+ post[:a1] = generate_unique_id
262
+ post[:a5] = currency
263
+ post[:h9] = options[:order_id]
264
+ post[:i2] = options[:billing_descriptor] if options[:billing_descriptor]
265
+ end
266
+
267
+ CARD_TYPES = {
268
+ 'visa' => '1',
269
+ 'mastercard' => '2',
270
+ 'maestro' => '9'
271
+ }
272
+
273
+ def add_payment_method(post, payment_method)
274
+ post[:c1] = payment_method.name
275
+ post[:b2] = CARD_TYPES[payment_method.brand] || ''
276
+ post[:b1] = payment_method.number
277
+ post[:b5] = payment_method.verification_value
278
+ post[:b4] = format(payment_method.year, :two_digits)
279
+ post[:b3] = format(payment_method.month, :two_digits)
280
+ end
281
+
282
+ def add_stored_credential(post, options)
283
+ add_transaction_type(post, options)
284
+ # if :transaction_type option is not passed, then check for :stored_credential options
285
+ return unless (stored_credential = options[:stored_credential]) && options.dig(:transaction_type).nil?
286
+
287
+ if stored_credential[:initiator] == 'merchant'
288
+ case stored_credential[:reason_type]
289
+ when 'recurring'
290
+ stored_credential[:initial_transaction] ? post[:a9] = '1' : post[:a9] = '2'
291
+ when 'installment', 'unscheduled'
292
+ post[:a9] = '8'
293
+ end
294
+ else
295
+ post[:a9] = '9'
296
+ end
297
+ end
298
+
299
+ def add_customer_data(post, options)
300
+ post[:d1] = options[:ip] || '127.0.0.1'
301
+ if (billing_address = options[:billing_address])
302
+ post[:c5] = billing_address[:address1] if billing_address[:address1]
303
+ post[:c7] = billing_address[:city] if billing_address[:city]
304
+ post[:c10] = billing_address[:zip] if billing_address[:zip]
305
+ post[:c8] = billing_address[:state] if billing_address[:state]
306
+ post[:c9] = billing_address[:country] if billing_address[:country]
307
+ post[:c2] = billing_address[:phone] if billing_address[:phone]
308
+ end
309
+ end
310
+
311
+ def add_reference(post, authorization)
312
+ response_id, authorization_code, request_id, action = authorization.split(';')
313
+ post[:g2] = response_id
314
+ post[:g3] = authorization_code
315
+ post[:g4] = request_id
316
+ action || :authorize
317
+ end
318
+
319
+ def add_email(post, options)
320
+ post[:c3] = options[:email] || 'unspecified@example.com'
321
+ end
322
+
323
+ def add_customer_name(post, options)
324
+ post[:j5] = options[:first_name] if options[:first_name]
325
+ post[:j13] = options[:last_name] if options[:last_name]
326
+ end
327
+
328
+ def add_3d_secure(post, options)
329
+ if (options[:eci] && options[:xid]) || (options[:three_d_secure] && options[:three_d_secure][:version]&.start_with?('1'))
330
+ add_3d_secure_1_data(post, options)
331
+ elsif options[:execute_threed] && options[:three_ds_2]
332
+ three_ds_2_options = options[:three_ds_2]
333
+ browser_info = three_ds_2_options[:browser_info]
334
+ post[:'3ds_initiate'] = options[:three_ds_initiate] || '01'
335
+ post[:f23] = options[:f23] if options[:f23]
336
+ post[:'3ds_purchasedate'] = Time.now.utc.strftime('%Y%m%d%I%M%S')
337
+ options.dig(:stored_credential, :initiator) == 'merchant' ? post[:'3ds_channel'] = '03' : post[:'3ds_channel'] = '02'
338
+ post[:'3ds_reqchallengeind'] = options[:three_ds_reqchallengeind] if options[:three_ds_reqchallengeind]
339
+ post[:'3ds_redirect_url'] = three_ds_2_options[:notification_url]
340
+ post[:'3ds_challengewindowsize'] = options[:three_ds_challenge_window_size] || '03'
341
+ post[:d5] = browser_info[:user_agent]
342
+ post[:'3ds_transtype'] = options[:three_ds_transtype] || '01'
343
+ post[:'3ds_browsertz'] = browser_info[:timezone]
344
+ post[:'3ds_browserscreenwidth'] = browser_info[:width]
345
+ post[:'3ds_browserscreenheight'] = browser_info[:height]
346
+ post[:'3ds_browsercolordepth'] = browser_info[:depth].to_s == '30' ? '32' : browser_info[:depth]
347
+ post[:d6] = browser_info[:language]
348
+ post[:'3ds_browserjavaenabled'] = browser_info[:java]
349
+ post[:'3ds_browseracceptheader'] = browser_info[:accept_header]
350
+ add_complete_shipping_address(post, options[:shipping_address]) if options[:shipping_address]
351
+ elsif options[:three_d_secure]
352
+ add_normalized_3d_secure_2_data(post, options)
353
+ end
354
+ end
355
+
356
+ def add_3d_secure_1_data(post, options)
357
+ if three_d_secure_options = options[:three_d_secure]
358
+ post[:i8] = build_i8(
359
+ three_d_secure_options[:eci],
360
+ three_d_secure_options[:cavv],
361
+ three_d_secure_options[:xid]
362
+ )
363
+ post[:'3ds_version'] = three_d_secure_options[:version]&.start_with?('1') ? '1.0' : three_d_secure_options[:version]
364
+ else
365
+ post[:i8] = build_i8(options[:eci], options[:cavv], options[:xid])
366
+ post[:'3ds_version'] = options[:three_ds_version].nil? || options[:three_ds_version]&.start_with?('1') ? '1.0' : options[:three_ds_version]
367
+ end
368
+ end
369
+
370
+ def add_complete_shipping_address(post, shipping_address)
371
+ return if shipping_address.values.any?(&:blank?)
372
+
373
+ post[:'3ds_shipaddrstate'] = shipping_address[:state]
374
+ post[:'3ds_shipaddrpostcode'] = shipping_address[:zip]
375
+ post[:'3ds_shipaddrline2'] = shipping_address[:address2]
376
+ post[:'3ds_shipaddrline1'] = shipping_address[:address1]
377
+ post[:'3ds_shipaddrcountry'] = shipping_address[:country]
378
+ post[:'3ds_shipaddrcity'] = shipping_address[:city]
379
+ end
380
+
381
+ def add_normalized_3d_secure_2_data(post, options)
382
+ three_d_secure_options = options[:three_d_secure]
383
+
384
+ post[:i8] = build_i8(
385
+ three_d_secure_options[:eci],
386
+ three_d_secure_options[:cavv]
387
+ )
388
+ post[:'3ds_version'] = three_d_secure_options[:version]&.start_with?('2') ? '2.0' : three_d_secure_options[:version]
389
+ post[:'3ds_dstrxid'] = three_d_secure_options[:ds_transaction_id]
390
+ end
391
+
392
+ def build_i8(eci, cavv = nil, xid = nil)
393
+ "#{eci}:#{cavv || 'none'}:#{xid || 'none'}"
394
+ end
395
+
396
+ def add_echo(post, options)
397
+ # The d2 parameter is used during the certification process
398
+ # See remote tests for full certification test suite
399
+ post[:d2] = options[:echo] unless options[:echo].blank?
400
+ end
401
+
402
+ def add_submerchant_id(post, options)
403
+ post[:h3] = options[:submerchant_id] if options[:submerchant_id]
404
+ end
405
+
406
+ def add_transaction_type(post, options)
407
+ post[:a9] = options[:transaction_type] if options[:transaction_type]
408
+ post[:a2] = '3' if options.dig(:metadata, :manual_entry)
409
+ end
410
+
411
+ def add_processor(post, options)
412
+ post[:r1] = options[:processor] if options[:processor]
413
+ post[:r2] = options[:processor_merchant_id] if options[:processor_merchant_id]
414
+ end
415
+
416
+ def add_authorization_details(post, options)
417
+ post[:a10] = options[:authorization_type] if options[:authorization_type]
418
+ post[:a11] = options[:multiple_capture_count] if options[:multiple_capture_count]
419
+ end
420
+
421
+ ACTIONS = {
422
+ purchase: '1',
423
+ authorize: '2',
424
+ capture: '3',
425
+ authorize_void: '4',
426
+ refund: '5',
427
+ credit: '6',
428
+ purchase_void: '7',
429
+ refund_void: '8',
430
+ capture_void: '9',
431
+ threeds_completion: '92',
432
+ referral_cft: '34'
433
+ }
434
+
435
+ def commit(action, params, reference_action = nil)
436
+ raw_response = ssl_post(url, post_data(action, params, reference_action))
437
+ response = parse(raw_response)
438
+
439
+ Response.new(
440
+ success_from(response),
441
+ message_from(response),
442
+ response,
443
+ authorization: "#{response['Z1']};#{response['Z4']};#{response['A1']};#{action}",
444
+ avs_result: AVSResult.new(code: response['Z9']),
445
+ cvv_result: CVVResult.new(response['Z14']),
446
+ test: test?
447
+ )
448
+ end
449
+
450
+ def sign_request(params)
451
+ params = params.sort
452
+ values = params.map do |param|
453
+ value = param[1].gsub(/[<>()\\]/, ' ')
454
+ value.strip
455
+ end
456
+ Digest::MD5.hexdigest(values.join + @options[:cipher_key])
457
+ end
458
+
459
+ def post_data(action, params, reference_action)
460
+ params.keys.each { |key| params[key] = params[key].to_s }
461
+ params[:M] = @options[:merchant_id]
462
+ params[:O] = request_action(action, reference_action)
463
+ params[:K] = sign_request(params)
464
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
465
+ end
466
+
467
+ def request_action(action, reference_action)
468
+ if reference_action
469
+ ACTIONS["#{reference_action}_#{action}".to_sym]
470
+ else
471
+ ACTIONS[action]
472
+ end
473
+ end
474
+
475
+ def url
476
+ test? ? test_url : live_url
477
+ end
478
+
479
+ def parse(body)
480
+ Hash[CGI::parse(body).map { |k, v| [k.upcase, v.first] }]
481
+ end
482
+
483
+ def success_from(response)
484
+ response['Z2'] == '0'
485
+ end
486
+
487
+ def message_from(response)
488
+ if success_from(response)
489
+ 'Succeeded'
490
+ else
491
+ RESPONSE_MESSAGES[response['Z6']] || response['Z3'] || 'Unable to read error message'
492
+ end
493
+ end
494
+ end
495
+ end
496
+ end