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,420 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class PaysafeGateway < Gateway
4
+ self.test_url = 'https://api.test.paysafe.com'
5
+ self.live_url = 'https://api.paysafe.com'
6
+
7
+ self.supported_countries = %w(AL AT BE BA BG CA HR CY CZ DK EE FI FR DE GR HU IS IE IT LV LI LT LU MT ME NL MK NO PL PT RO RS SK SI ES SE CH TR GB US)
8
+ self.supported_cardtypes = %i[visa master american_express discover]
9
+
10
+ self.homepage_url = 'https://www.paysafe.com/'
11
+ self.display_name = 'Paysafe'
12
+
13
+ def initialize(options = {})
14
+ requires!(options, :username, :password, :account_id)
15
+ super
16
+ end
17
+
18
+ def purchase(money, payment, options = {})
19
+ post = {}
20
+ add_auth_purchase_params(post, money, payment, options)
21
+ add_airline_travel_details(post, options)
22
+ add_split_pay_details(post, options)
23
+ post[:settleWithAuth] = true
24
+
25
+ commit(:post, 'auths', post, options)
26
+ end
27
+
28
+ def authorize(money, payment, options = {})
29
+ post = {}
30
+ add_auth_purchase_params(post, money, payment, options)
31
+
32
+ commit(:post, 'auths', post, options)
33
+ end
34
+
35
+ def capture(money, authorization, options = {})
36
+ post = {}
37
+ add_invoice(post, money, options)
38
+
39
+ commit(:post, "auths/#{authorization}/settlements", post, options)
40
+ end
41
+
42
+ def refund(money, authorization, options = {})
43
+ post = {}
44
+ add_invoice(post, money, options)
45
+
46
+ commit(:post, "settlements/#{authorization}/refunds", post, options)
47
+ end
48
+
49
+ def void(authorization, options = {})
50
+ post = {}
51
+ money = options[:amount]
52
+ add_invoice(post, money, options)
53
+
54
+ commit(:post, "auths/#{authorization}/voidauths", post, options)
55
+ end
56
+
57
+ def credit(money, payment, options = {})
58
+ post = {}
59
+ add_invoice(post, money, options)
60
+ add_payment(post, payment)
61
+
62
+ commit(:post, 'standalonecredits', post, options)
63
+ end
64
+
65
+ # This is a '$0 auth' done at a specific verification endpoint at the gateway
66
+ def verify(payment, options = {})
67
+ post = {}
68
+ add_payment(post, payment)
69
+ add_billing_address(post, options)
70
+ add_customer_data(post, payment, options) unless payment.is_a?(String)
71
+
72
+ commit(:post, 'verifications', post, options)
73
+ end
74
+
75
+ def store(payment, options = {})
76
+ post = {}
77
+ add_payment(post, payment)
78
+ add_address_for_vaulting(post, options)
79
+ add_profile_data(post, payment, options)
80
+ add_store_data(post, payment, options)
81
+
82
+ commit(:post, 'profiles', post, options)
83
+ end
84
+
85
+ def unstore(pm_profile_id)
86
+ commit(:delete, "profiles/#{get_id_from_store_auth(pm_profile_id)}", nil, nil)
87
+ end
88
+
89
+ def supports_scrubbing?
90
+ true
91
+ end
92
+
93
+ def scrub(transcript)
94
+ transcript.
95
+ gsub(%r((Authorization: Basic )[a-zA-Z0-9:_]+), '\1[FILTERED]').
96
+ gsub(%r(("cardNum\\?":\\?")\d+), '\1[FILTERED]').
97
+ gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]')
98
+ end
99
+
100
+ private
101
+
102
+ def add_auth_purchase_params(post, money, payment, options)
103
+ add_invoice(post, money, options)
104
+ add_payment(post, payment)
105
+ add_billing_address(post, options)
106
+ add_merchant_details(post, options)
107
+ add_customer_data(post, payment, options) unless payment.is_a?(String)
108
+ add_three_d_secure(post, payment, options) if options[:three_d_secure]
109
+ add_stored_credential(post, options) if options[:stored_credential]
110
+ add_funding_transaction(post, options)
111
+ end
112
+
113
+ # Customer data can be included in transactions where the payment method is a credit card
114
+ # but should not be sent when the payment method is a token
115
+ def add_customer_data(post, creditcard, options)
116
+ post[:profile] = {}
117
+ post[:profile][:firstName] = creditcard.first_name
118
+ post[:profile][:lastName] = creditcard.last_name
119
+ post[:profile][:email] = options[:email] if options[:email]
120
+ post[:customerIp] = options[:ip] if options[:ip]
121
+ end
122
+
123
+ def add_billing_address(post, options)
124
+ return unless address = options[:billing_address] || options[:address]
125
+
126
+ post[:billingDetails] = {}
127
+ post[:billingDetails][:street] = address[:address1]
128
+ post[:billingDetails][:city] = address[:city]
129
+ post[:billingDetails][:state] = address[:state]
130
+ post[:billingDetails][:country] = address[:country]
131
+ post[:billingDetails][:zip] = address[:zip]
132
+ post[:billingDetails][:phone] = address[:phone]
133
+ end
134
+
135
+ # The add_address_for_vaulting method is applicable to the store method, as the APIs address
136
+ # object is formatted differently from the standard transaction billing address
137
+ def add_address_for_vaulting(post, options)
138
+ return unless address = options[:billing_address] || options[:address]
139
+
140
+ post[:card][:billingAddress] = {}
141
+ post[:card][:billingAddress][:street] = address[:address1]
142
+ post[:card][:billingAddress][:street2] = address[:address2]
143
+ post[:card][:billingAddress][:city] = address[:city]
144
+ post[:card][:billingAddress][:zip] = address[:zip]
145
+ post[:card][:billingAddress][:country] = address[:country]
146
+ post[:card][:billingAddress][:state] = address[:state] if address[:state]
147
+ end
148
+
149
+ # This data is specific to creating a profile at the gateway's vault level
150
+ def add_profile_data(post, payment, options)
151
+ post[:firstName] = payment.first_name
152
+ post[:lastName] = payment.last_name
153
+ post[:dateOfBirth] = {}
154
+ post[:dateOfBirth][:year] = options[:date_of_birth][:year]
155
+ post[:dateOfBirth][:month] = options[:date_of_birth][:month]
156
+ post[:dateOfBirth][:day] = options[:date_of_birth][:day]
157
+ post[:email] = options[:email] if options[:email]
158
+ post[:ip] = options[:ip] if options[:ip]
159
+
160
+ if options[:phone]
161
+ post[:phone] = options[:phone]
162
+ elsif address = options[:billing_address] || options[:address]
163
+ post[:phone] = address[:phone] if address[:phone]
164
+ end
165
+ end
166
+
167
+ def add_store_data(post, payment, options)
168
+ post[:merchantCustomerId] = options[:customer_id] || SecureRandom.hex(12)
169
+ post[:locale] = options[:locale] || 'en_US'
170
+ post[:card][:holderName] = payment.name
171
+ end
172
+
173
+ # Paysafe expects minor units so we are not calling amount method on money parameter
174
+ def add_invoice(post, money, options)
175
+ post[:amount] = money
176
+ end
177
+
178
+ def add_payment(post, payment)
179
+ if payment.is_a?(String)
180
+ post[:card] = {}
181
+ post[:card][:paymentToken] = get_pm_from_store_auth(payment)
182
+ else
183
+ post[:card] = { cardExpiry: {} }
184
+ post[:card][:cardNum] = payment.number
185
+ post[:card][:cardExpiry][:month] = payment.month
186
+ post[:card][:cardExpiry][:year] = payment.year
187
+ post[:card][:cvv] = payment.verification_value
188
+ end
189
+ end
190
+
191
+ def add_merchant_details(post, options)
192
+ return unless options[:merchant_descriptor]
193
+
194
+ post[:merchantDescriptor] = {}
195
+ post[:merchantDescriptor][:dynamicDescriptor] = options[:merchant_descriptor][:dynamic_descriptor] if options[:merchant_descriptor][:dynamic_descriptor]
196
+ post[:merchantDescriptor][:phone] = options[:merchant_descriptor][:phone] if options[:merchant_descriptor][:phone]
197
+ end
198
+
199
+ def add_three_d_secure(post, payment, options)
200
+ three_d_secure = options[:three_d_secure]
201
+
202
+ post[:authentication] = {}
203
+ post[:authentication][:eci] = three_d_secure[:eci]
204
+ post[:authentication][:cavv] = three_d_secure[:cavv]
205
+ post[:authentication][:xid] = three_d_secure[:xid] if three_d_secure[:xid]
206
+ post[:authentication][:threeDSecureVersion] = three_d_secure[:version]
207
+ post[:authentication][:directoryServerTransactionId] = three_d_secure[:ds_transaction_id] unless payment.is_a?(String) || !mastercard?(payment)
208
+ end
209
+
210
+ def add_airline_travel_details(post, options)
211
+ return unless options[:airline_travel_details]
212
+
213
+ post[:airlineTravelDetails] = {}
214
+ post[:airlineTravelDetails][:passengerName] = options[:airline_travel_details][:passenger_name] if options[:airline_travel_details][:passenger_name]
215
+ post[:airlineTravelDetails][:departureDate] = options[:airline_travel_details][:departure_date] if options[:airline_travel_details][:departure_date]
216
+ post[:airlineTravelDetails][:origin] = options[:airline_travel_details][:origin] if options[:airline_travel_details][:origin]
217
+ post[:airlineTravelDetails][:computerizedReservationSystem] = options[:airline_travel_details][:computerized_reservation_system] if options[:airline_travel_details][:computerized_reservation_system]
218
+ post[:airlineTravelDetails][:customerReferenceNumber] = options[:airline_travel_details][:customer_reference_number] if options[:airline_travel_details][:customer_reference_number]
219
+
220
+ add_ticket_details(post, options)
221
+ add_travel_agency_details(post, options)
222
+ add_trip_legs(post, options)
223
+ end
224
+
225
+ def add_ticket_details(post, options)
226
+ return unless ticket = options[:airline_travel_details][:ticket]
227
+
228
+ post[:airlineTravelDetails][:ticket] = {}
229
+ post[:airlineTravelDetails][:ticket][:ticketNumber] = ticket[:ticket_number] if ticket[:ticket_number]
230
+ post[:airlineTravelDetails][:ticket][:isRestrictedTicket] = ticket[:is_restricted_ticket] if ticket[:is_restricted_ticket]
231
+ end
232
+
233
+ def add_travel_agency_details(post, options)
234
+ return unless agency = options[:airline_travel_details][:travel_agency]
235
+
236
+ post[:airlineTravelDetails][:travelAgency] = {}
237
+ post[:airlineTravelDetails][:travelAgency][:name] = agency[:name] if agency[:name]
238
+ post[:airlineTravelDetails][:travelAgency][:code] = agency[:code] if agency[:code]
239
+ end
240
+
241
+ def add_trip_legs(post, options)
242
+ return unless trip_legs = options[:airline_travel_details][:trip_legs]
243
+
244
+ trip_legs_hash = {}
245
+ trip_legs.each.with_index(1) do |leg, i|
246
+ my_leg = "leg#{i}".to_sym
247
+ details = add_leg_details(my_leg, leg[1])
248
+
249
+ trip_legs_hash[my_leg] = details
250
+ end
251
+ post[:airlineTravelDetails][:tripLegs] = trip_legs_hash
252
+ end
253
+
254
+ def add_leg_details(obj, leg)
255
+ details = {}
256
+ add_flight_details(details, obj, leg)
257
+ details[:serviceClass] = leg[:service_class] if leg[:service_class]
258
+ details[:isStopOverAllowed] = leg[:is_stop_over_allowed] if leg[:is_stop_over_allowed]
259
+ details[:destination] = leg[:destination] if leg[:destination]
260
+ details[:fareBasis] = leg[:fare_basis] if leg[:fare_basis]
261
+ details[:departureDate] = leg[:departure_date] if leg[:departure_date]
262
+
263
+ details
264
+ end
265
+
266
+ def add_flight_details(details, obj, leg)
267
+ details[:flight] = {}
268
+ details[:flight][:carrierCode] = leg[:flight][:carrier_code] if leg[:flight][:carrier_code]
269
+ details[:flight][:flightNumber] = leg[:flight][:flight_number] if leg[:flight][:flight_number]
270
+ end
271
+
272
+ def add_split_pay_details(post, options)
273
+ return unless options[:split_pay]
274
+
275
+ split_pay = []
276
+ options[:split_pay].each do |pmnt|
277
+ split = {}
278
+
279
+ split[:linkedAccount] = pmnt[:linked_account]
280
+ split[:amount] = pmnt[:amount].to_i if pmnt[:amount]
281
+ split[:percent] = pmnt[:percent].to_i if pmnt[:percent]
282
+
283
+ split_pay << split
284
+ end
285
+ post[:splitpay] = split_pay
286
+ end
287
+
288
+ def add_funding_transaction(post, options)
289
+ return unless options[:funding_transaction]
290
+
291
+ post[:fundingTransaction] = {}
292
+ post[:fundingTransaction][:type] = options[:funding_transaction]
293
+ post[:profile] ||= {}
294
+ post[:profile][:merchantCustomerId] = options[:customer_id] || SecureRandom.hex(12)
295
+ end
296
+
297
+ def add_stored_credential(post, options)
298
+ return unless options[:stored_credential]
299
+
300
+ post[:storedCredential] = {}
301
+
302
+ case options[:stored_credential][:initial_transaction]
303
+ when true
304
+ post[:storedCredential][:occurrence] = 'INITIAL'
305
+ when false
306
+ post[:storedCredential][:occurrence] = 'SUBSEQUENT'
307
+ end
308
+
309
+ case options[:stored_credential][:reason_type]
310
+ when 'recurring', 'installment'
311
+ post[:storedCredential][:type] = 'RECURRING'
312
+ when 'unscheduled'
313
+ if options[:stored_credential][:initiator] == 'merchant'
314
+ post[:storedCredential][:type] = 'TOPUP'
315
+ elsif options[:stored_credential][:initiator] == 'cardholder'
316
+ post[:storedCredential][:type] = 'ADHOC'
317
+ else
318
+ return
319
+ end
320
+ end
321
+
322
+ post[:storedCredential][:initialTransactionId] = options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
323
+ end
324
+
325
+ def mastercard?(payment)
326
+ return false unless payment.respond_to?(:brand)
327
+
328
+ payment.brand == 'master'
329
+ end
330
+
331
+ def parse(body)
332
+ return {} if body.empty?
333
+
334
+ JSON.parse(body)
335
+ end
336
+
337
+ def commit(method, action, parameters, options)
338
+ url = url(action)
339
+ raw_response = ssl_request(method, url, post_data(parameters, options), headers)
340
+ response = parse(raw_response)
341
+ success = success_from(response)
342
+
343
+ Response.new(
344
+ success,
345
+ message_from(success, response),
346
+ response,
347
+ authorization: authorization_from(action, response),
348
+ avs_result: AVSResult.new(code: response['avsResponse']),
349
+ cvv_result: CVVResult.new(response['cvvVerification']),
350
+ test: test?,
351
+ error_code: success ? nil : error_code_from(response)
352
+ )
353
+ end
354
+
355
+ def headers
356
+ {
357
+ 'Content-Type' => 'application/json',
358
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:username]}:#{@options[:password]}")
359
+ }
360
+ end
361
+
362
+ def url(action, options = {})
363
+ base_url = (test? ? test_url : live_url)
364
+
365
+ if action.include? 'profiles'
366
+ "#{base_url}/customervault/v1/#{action}"
367
+ else
368
+ "#{base_url}/cardpayments/v1/accounts/#{@options[:account_id]}/#{action}"
369
+ end
370
+ end
371
+
372
+ def success_from(response)
373
+ return false if response['status'] == 'FAILED' || response['error']
374
+
375
+ true
376
+ end
377
+
378
+ def message_from(success, response)
379
+ return response['status'] unless response['error']
380
+
381
+ "Error(s)- code:#{response['error']['code']}, message:#{response['error']['message']}"
382
+ end
383
+
384
+ def authorization_from(action, response)
385
+ if action == 'profiles'
386
+ pm = response['cards'].first['paymentToken']
387
+ "#{pm}|#{response['id']}"
388
+ else
389
+ response['id']
390
+ end
391
+ end
392
+
393
+ def get_pm_from_store_auth(authorization)
394
+ authorization.split('|')[0]
395
+ end
396
+
397
+ def get_id_from_store_auth(authorization)
398
+ authorization.split('|')[1]
399
+ end
400
+
401
+ def post_data(parameters = {}, options = {})
402
+ return unless parameters.present?
403
+
404
+ parameters[:merchantRefNum] = options[:merchant_ref_num] || SecureRandom.hex(16).to_s
405
+
406
+ parameters.to_json
407
+ end
408
+
409
+ def error_code_from(response)
410
+ return unless response['error']
411
+
412
+ response['error']['code']
413
+ end
414
+
415
+ def handle_response(response)
416
+ response.body
417
+ end
418
+ end
419
+ end
420
+ end
@@ -0,0 +1,159 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class PayscoutGateway < Gateway
4
+ self.live_url = self.test_url = 'https://secure.payscout.com/api/transact.php'
5
+
6
+ self.supported_countries = ['US']
7
+ self.supported_cardtypes = %i[visa master american_express discover]
8
+ self.default_currency = 'USD'
9
+ self.homepage_url = 'http://www.payscout.com/'
10
+ self.display_name = 'Payscout'
11
+
12
+ def initialize(options = {})
13
+ requires!(options, :username, :password)
14
+ super
15
+ end
16
+
17
+ def authorize(money, creditcard, options = {})
18
+ post = {}
19
+ add_invoice(post, options)
20
+ add_creditcard(post, creditcard)
21
+ add_currency(post, money, options)
22
+ add_address(post, options)
23
+
24
+ commit('auth', money, post)
25
+ end
26
+
27
+ def purchase(money, creditcard, options = {})
28
+ post = {}
29
+ add_invoice(post, options)
30
+ add_creditcard(post, creditcard)
31
+ add_currency(post, money, options)
32
+ add_address(post, options)
33
+
34
+ commit('sale', money, post)
35
+ end
36
+
37
+ def capture(money, authorization, options = {})
38
+ post = {}
39
+ post[:transactionid] = authorization
40
+
41
+ commit('capture', money, post)
42
+ end
43
+
44
+ def refund(money, authorization, options = {})
45
+ post = {}
46
+ post[:transactionid] = authorization
47
+
48
+ commit('refund', money, post)
49
+ end
50
+
51
+ def void(authorization, options = {})
52
+ post = {}
53
+ post[:transactionid] = authorization
54
+
55
+ commit('void', nil, post)
56
+ end
57
+
58
+ private
59
+
60
+ def add_address(post, options)
61
+ if address = options[:billing_address] || options[:address]
62
+ post[:address1] = address[:address1].to_s
63
+ post[:address2] = address[:address2].to_s
64
+ post[:city] = address[:city].to_s
65
+ post[:state] = (address[:state].blank? ? 'n/a' : address[:state])
66
+ post[:zip] = address[:zip].to_s
67
+ post[:country] = address[:country].to_s
68
+ post[:phone] = address[:phone].to_s
69
+ post[:fax] = address[:fax].to_s
70
+ post[:email] = address[:email].to_s
71
+ end
72
+
73
+ if address = options[:shipping_address]
74
+ post[:shipping_firstname] = address[:first_name].to_s
75
+ post[:shipping_lastname] = address[:last_name].to_s
76
+ post[:shipping_company] = address[:company].to_s
77
+ post[:shipping_address1] = address[:address1].to_s
78
+ post[:shipping_address2] = address[:address2].to_s
79
+ post[:shipping_city] = address[:city].to_s
80
+ post[:shipping_country] = address[:country].to_s
81
+ post[:shipping_state] = (address[:state].blank? ? 'n/a' : address[:state])
82
+ post[:shipping_zip] = address[:zip].to_s
83
+ post[:shipping_email] = address[:email].to_s
84
+ end
85
+ end
86
+
87
+ def add_currency(post, money, options)
88
+ post[:currency] = options[:currency] || currency(money)
89
+ end
90
+
91
+ def add_invoice(post, options)
92
+ post[:orderdescription] = options[:description]
93
+ post[:orderid] = options[:order_id]
94
+ end
95
+
96
+ def add_creditcard(post, creditcard)
97
+ post[:ccnumber] = creditcard.number
98
+ post[:cvv] = creditcard.verification_value if creditcard.verification_value?
99
+ post[:ccexp] = expdate(creditcard)
100
+ post[:firstname] = creditcard.first_name
101
+ post[:lastname] = creditcard.last_name
102
+ end
103
+
104
+ def parse(body)
105
+ Hash[body.split('&').map { |x| x.split('=') }]
106
+ end
107
+
108
+ def commit(action, money, parameters)
109
+ parameters[:amount] = amount(money) unless action == 'void'
110
+ url = (test? ? self.test_url : self.live_url)
111
+ data = ssl_post(url, post_data(action, parameters))
112
+
113
+ response = parse(data)
114
+ response[:action] = action
115
+
116
+ message = message_from(response)
117
+ test_mode = (test? || message =~ /TESTMODE/)
118
+ Response.new(success?(response), message, response,
119
+ test: test_mode,
120
+ authorization: response['transactionid'],
121
+ fraud_review: fraud_review?(response),
122
+ avs_result: { code: response['avsresponse'] },
123
+ cvv_result: response['cvvresponse'])
124
+ end
125
+
126
+ def message_from(response)
127
+ case response['response']
128
+ when '1'
129
+ 'The transaction has been approved'
130
+ when '2'
131
+ 'The transaction has been declined'
132
+ when '3'
133
+ response['responsetext']
134
+ else
135
+ 'There was an error processing the transaction'
136
+ end
137
+ end
138
+
139
+ def fraud_review?(response)
140
+ false
141
+ end
142
+
143
+ def success?(response)
144
+ (response['response'] == '1')
145
+ end
146
+
147
+ def post_data(action, parameters = {})
148
+ post = {}
149
+
150
+ post[:username] = @options[:username]
151
+ post[:password] = @options[:password]
152
+ post[:type] = action
153
+
154
+ request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
155
+ request
156
+ end
157
+ end
158
+ end
159
+ end