swiss-activemerchant 1.0.1

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