active_accountability_merchant 1.97.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +2948 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +246 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +15 -0
  8. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  9. data/lib/active_merchant/billing/avs_result.rb +96 -0
  10. data/lib/active_merchant/billing/base.rb +61 -0
  11. data/lib/active_merchant/billing/check.rb +80 -0
  12. data/lib/active_merchant/billing/compatibility.rb +117 -0
  13. data/lib/active_merchant/billing/credit_card.rb +406 -0
  14. data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
  15. data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
  16. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  17. data/lib/active_merchant/billing/gateway.rb +330 -0
  18. data/lib/active_merchant/billing/gateways.rb +14 -0
  19. data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
  20. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  23. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -0
  24. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  25. data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
  26. data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -0
  27. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  28. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  29. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +384 -0
  30. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  31. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +217 -0
  33. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
  34. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  35. data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
  36. data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
  37. data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
  38. data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
  39. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  40. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  41. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +22 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -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 +316 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -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 +327 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  59. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  60. data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
  61. data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
  62. data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
  63. data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
  64. data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
  65. data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
  68. data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  73. data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
  74. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  75. data/lib/active_merchant/billing/gateways/epay.rb +285 -0
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  77. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
  80. data/lib/active_merchant/billing/gateways/exact.rb +224 -0
  81. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -0
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  91. data/lib/active_merchant/billing/gateways/forte.rb +270 -0
  92. data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
  96. data/lib/active_merchant/billing/gateways/hps.rb +350 -0
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  99. data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
  100. data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
  101. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  102. data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
  103. data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
  104. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
  111. data/lib/active_merchant/billing/gateways/litle.rb +507 -0
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -0
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +286 -0
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
  121. data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
  124. data/lib/active_merchant/billing/gateways/migs.rb +332 -0
  125. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  126. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +217 -0
  128. data/lib/active_merchant/billing/gateways/monei.rb +338 -0
  129. data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
  130. data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
  131. data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
  132. data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
  133. data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
  134. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  135. data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
  136. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  137. data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
  138. data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
  139. data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
  140. data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
  141. data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
  142. data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
  143. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  144. data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
  145. data/lib/active_merchant/billing/gateways/opp.rb +388 -0
  146. data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
  147. data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
  149. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  150. data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
  151. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  152. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  153. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -0
  154. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  155. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  156. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +188 -0
  157. data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
  158. data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
  159. data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
  160. data/lib/active_merchant/billing/gateways/payex.rb +410 -0
  161. data/lib/active_merchant/billing/gateways/payflow.rb +383 -0
  162. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  163. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +43 -0
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  165. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  166. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  167. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  168. data/lib/active_merchant/billing/gateways/payment_express.rb +369 -0
  169. data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
  170. data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
  171. data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
  172. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -0
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  175. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  176. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  177. data/lib/active_merchant/billing/gateways/paypal_express.rb +269 -0
  178. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  179. data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
  180. data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
  181. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  182. data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
  183. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  184. data/lib/active_merchant/billing/gateways/pin.rb +234 -0
  185. data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
  186. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  187. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  188. data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
  189. data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
  190. data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
  191. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  192. data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
  193. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  194. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
  195. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  196. data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
  197. data/lib/active_merchant/billing/gateways/realex.rb +374 -0
  198. data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
  199. data/lib/active_merchant/billing/gateways/s5.rb +246 -0
  200. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  201. data/lib/active_merchant/billing/gateways/sage.rb +448 -0
  202. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  203. data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
  204. data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
  205. data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
  206. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
  207. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
  208. data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
  209. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  210. data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
  211. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  212. data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
  213. data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
  214. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
  215. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
  216. data/lib/active_merchant/billing/gateways/telr.rb +274 -0
  217. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  218. data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
  219. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  220. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  221. data/lib/active_merchant/billing/gateways/transax.rb +22 -0
  222. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  223. data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
  224. data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
  225. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  226. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
  227. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
  228. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  229. data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
  230. data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
  231. data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
  232. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  233. data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
  234. data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
  235. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  236. data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
  237. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
  238. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  239. data/lib/active_merchant/billing/model.rb +30 -0
  240. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  241. data/lib/active_merchant/billing/payment_token.rb +21 -0
  242. data/lib/active_merchant/billing/rails.rb +3 -0
  243. data/lib/active_merchant/billing/response.rb +92 -0
  244. data/lib/active_merchant/connection.rb +195 -0
  245. data/lib/active_merchant/country.rb +336 -0
  246. data/lib/active_merchant/empty.rb +20 -0
  247. data/lib/active_merchant/errors.rb +35 -0
  248. data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
  249. data/lib/active_merchant/network_connection_retries.rb +80 -0
  250. data/lib/active_merchant/post_data.rb +25 -0
  251. data/lib/active_merchant/posts_data.rb +92 -0
  252. data/lib/active_merchant/version.rb +3 -0
  253. data/lib/activemerchant.rb +1 -0
  254. data/lib/certs/cacert.pem +3988 -0
  255. data/lib/support/gateway_support.rb +69 -0
  256. data/lib/support/outbound_hosts.rb +28 -0
  257. data/lib/support/ssl_verify.rb +92 -0
  258. data/lib/support/ssl_version.rb +87 -0
  259. metadata +435 -0
@@ -0,0 +1,270 @@
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 = ['AD', 'AE', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA']
10
+ self.default_currency = 'USD'
11
+ self.money_format = :cents
12
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :maestro, :discover]
13
+
14
+ def initialize(options = {})
15
+ requires!(options, :secret_key)
16
+ super
17
+ end
18
+
19
+ def purchase(amount, payment_method, options = {})
20
+ multi = MultiResponse.run do |r|
21
+ r.process { authorize(amount, payment_method, options) }
22
+ r.process { capture(amount, r.authorization, options) }
23
+ end
24
+
25
+ merged_params = multi.responses.map(&:params).reduce({}, :merge)
26
+ succeeded = success_from(merged_params)
27
+
28
+ response(:purchase, succeeded, merged_params)
29
+ end
30
+
31
+ def authorize(amount, payment_method, options = {})
32
+ post = {}
33
+ post[:capture] = false
34
+ add_invoice(post, amount, options)
35
+ add_payment_method(post, payment_method, options)
36
+ add_customer_data(post, options)
37
+ add_transaction_data(post, options)
38
+ add_3ds(post, options)
39
+
40
+ commit(:authorize, post)
41
+ end
42
+
43
+ def capture(amount, authorization, options = {})
44
+ post = {}
45
+ add_invoice(post, amount, options)
46
+ add_customer_data(post, options)
47
+
48
+ commit(:capture, post, authorization)
49
+ end
50
+
51
+ def void(authorization, _options = {})
52
+ post = {}
53
+ commit(:void, post, authorization)
54
+ end
55
+
56
+ def refund(amount, authorization, options = {})
57
+ post = {}
58
+ add_invoice(post, amount, options)
59
+ add_customer_data(post, options)
60
+
61
+ commit(:refund, post, authorization)
62
+ end
63
+
64
+ def verify(credit_card, options = {})
65
+ MultiResponse.run(:use_first_response) do |r|
66
+ r.process { authorize(100, credit_card, options) }
67
+ r.process(:ignore_result) { void(r.authorization, options) }
68
+ end
69
+ end
70
+
71
+ def verify_payment(authorization, option={})
72
+ commit(:verify_payment, authorization)
73
+ end
74
+
75
+ def supports_scrubbing?
76
+ true
77
+ end
78
+
79
+ def scrub(transcript)
80
+ transcript.
81
+ gsub(/(Authorization: )[^\\]*/i, '\1[FILTERED]').
82
+ gsub(/("number\\":\\")\d+/, '\1[FILTERED]').
83
+ gsub(/("cvv\\":\\")\d+/, '\1[FILTERED]')
84
+ end
85
+
86
+ private
87
+
88
+ def add_invoice(post, money, options)
89
+ post[:amount] = localized_amount(money, options[:currency])
90
+ post[:reference] = options[:order_id]
91
+ post[:currency] = options[:currency] || currency(money)
92
+ if options[:descriptor_name] || options[:descriptor_city]
93
+ post[:billing_descriptor] = {}
94
+ post[:billing_descriptor][:name] = options[:descriptor_name] if options[:descriptor_name]
95
+ post[:billing_descriptor][:city] = options[:descriptor_city] if options[:descriptor_city]
96
+ end
97
+ post[:metadata] = {}
98
+ post[:metadata][:udf5] = application_id || 'ActiveMerchant'
99
+ end
100
+
101
+ def add_payment_method(post, payment_method, options)
102
+ post[:source] = {}
103
+ post[:source][:type] = 'card'
104
+ post[:source][:name] = payment_method.name
105
+ post[:source][:number] = payment_method.number
106
+ post[:source][:cvv] = payment_method.verification_value
107
+ post[:source][:expiry_year] = format(payment_method.year, :four_digits)
108
+ post[:source][:expiry_month] = format(payment_method.month, :two_digits)
109
+ post[:source][:stored] = 'true' if options[:card_on_file] == true
110
+ end
111
+
112
+ def add_customer_data(post, options)
113
+ post[:customer] = {}
114
+ post[:customer][:email] = options[:email] || nil
115
+ post[:payment_ip] = options[:ip] if options[:ip]
116
+ address = options[:billing_address]
117
+ if address && post[:source]
118
+ post[:source][:billing_address] = {}
119
+ post[:source][:billing_address][:address_line1] = address[:address1] unless address[:address1].blank?
120
+ post[:source][:billing_address][:address_line2] = address[:address2] unless address[:address2].blank?
121
+ post[:source][:billing_address][:city] = address[:city] unless address[:city].blank?
122
+ post[:source][:billing_address][:state] = address[:state] unless address[:state].blank?
123
+ post[:source][:billing_address][:country] = address[:country] unless address[:country].blank?
124
+ post[:source][:billing_address][:zip] = address[:zip] unless address[:zip].blank?
125
+ end
126
+ end
127
+
128
+ def add_transaction_data(post, options = {})
129
+ post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
130
+ post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
131
+ post[:payment_type] = 'MOTO' if options[:transaction_indicator] == 3
132
+ post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
133
+ end
134
+
135
+ def add_3ds(post, options)
136
+ if options[:three_d_secure] || options[:execute_threed]
137
+ post[:'3ds'] = {}
138
+ post[:'3ds'][:enabled] = true
139
+ post[:success_url] = options[:callback_url] if options[:callback_url]
140
+ post[:failure_url] = options[:callback_url] if options[:callback_url]
141
+ end
142
+
143
+ if options[:three_d_secure]
144
+ post[:'3ds'][:eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
145
+ post[:'3ds'][:cryptogram] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
146
+ post[:'3ds'][:version] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
147
+ post[:'3ds'][:xid] = options[:three_d_secure][:ds_transaction_id] || options[:three_d_secure][:xid]
148
+ end
149
+ end
150
+
151
+ def commit(action, post, authorization = nil)
152
+ begin
153
+ raw_response = (action == :verify_payment ? ssl_get("#{base_url}/payments/#{post}", headers) : ssl_post(url(post, action, authorization), post.to_json, headers))
154
+ response = parse(raw_response)
155
+ if action == :capture && response.key?('_links')
156
+ response['id'] = response['_links']['payment']['href'].split('/')[-1]
157
+ end
158
+ rescue ResponseError => e
159
+ raise unless e.response.code.to_s =~ /4\d\d/
160
+ response = parse(e.response.body)
161
+ end
162
+
163
+ succeeded = success_from(response)
164
+
165
+ response(action, succeeded, response)
166
+ end
167
+
168
+ def response(action, succeeded, response)
169
+ successful_response = succeeded && action == :purchase || action == :authorize
170
+ avs_result = successful_response ? avs_result(response) : nil
171
+ cvv_result = successful_response ? cvv_result(response) : nil
172
+
173
+ Response.new(
174
+ succeeded,
175
+ message_from(succeeded, response),
176
+ response,
177
+ authorization: authorization_from(response),
178
+ error_code: error_code_from(succeeded, response),
179
+ test: test?,
180
+ avs_result: avs_result,
181
+ cvv_result: cvv_result
182
+ )
183
+ end
184
+
185
+ def headers
186
+ {
187
+ 'Authorization' => @options[:secret_key],
188
+ 'Content-Type' => 'application/json;charset=UTF-8',
189
+ }
190
+ end
191
+
192
+ def url(_post, action, authorization)
193
+ if action == :authorize
194
+ "#{base_url}/payments"
195
+ elsif action == :capture
196
+ "#{base_url}/payments/#{authorization}/captures"
197
+ elsif action == :refund
198
+ "#{base_url}/payments/#{authorization}/refunds"
199
+ elsif action == :void
200
+ "#{base_url}/payments/#{authorization}/voids"
201
+ else
202
+ "#{base_url}/payments/#{authorization}/#{action}"
203
+ end
204
+ end
205
+
206
+ def base_url
207
+ test? ? test_url : live_url
208
+ end
209
+
210
+ def avs_result(response)
211
+ response['source'] && response['source']['avs_check'] ? AVSResult.new(code: response['source']['avs_check']) : nil
212
+ end
213
+
214
+ def cvv_result(response)
215
+ response['source'] && response['source']['cvv_check'] ? CVVResult.new(response['source']['cvv_check']) : nil
216
+ end
217
+
218
+ def parse(body)
219
+ JSON.parse(body)
220
+ rescue JSON::ParserError
221
+ {
222
+ 'message' => 'Invalid JSON response received from Checkout.com Unified Payments Gateway. Please contact Checkout.com if you continue to receive this message.',
223
+ 'raw_response' => scrub(body)
224
+ }
225
+ end
226
+
227
+ def success_from(response)
228
+ response['response_summary'] == 'Approved' || response['approved'] == true || !response.key?('response_summary') && response.key?('action_id')
229
+ end
230
+
231
+ def message_from(succeeded, response)
232
+ if succeeded
233
+ 'Succeeded'
234
+ elsif response['error_type']
235
+ response['error_type'] + ': ' + response['error_codes'].first
236
+ else
237
+ response['response_summary'] || response['response_code'] || 'Unable to read error message'
238
+ end
239
+ end
240
+
241
+ STANDARD_ERROR_CODE_MAPPING = {
242
+ '20014' => STANDARD_ERROR_CODE[:invalid_number],
243
+ '20100' => STANDARD_ERROR_CODE[:invalid_expiry_date],
244
+ '20054' => STANDARD_ERROR_CODE[:expired_card],
245
+ '40104' => STANDARD_ERROR_CODE[:incorrect_cvc],
246
+ '40108' => STANDARD_ERROR_CODE[:incorrect_zip],
247
+ '40111' => STANDARD_ERROR_CODE[:incorrect_address],
248
+ '20005' => STANDARD_ERROR_CODE[:card_declined],
249
+ '20088' => STANDARD_ERROR_CODE[:processing_error],
250
+ '20001' => STANDARD_ERROR_CODE[:call_issuer],
251
+ '30004' => STANDARD_ERROR_CODE[:pickup_card]
252
+ }
253
+
254
+ def authorization_from(raw)
255
+ raw['id']
256
+ end
257
+
258
+ def error_code_from(succeeded, response)
259
+ return if succeeded
260
+ if response['error_type'] && response['error_codes']
261
+ "#{response['error_type']}: #{response['error_codes'].join(', ')}"
262
+ elsif response['error_type']
263
+ response['error_type']
264
+ else
265
+ STANDARD_ERROR_CODE_MAPPING[response['response_code']]
266
+ end
267
+ end
268
+ end
269
+ end
270
+ end
@@ -0,0 +1,22 @@
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 = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro]
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,220 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class ClearhausGateway < Gateway
4
+ self.test_url = 'https://gateway.test.clearhaus.com'
5
+ self.live_url = 'https://gateway.clearhaus.com'
6
+
7
+ self.supported_countries = ['DK', 'NO', 'SE', 'FI', 'DE', 'CH', 'NL', 'AD', 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'FO', 'GL', 'EE', 'FR', 'GR',
8
+ 'HU', 'IS', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MT', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'GB']
9
+
10
+ self.default_currency = 'EUR'
11
+ self.currencies_without_fractions = %w(BIF BYR DJF GNF JPY KMF KRW PYG RWF VND VUV XAF XOF XPF)
12
+ self.supported_cardtypes = [:visa, :master]
13
+
14
+ self.homepage_url = 'https://www.clearhaus.com'
15
+ self.display_name = 'Clearhaus'
16
+ self.money_format = :cents
17
+
18
+ ACTION_CODE_MESSAGES = {
19
+ 20000 => 'Approved',
20
+ 40000 => 'General input error',
21
+ 40110 => 'Invalid card number',
22
+ 40120 => 'Invalid CSC',
23
+ 40130 => 'Invalid expire date',
24
+ 40135 => 'Card expired',
25
+ 40140 => 'Invalid currency',
26
+ 40200 => 'Clearhaus rule violation',
27
+ 40300 => '3-D Secure problem',
28
+ 40310 => '3-D Secure authentication failure',
29
+ 40400 => 'Backend problem',
30
+ 40410 => 'Declined by issuer or card scheme',
31
+ 40411 => 'Card restricted',
32
+ 40412 => 'Card lost or stolen',
33
+ 40413 => 'Insufficient funds',
34
+ 40414 => 'Suspected fraud',
35
+ 40415 => 'Amount limit exceeded',
36
+ 50000 => 'Clearhaus error'
37
+ }
38
+
39
+ def initialize(options={})
40
+ requires!(options, :api_key)
41
+ options[:private_key] = options[:private_key].strip if options[:private_key]
42
+ super
43
+ end
44
+
45
+ def purchase(amount, payment, options={})
46
+ MultiResponse.run(:use_first_response) do |r|
47
+ r.process { authorize(amount, payment, options) }
48
+ r.process { capture(amount, r.authorization, options) }
49
+ end
50
+ end
51
+
52
+ def authorize(amount, payment, options={})
53
+ post = {}
54
+ add_invoice(post, amount, options)
55
+
56
+ action = if payment.respond_to?(:number)
57
+ add_payment(post, payment)
58
+ '/authorizations'
59
+ elsif payment.kind_of?(String)
60
+ "/cards/#{payment}/authorizations"
61
+ else
62
+ raise ArgumentError.new("Unknown payment type #{payment.inspect}")
63
+ end
64
+
65
+ post[:recurring] = options[:recurring] if options[:recurring]
66
+ post[:card][:pares] = options[:pares] if options[:pares]
67
+
68
+ commit(action, post)
69
+ end
70
+
71
+ def capture(amount, authorization, options={})
72
+ post = {}
73
+ add_invoice(post, amount, options)
74
+
75
+ commit("/authorizations/#{authorization}/captures", post)
76
+ end
77
+
78
+ def refund(amount, authorization, options={})
79
+ post = {}
80
+ add_amount(post, amount, options)
81
+
82
+ commit("/authorizations/#{authorization}/refunds", post)
83
+ end
84
+
85
+ def void(authorization, options = {})
86
+ commit("/authorizations/#{authorization}/voids", options)
87
+ end
88
+
89
+ def verify(credit_card, options={})
90
+ MultiResponse.run(:use_first_response) do |r|
91
+ r.process { authorize(0, credit_card, options) }
92
+ r.process(:ignore_result) { void(r.authorization, options) }
93
+ end
94
+ end
95
+
96
+ def store(credit_card, options={})
97
+ post = {}
98
+ add_payment(post, credit_card)
99
+
100
+ commit('/cards', post)
101
+ end
102
+
103
+ def supports_scrubbing?
104
+ true
105
+ end
106
+
107
+ def scrub(transcript)
108
+ transcript.
109
+ gsub(%r((Authorization: Basic )[\w=]+), '\1[FILTERED]').
110
+ gsub(%r((&?card(?:\[|%5B)csc(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]').
111
+ gsub(%r((&?card(?:\[|%5B)pan(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]')
112
+ end
113
+
114
+ private
115
+
116
+ def add_invoice(post, money, options)
117
+ add_amount(post, money, options)
118
+ post[:reference] = options[:order_id] if options[:order_id]
119
+ post[:text_on_statement] = options[:text_on_statement] if options[:text_on_statement]
120
+ end
121
+
122
+ def add_amount(post, amount, options)
123
+ post[:amount] = localized_amount(amount, options[:currency] || default_currency)
124
+ post[:currency] = (options[:currency] || default_currency)
125
+ end
126
+
127
+ def add_payment(post, payment)
128
+ card = {}
129
+ card[:pan] = payment.number
130
+ card[:expire_month] = '%02d'% payment.month
131
+ card[:expire_year] = payment.year
132
+
133
+ if payment.verification_value?
134
+ card[:csc] = payment.verification_value
135
+ end
136
+
137
+ post[:card] = card if card.any?
138
+ end
139
+
140
+ def headers(api_key)
141
+ {
142
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{api_key}:"),
143
+ 'User-Agent' => "Clearhaus ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
144
+ }
145
+ end
146
+
147
+ def parse(body)
148
+ JSON.parse(body) rescue body
149
+ end
150
+
151
+ def commit(action, parameters)
152
+ url = (test? ? test_url : live_url) + action
153
+ headers = headers(@options[:api_key])
154
+ body = parameters.to_query
155
+
156
+ if @options[:signing_key] && @options[:private_key]
157
+ begin
158
+ headers['Signature'] = generate_signature(body)
159
+ rescue OpenSSL::PKey::RSAError => e
160
+ return Response.new(false, e.message)
161
+ end
162
+ end
163
+
164
+ response = begin
165
+ parse(ssl_post(url, body, headers))
166
+ rescue ResponseError => e
167
+ raise unless(e.response.code.to_s =~ /400/)
168
+ parse(e.response.body)
169
+ end
170
+
171
+ Response.new(
172
+ success_from(response),
173
+ message_from(response),
174
+ response,
175
+ authorization: authorization_from(action, response),
176
+ test: test?,
177
+ error_code: error_code_from(response)
178
+ )
179
+ end
180
+
181
+ def success_from(response)
182
+ (response && (response['status']['code'] == 20000))
183
+ end
184
+
185
+ def message_from(response)
186
+ default_message = ACTION_CODE_MESSAGES[response['status']['code']]
187
+
188
+ if success_from(response)
189
+ default_message
190
+ else
191
+ (response['status']['message'] || default_message)
192
+ end
193
+ end
194
+
195
+ def authorization_from(action, response)
196
+ id_of_auth_for_capture(action) || response['id']
197
+ end
198
+
199
+ def id_of_auth_for_capture(action)
200
+ match = action.match(/authorizations\/(.+)\/captures/)
201
+ return nil unless match
202
+
203
+ match.captures.first
204
+ end
205
+
206
+ def generate_signature(body)
207
+ key = OpenSSL::PKey::RSA.new(@options[:private_key])
208
+ hex = key.sign(OpenSSL::Digest.new('sha256'), body).unpack('H*').first
209
+
210
+ "#{@options[:signing_key]} RS256-hex #{hex}"
211
+ end
212
+
213
+ def error_code_from(response)
214
+ unless success_from(response)
215
+ response['status']['code']
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end