swiss-crm-activemerchant 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +252 -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 +242 -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 +228 -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 +354 -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 +121 -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,587 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CheckoutV2Gateway < Gateway
4
+ self.display_name = 'Checkout.com Unified Payments'
5
+ self.homepage_url = 'https://www.checkout.com/'
6
+ self.live_url = 'https://api.checkout.com'
7
+ self.test_url = 'https://api.sandbox.checkout.com'
8
+
9
+ self.supported_countries = %w[AD AE AR AT AU BE BG BH BR CH CL CN CO CY CZ DE DK EE EG ES FI FR GB GR HK HR HU IE IS IT JO JP KW LI LT LU LV MC MT MX MY NL NO NZ OM PE PL PT QA RO SA SE SG SI SK SM TR US]
10
+ self.default_currency = 'USD'
11
+ self.money_format = :cents
12
+ self.supported_cardtypes = %i[visa master american_express diners_club maestro discover jcb mada bp_plus]
13
+ self.currencies_without_fractions = %w(BIF DJF GNF ISK KMF XAF CLF XPF JPY PYG RWF KRW VUV VND XOF)
14
+ self.currencies_with_three_decimal_places = %w(BHD LYD JOD KWD OMR TND)
15
+
16
+ SUCCESS_CODES = %w{10000 10008 10011 10076 10077 10081}.freeze
17
+
18
+ SOFT_DECLINE_CODES = %w{
19
+ 20001 20002 20003 20005 20006 20009 20010 20012 20013 20014 20017
20
+ 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028
21
+ 20029 20030 20031 20032 20038 20039 20040 20042 20044 20046 20051
22
+ 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062
23
+ 20063 20064 20065 20066 20067 20068 20075 20078 20082 20083 20084
24
+ 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095
25
+ 20096 20097 20098 20099 2006P 200N0 200N7 200O5 200P1 200P9 200R1
26
+ 200R3 200S4 200T2 200T3 200T5 20100 20101 20102 20103 20104 20105
27
+ 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116
28
+ 20117 20118 20119 20120 20121 20123 20124 20150 20151 20152 20153
29
+ 20154 20155 20156 20157 20158 20179 20182 20183 20193
30
+ }.freeze
31
+ LIVE_ACCESS_TOKEN_URL = 'https://access.checkout.com/connect/token'
32
+ TEST_ACCESS_TOKEN_URL = 'https://access.sandbox.checkout.com/connect/token'
33
+
34
+ def initialize(options = {})
35
+ @options = options
36
+ @access_token = nil
37
+ @response_http_code = nil
38
+
39
+ if options.has_key?(:secret_key)
40
+ requires!(options, :secret_key)
41
+ else
42
+ requires!(options, :client_id, :client_secret)
43
+ @access_token = setup_access_token
44
+ end
45
+
46
+ super
47
+ end
48
+
49
+ def purchase(amount, payment_method, options = {})
50
+ post = {}
51
+ build_auth_or_purchase(post, amount, payment_method, options)
52
+
53
+ commit(:purchase, post, options)
54
+ end
55
+
56
+ def authorize(amount, payment_method, options = {})
57
+ post = {}
58
+ post[:capture] = false
59
+ build_auth_or_purchase(post, amount, payment_method, options)
60
+ options[:incremental_authorization] ? commit(:incremental_authorize, post, options, options[:incremental_authorization]) : commit(:authorize, post, options)
61
+ end
62
+
63
+ def capture(amount, authorization, options = {})
64
+ post = {}
65
+ post[:capture_type] = options[:capture_type] || 'Final'
66
+ add_invoice(post, amount, options)
67
+ add_customer_data(post, options)
68
+ add_shipping_address(post, options)
69
+ add_metadata(post, options)
70
+
71
+ commit(:capture, post, options, authorization)
72
+ end
73
+
74
+ def credit(amount, payment, options = {})
75
+ post = {}
76
+ post[:instruction] = {}
77
+ post[:instruction][:funds_transfer_type] = options[:funds_transfer_type] || 'FD'
78
+ add_processing_channel(post, options)
79
+ add_invoice(post, amount, options)
80
+ add_payment_method(post, payment, options, :destination)
81
+ add_source(post, payment, options)
82
+
83
+ commit(:credit, post, options)
84
+ end
85
+
86
+ def void(authorization, _options = {})
87
+ post = {}
88
+ add_metadata(post, options)
89
+
90
+ commit(:void, post, options, authorization)
91
+ end
92
+
93
+ def refund(amount, authorization, options = {})
94
+ post = {}
95
+ add_invoice(post, amount, options)
96
+ add_customer_data(post, options)
97
+ add_metadata(post, options)
98
+
99
+ commit(:refund, post, options, authorization)
100
+ end
101
+
102
+ def verify(credit_card, options = {})
103
+ authorize(0, credit_card, options)
104
+ end
105
+
106
+ def verify_payment(authorization, option = {})
107
+ commit(:verify_payment, nil, options, authorization, :get)
108
+ end
109
+
110
+ def supports_scrubbing?
111
+ true
112
+ end
113
+
114
+ def scrub(transcript)
115
+ transcript.
116
+ gsub(/(Authorization: )[^\\]*/i, '\1[FILTERED]').
117
+ gsub(/("number\\":\\")\d+/, '\1[FILTERED]').
118
+ gsub(/("cvv\\":\\")\d+/, '\1[FILTERED]').
119
+ gsub(/("cryptogram\\":\\")\w+/, '\1[FILTERED]').
120
+ gsub(/(source\\":\{.*\\"token\\":\\")\d+/, '\1[FILTERED]').
121
+ gsub(/("token\\":\\")\w+/, '\1[FILTERED]')
122
+ end
123
+
124
+ def store(payment_method, options = {})
125
+ post = {}
126
+ MultiResponse.run do |r|
127
+ if payment_method.is_a?(NetworkTokenizationCreditCard)
128
+ r.process { verify(payment_method, options) }
129
+ break r unless r.success?
130
+
131
+ r.params['source']['customer'] = r.params['customer']
132
+ r.process { response(:store, true, r.params['source']) }
133
+ else
134
+ r.process { tokenize(payment_method, options) }
135
+ break r unless r.success?
136
+
137
+ token = r.params['token']
138
+ add_payment_method(post, token, options)
139
+ post.merge!(post.delete(:source))
140
+ add_customer_data(post, options)
141
+ add_shipping_address(post, options)
142
+ r.process { commit(:store, post, options) }
143
+ end
144
+ end
145
+ end
146
+
147
+ def unstore(id, options = {})
148
+ commit(:unstore, nil, options, id, :delete)
149
+ end
150
+
151
+ private
152
+
153
+ def build_auth_or_purchase(post, amount, payment_method, options)
154
+ add_invoice(post, amount, options)
155
+ add_authorization_type(post, options)
156
+ add_payment_method(post, payment_method, options)
157
+ add_customer_data(post, options)
158
+ add_extra_customer_data(post, payment_method, options)
159
+ add_shipping_address(post, options)
160
+ add_stored_credential_options(post, options)
161
+ add_transaction_data(post, options)
162
+ add_3ds(post, options)
163
+ add_metadata(post, options, payment_method)
164
+ add_processing_channel(post, options)
165
+ add_marketplace_data(post, options)
166
+ end
167
+
168
+ def add_invoice(post, money, options)
169
+ post[:amount] = localized_amount(money, options[:currency])
170
+ post[:reference] = options[:order_id]
171
+ post[:currency] = options[:currency] || currency(money)
172
+ if options[:descriptor_name] || options[:descriptor_city]
173
+ post[:billing_descriptor] = {}
174
+ post[:billing_descriptor][:name] = options[:descriptor_name] if options[:descriptor_name]
175
+ post[:billing_descriptor][:city] = options[:descriptor_city] if options[:descriptor_city]
176
+ end
177
+ post[:metadata] = {}
178
+ post[:metadata][:udf5] = application_id || 'ActiveMerchant'
179
+ end
180
+
181
+ def add_authorization_type(post, options)
182
+ post[:authorization_type] = options[:authorization_type] if options[:authorization_type]
183
+ end
184
+
185
+ def add_metadata(post, options, payment_method = nil)
186
+ post[:metadata] = {} unless post[:metadata]
187
+ post[:metadata].merge!(options[:metadata]) if options[:metadata]
188
+ post[:metadata][:udf1] = 'mada' if payment_method.try(:brand) == 'mada'
189
+ end
190
+
191
+ def add_payment_method(post, payment_method, options, key = :source)
192
+ post[key] = {}
193
+ case payment_method
194
+ when NetworkTokenizationCreditCard
195
+ token_type = token_type_from(payment_method)
196
+ cryptogram = payment_method.payment_cryptogram
197
+ eci = payment_method.eci || options[:eci]
198
+ eci ||= '05' if token_type == 'vts'
199
+
200
+ post[key][:type] = 'network_token'
201
+ post[key][:token] = payment_method.number
202
+ post[key][:token_type] = token_type
203
+ post[key][:cryptogram] = cryptogram if cryptogram
204
+ post[key][:eci] = eci if eci
205
+ when ->(pm) { pm.try(:credit_card?) }
206
+ post[key][:type] = 'card'
207
+ post[key][:name] = payment_method.name
208
+ post[key][:number] = payment_method.number
209
+ post[key][:cvv] = payment_method.verification_value
210
+ post[key][:stored] = 'true' if options[:card_on_file] == true
211
+ if options[:account_holder_type]
212
+ post[key][:account_holder] = {}
213
+ post[key][:account_holder][:type] = options[:account_holder_type]
214
+ post[key][:account_holder][:first_name] = payment_method.first_name if payment_method.first_name
215
+ post[key][:account_holder][:last_name] = payment_method.last_name if payment_method.last_name
216
+ else
217
+ post[key][:first_name] = payment_method.first_name if payment_method.first_name
218
+ post[key][:last_name] = payment_method.last_name if payment_method.last_name
219
+ end
220
+ end
221
+ if payment_method.is_a?(String)
222
+ if /tok/.match?(payment_method)
223
+ post[:source][:type] = 'token'
224
+ post[:source][:token] = payment_method
225
+ elsif /src/.match?(payment_method)
226
+ post[key][:type] = 'id'
227
+ post[key][:id] = payment_method
228
+ else
229
+ add_source(post, payment_method, options)
230
+ end
231
+ elsif payment_method.try(:year)
232
+ post[key][:expiry_year] = format(payment_method.year, :four_digits)
233
+ post[key][:expiry_month] = format(payment_method.month, :two_digits)
234
+ end
235
+ end
236
+
237
+ def add_source(post, payment_method, options)
238
+ post[:source] = {}
239
+
240
+ case payment_method
241
+ when 'paypal'
242
+ post[:source][:type] = payment_method
243
+ when 'sofort'
244
+ post[:source][:type] = payment_method
245
+ when 'klarna'
246
+ post[:source][:type] = payment_method
247
+ post[:source][:account_holder] = {}
248
+ post[:source][:account_holder][:first_name] = options[:first_name] if options[:first_name]
249
+ post[:source][:account_holder][:last_name] = options[:last_name] if options[:last_name]
250
+ post[:source][:account_holder][:email] = options[:email] || nil
251
+ post[:source][:account_holder][:phone] = {}
252
+ post[:source][:account_holder][:phone][:country_code] = options[:phone_country_code] if options[:phone_country_code]
253
+ post[:source][:account_holder][:phone][:number] = options[:phone] || options.dig(:billing_address, :phone) || options.dig(:billing_address, :phone_number)
254
+ when 'giropay'
255
+ post[:source][:type] = payment_method
256
+ post[:source][:account_holder] = {}
257
+ post[:source][:account_holder][:first_name] = options[:first_name] if options[:first_name]
258
+ post[:source][:account_holder][:last_name] = options[:last_name] if options[:last_name]
259
+ else
260
+ post[:source][:type] = options[:source_type] if options[:source_type]
261
+ post[:source][:id] = options[:source_id] if options[:source_id]
262
+ end
263
+ end
264
+
265
+ def add_customer_data(post, options)
266
+ post[:customer] = {}
267
+ post[:customer][:email] = options[:email] || nil
268
+ post[:payment_ip] = options[:ip] if options[:ip]
269
+ address = options[:billing_address]
270
+ if address && post[:source]
271
+ post[:source][:billing_address] = {}
272
+ post[:source][:billing_address][:address_line1] = address[:address1] unless address[:address1].blank?
273
+ post[:source][:billing_address][:address_line2] = address[:address2] unless address[:address2].blank?
274
+ post[:source][:billing_address][:city] = address[:city] unless address[:city].blank?
275
+ post[:source][:billing_address][:state] = address[:state] unless address[:state].blank?
276
+ post[:source][:billing_address][:country] = address[:country] unless address[:country].blank?
277
+ post[:source][:billing_address][:zip] = address[:zip] unless address[:zip].blank?
278
+ end
279
+ end
280
+
281
+ # created a separate method for these fields because they should not be included
282
+ # in all transaction types that include methods with source and customer fields
283
+ def add_extra_customer_data(post, payment_method, options)
284
+ post[:source][:phone] = {}
285
+ post[:source][:phone][:number] = options[:phone] || options.dig(:billing_address, :phone) || options.dig(:billing_address, :phone_number)
286
+ post[:source][:phone][:country_code] = options[:phone_country_code] if options[:phone_country_code]
287
+ post[:customer][:name] = payment_method.name if payment_method.respond_to?(:name)
288
+ end
289
+
290
+ def add_shipping_address(post, options)
291
+ if address = options[:shipping_address]
292
+ post[:shipping] = {}
293
+ post[:shipping][:address] = {}
294
+ post[:shipping][:address][:address_line1] = address[:address1] unless address[:address1].blank?
295
+ post[:shipping][:address][:address_line2] = address[:address2] unless address[:address2].blank?
296
+ post[:shipping][:address][:city] = address[:city] unless address[:city].blank?
297
+ post[:shipping][:address][:state] = address[:state] unless address[:state].blank?
298
+ post[:shipping][:address][:country] = address[:country] unless address[:country].blank?
299
+ post[:shipping][:address][:zip] = address[:zip] unless address[:zip].blank?
300
+ end
301
+ end
302
+
303
+ def add_transaction_data(post, options = {})
304
+ post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
305
+ post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
306
+ post[:payment_type] = 'MOTO' if options[:transaction_indicator] == 3 || options.dig(:metadata, :manual_entry)
307
+ post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
308
+ end
309
+
310
+ def merchant_initiated_override(post, options)
311
+ post[:merchant_initiated] = true
312
+ post[:source][:stored] = true
313
+ post[:previous_payment_id] = options[:merchant_initiated_transaction_id]
314
+ end
315
+
316
+ def add_stored_credentials_using_normalized_fields(post, options)
317
+ if options[:stored_credential][:initial_transaction] == true
318
+ post[:merchant_initiated] = false
319
+ else
320
+ post[:source][:stored] = true
321
+ post[:previous_payment_id] = options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
322
+ post[:merchant_initiated] = true
323
+ end
324
+ end
325
+
326
+ def add_stored_credential_options(post, options = {})
327
+ return unless options[:stored_credential]
328
+
329
+ post[:payment_type] = 'Recurring' if %w(recurring installment).include? options[:stored_credential][:reason_type]
330
+
331
+ if options[:merchant_initiated_transaction_id]
332
+ merchant_initiated_override(post, options)
333
+ else
334
+ add_stored_credentials_using_normalized_fields(post, options)
335
+ end
336
+ end
337
+
338
+ def add_3ds(post, options)
339
+ if options[:three_d_secure] || options[:execute_threed]
340
+ post[:'3ds'] = {}
341
+ post[:'3ds'][:enabled] = true
342
+ post[:success_url] = options[:redirect_links][:success_url] if options[:redirect_links]
343
+ post[:failure_url] = options[:redirect_links][:failure_url] if options[:redirect_links]
344
+ post[:'3ds'][:attempt_n3d] = options[:attempt_n3d] if options[:attempt_n3d]
345
+ post[:'3ds'][:challenge_indicator] = options[:challenge_indicator] if options[:challenge_indicator]
346
+ post[:'3ds'][:exemption] = options[:exemption] if options[:exemption]
347
+ end
348
+
349
+ if options[:three_d_secure]
350
+ post[:'3ds'][:eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
351
+ post[:'3ds'][:cryptogram] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
352
+ post[:'3ds'][:version] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
353
+ post[:'3ds'][:xid] = options[:three_d_secure][:ds_transaction_id] || options[:three_d_secure][:xid]
354
+ post[:'3ds'][:status] = options[:three_d_secure][:authentication_response_status]
355
+ end
356
+ end
357
+
358
+ def add_processing_channel(post, options)
359
+ post[:processing_channel_id] = options[:processing_channel_id] if options[:processing_channel_id]
360
+ end
361
+
362
+ def add_marketplace_data(post, options)
363
+ if options[:marketplace]
364
+ post[:marketplace] = {}
365
+ post[:marketplace][:sub_entity_id] = options[:marketplace][:sub_entity_id] if options[:marketplace][:sub_entity_id]
366
+ end
367
+ end
368
+
369
+ def access_token_header
370
+ {
371
+ 'Authorization' => "Basic #{Base64.encode64("#{@options[:client_id]}:#{@options[:client_secret]}").delete("\n")}",
372
+ 'Content-Type' => 'application/x-www-form-urlencoded'
373
+ }
374
+ end
375
+
376
+ def access_token_url
377
+ test? ? TEST_ACCESS_TOKEN_URL : LIVE_ACCESS_TOKEN_URL
378
+ end
379
+
380
+ def setup_access_token
381
+ request = 'grant_type=client_credentials'
382
+ response = parse(ssl_post(access_token_url, request, access_token_header))
383
+ response['access_token']
384
+ end
385
+
386
+ def commit(action, post, options, authorization = nil, method = :post)
387
+ begin
388
+ request_endpoint = url(action, authorization)
389
+ request_body = post.nil? || post.empty? ? nil : post.to_json
390
+
391
+ raw_response = ssl_request(method, request_endpoint, request_body, headers(action, options))
392
+ response = parse(raw_response)
393
+ response['id'] = response['_links']['payment']['href'].split('/')[-1] if action == :capture && response.key?('_links')
394
+ source_id = authorization if action == :unstore
395
+ rescue ResponseError => e
396
+ raise unless e.response.code.to_s =~ /4\d\d/
397
+
398
+ response = parse(e.response.body, error: e.response)
399
+ end
400
+
401
+ succeeded = success_from(action, response)
402
+
403
+ additional_data = {
404
+ request_endpoint: request_endpoint,
405
+ request_method: method,
406
+ request_body: parse(request_body),
407
+ response_http_code: @response_http_code
408
+ }
409
+
410
+ response(action, succeeded, response, source_id, additional_data)
411
+ end
412
+
413
+ def response(action, succeeded, response, source_id = nil, options = {})
414
+ successful_response = succeeded && action == :purchase || action == :authorize
415
+ avs_result = successful_response ? avs_result(response) : nil
416
+ cvv_result = successful_response ? cvv_result(response) : nil
417
+ authorization = authorization_from(response) unless action == :unstore
418
+ body = action == :unstore ? { response_code: response.to_s } : response
419
+ response_code = action == :refund && succeeded ? '10000' : response.dig('response_code')
420
+
421
+ Response.new(
422
+ succeeded,
423
+ message_from(succeeded, response),
424
+ body,
425
+ authorization: authorization,
426
+ error_code: error_code_from(succeeded, body),
427
+ test: test?,
428
+ avs_result: avs_result,
429
+ cvv_result: cvv_result,
430
+ response_type: response_type(response_code),
431
+ response_http_code: options[:response_http_code],
432
+ request_endpoint: options[:request_endpoint],
433
+ request_method: options[:request_method],
434
+ request_body: options[:request_body]
435
+ )
436
+ end
437
+
438
+ def headers(action, options)
439
+ auth_token = @access_token ? "Bearer #{@access_token}" : "Bearer #{@options[:secret_key]}"
440
+ auth_token = @options[:public_key] if action == :tokens
441
+ headers = {
442
+ 'Authorization' => auth_token,
443
+ 'Content-Type' => 'application/json;charset=UTF-8'
444
+ }
445
+ headers['Cko-Idempotency-Key'] = options[:idempotency_key] if options[:idempotency_key]
446
+ headers
447
+ end
448
+
449
+ def tokenize(payment_method, options = {})
450
+ post = {}
451
+ add_authorization_type(post, options)
452
+ add_payment_method(post, payment_method, options)
453
+ add_customer_data(post, options)
454
+ commit(:tokens, post[:source], options)
455
+ end
456
+
457
+ def url(action, authorization)
458
+ case action
459
+ when :authorize, :purchase, :credit
460
+ "#{base_url}/payments"
461
+ when :unstore, :store
462
+ "#{base_url}/instruments/#{authorization}"
463
+ when :capture
464
+ "#{base_url}/payments/#{authorization}/captures"
465
+ when :refund
466
+ "#{base_url}/payments/#{authorization}/refunds"
467
+ when :void
468
+ "#{base_url}/payments/#{authorization}/voids"
469
+ when :incremental_authorize
470
+ "#{base_url}/payments/#{authorization}/authorizations"
471
+ when :tokens
472
+ "#{base_url}/tokens"
473
+ when :verify_payment
474
+ "#{base_url}/payments/#{authorization}"
475
+ else
476
+ "#{base_url}/payments/#{authorization}/#{action}"
477
+ end
478
+ end
479
+
480
+ def base_url
481
+ test? ? test_url : live_url
482
+ end
483
+
484
+ def avs_result(response)
485
+ response['source'] && response['source']['avs_check'] ? AVSResult.new(code: response['source']['avs_check']) : nil
486
+ end
487
+
488
+ def cvv_result(response)
489
+ response['source'] && response['source']['cvv_check'] ? CVVResult.new(response['source']['cvv_check']) : nil
490
+ end
491
+
492
+ def parse(body, error: nil)
493
+ JSON.parse(body)
494
+ rescue JSON::ParserError
495
+ response = {
496
+ 'error_type' => error&.code,
497
+ 'message' => 'Invalid JSON response received from Checkout.com Unified Payments Gateway. Please contact Checkout.com if you continue to receive this message.',
498
+ 'raw_response' => scrub(body)
499
+ }
500
+ response['error_codes'] = [error&.message] if error&.message
501
+ response
502
+ end
503
+
504
+ def success_from(action, response)
505
+ return response['status'] == 'Pending' if action == :credit
506
+ return true if action == :unstore && response == 204
507
+
508
+ store_response = response['token'] || response['id']
509
+ if store_response
510
+ return true if (action == :tokens && store_response.match(/tok/)) || (action == :store && store_response.match(/src_/))
511
+ end
512
+ response['response_summary'] == 'Approved' || response['approved'] == true || !response.key?('response_summary') && response.key?('action_id')
513
+ end
514
+
515
+ def message_from(succeeded, response)
516
+ if succeeded
517
+ 'Succeeded'
518
+ elsif response['error_type']
519
+ response['error_type'] + ': ' + response['error_codes'].first
520
+ else
521
+ response['response_summary'] || response['response_code'] || response['status'] || response['message'] || 'Unable to read error message'
522
+ end
523
+ end
524
+
525
+ STANDARD_ERROR_CODE_MAPPING = {
526
+ '20014' => STANDARD_ERROR_CODE[:invalid_number],
527
+ '20100' => STANDARD_ERROR_CODE[:invalid_expiry_date],
528
+ '20054' => STANDARD_ERROR_CODE[:expired_card],
529
+ '40104' => STANDARD_ERROR_CODE[:incorrect_cvc],
530
+ '40108' => STANDARD_ERROR_CODE[:incorrect_zip],
531
+ '40111' => STANDARD_ERROR_CODE[:incorrect_address],
532
+ '20005' => STANDARD_ERROR_CODE[:card_declined],
533
+ '20088' => STANDARD_ERROR_CODE[:processing_error],
534
+ '20001' => STANDARD_ERROR_CODE[:call_issuer],
535
+ '30004' => STANDARD_ERROR_CODE[:pickup_card]
536
+ }
537
+
538
+ def authorization_from(raw)
539
+ raw['id'] || raw['action_id']
540
+ end
541
+
542
+ def error_code_from(succeeded, response)
543
+ return if succeeded
544
+
545
+ if response['error_type'] && response['error_codes']
546
+ "#{response['error_type']}: #{response['error_codes'].join(', ')}"
547
+ elsif response['error_type']
548
+ response['error_type']
549
+ else
550
+ STANDARD_ERROR_CODE_MAPPING[response['response_code']]
551
+ end
552
+ end
553
+
554
+ def token_type_from(payment_method)
555
+ case payment_method.source
556
+ when :network_token
557
+ payment_method.brand == 'visa' ? 'vts' : 'mdes'
558
+ when :google_pay, :android_pay
559
+ 'googlepay'
560
+ when :apple_pay
561
+ 'applepay'
562
+ end
563
+ end
564
+
565
+ def handle_response(response)
566
+ @response_http_code = response.code.to_i
567
+ case @response_http_code
568
+ # to get the response code after unstore(delete instrument), because the body is nil
569
+ when 200...300
570
+ response.body || response.code
571
+ else
572
+ raise ResponseError.new(response)
573
+ end
574
+ end
575
+
576
+ def response_type(code)
577
+ if SUCCESS_CODES.include?(code)
578
+ 0
579
+ elsif SOFT_DECLINE_CODES.include?(code) || code.nil?
580
+ 1
581
+ else
582
+ 2
583
+ end
584
+ end
585
+ end
586
+ end
587
+ end
@@ -0,0 +1,21 @@
1
+ module ActiveMerchant
2
+ module Billing
3
+ class CitrusPayGateway < Gateway
4
+ include MastercardGateway
5
+
6
+ class_attribute :live_na_url, :live_ap_url, :test_na_url, :test_ap_url
7
+
8
+ self.test_na_url = 'https://test-gateway.mastercard.com/api/rest/version/39/'
9
+ self.test_ap_url = 'https://test-gateway.mastercard.com/api/rest/version/39/'
10
+
11
+ self.live_na_url = 'https://na-gateway.mastercard.com/api/rest/version/39/'
12
+ self.live_ap_url = 'https://ap-gateway.mastercard.com/api/rest/version/39/'
13
+
14
+ self.display_name = 'Citrus Pay'
15
+ self.homepage_url = 'http://www.citruspay.com/'
16
+ self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US)
17
+ self.default_currency = 'USD'
18
+ self.supported_cardtypes = %i[visa master american_express discover diners_club jcb maestro]
19
+ end
20
+ end
21
+ end