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,222 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # For more information visit {Transact Pro Services}[https://www.transactpro.lv/business/]
4
+ #
5
+ # This gateway was formerly associated with www.1stpayments.net
6
+ #
7
+ # Written by Piers Chambers (Varyonic.com)
8
+ class TransactProGateway < Gateway
9
+ self.test_url = 'https://gw2sandbox.tpro.lv:8443/gw2test/gwprocessor2.php'
10
+ self.live_url = 'https://www2.1stpayments.net/gwprocessor2.php'
11
+
12
+ self.supported_countries = ['US']
13
+ self.default_currency = 'USD'
14
+ self.money_format = :cents
15
+ self.supported_cardtypes = %i[visa master american_express discover]
16
+
17
+ self.homepage_url = 'https://www.transactpro.lv/business/online-payments-acceptance'
18
+ self.display_name = 'Transact Pro'
19
+
20
+ def initialize(options = {})
21
+ requires!(options, :guid, :password, :terminal)
22
+ super
23
+ end
24
+
25
+ def purchase(amount, payment, options = {})
26
+ post = PostData.new
27
+ add_invoice(post, amount, options)
28
+ add_payment(post, payment)
29
+ add_address(post, payment, options)
30
+ add_customer_data(post, options)
31
+ add_credentials(post)
32
+ post[:rs] = @options[:terminal]
33
+
34
+ MultiResponse.run do |r|
35
+ r.process { commit('init', post) }
36
+ r.process do
37
+ post = PostData.new
38
+ post[:init_transaction_id] = r.authorization
39
+ add_payment_cc(post, payment)
40
+ post[:f_extended] = '4'
41
+
42
+ commit('charge', post, amount)
43
+ end
44
+ end
45
+ end
46
+
47
+ def authorize(amount, payment, options = {})
48
+ post = PostData.new
49
+ add_invoice(post, amount, options)
50
+ add_payment(post, payment)
51
+ add_address(post, payment, options)
52
+ add_customer_data(post, options)
53
+ add_credentials(post)
54
+ post[:rs] = @options[:terminal]
55
+
56
+ MultiResponse.run do |r|
57
+ r.process { commit('init_dms', post) }
58
+ r.process do
59
+ post = PostData.new
60
+ post[:init_transaction_id] = r.authorization
61
+ add_payment_cc(post, payment)
62
+ post[:f_extended] = '4'
63
+
64
+ commit('make_hold', post, amount)
65
+ end
66
+ end
67
+ end
68
+
69
+ def capture(amount, authorization, options = {})
70
+ identifier, original_amount = split_authorization(authorization)
71
+ raise ArgumentError.new("Partial capture is not supported, and #{amount.inspect} != #{original_amount.inspect}") if amount && (amount != original_amount)
72
+
73
+ post = PostData.new
74
+ add_credentials(post)
75
+ post[:init_transaction_id] = identifier
76
+ post[:f_extended] = '4'
77
+
78
+ commit('charge_hold', post, original_amount)
79
+ end
80
+
81
+ def refund(amount, authorization, options = {})
82
+ identifier, original_amount = split_authorization(authorization)
83
+
84
+ post = PostData.new
85
+ add_credentials(post, :account_guid)
86
+ post[:init_transaction_id] = identifier
87
+ post[:amount_to_refund] = amount(amount || original_amount)
88
+
89
+ commit('refund', post)
90
+ end
91
+
92
+ def void(authorization, options = {})
93
+ identifier, amount = split_authorization(authorization)
94
+
95
+ post = PostData.new
96
+ add_credentials(post, :account_guid)
97
+ post[:init_transaction_id] = identifier
98
+ post[:amount_to_refund] = amount(amount)
99
+ commit('cancel_dms', post)
100
+ end
101
+
102
+ def verify(credit_card, options = {})
103
+ MultiResponse.run(:use_first_response) do |r|
104
+ r.process { authorize(100, credit_card, options) }
105
+ r.process(:ignore_result) { void(r.authorization, options) }
106
+ end
107
+ end
108
+
109
+ private
110
+
111
+ def add_customer_data(post, options)
112
+ post[:email] = (options[:email] || 'noone@example.com')
113
+ post[:user_ip] = (options[:ip] || '127.0.0.1')
114
+ end
115
+
116
+ def add_address(post, creditcard, options)
117
+ if address = options[:billing_address]
118
+ post[:street] = address[:address1].to_s
119
+ post[:city] = address[:city].to_s
120
+ post[:state] = (address[:state].blank? ? 'NA' : address[:state].to_s)
121
+ post[:zip] = address[:zip].to_s
122
+ post[:country] = address[:country].to_s
123
+ post[:phone] = (address[:phone].to_s.gsub(/[^0-9]/, '') || '0000000')
124
+ end
125
+
126
+ if address = options[:shipping_address]
127
+ post[:shipping_name] = "#{address.first_name} #{address.last_name}"
128
+ post[:shipping_street] = address[:address1].to_s
129
+ post[:shipping_phone] = address[:phone].to_s
130
+ post[:shipping_zip] = address[:zip].to_s
131
+ post[:shipping_city] = address[:city].to_s
132
+ post[:shipping_country] = address[:country].to_s
133
+ post[:shipping_state] = (address[:state].blank? ? 'NA' : address[:state].to_s)
134
+ post[:shipping_email] = (options[:email] || 'noone@example.com')
135
+ end
136
+ end
137
+
138
+ def add_invoice(post, money, options)
139
+ post[:merchant_transaction_id] = options[:order_id] if options[:order_id]
140
+ post[:amount] = amount(money)
141
+ post[:currency] = (options[:currency] || currency(money))
142
+ post[:description] = options[:description]
143
+ post[:merchant_site_url] = options[:merchant]
144
+ end
145
+
146
+ def add_payment(post, payment)
147
+ post[:name_on_card] = "#{payment.first_name} #{payment.last_name}"
148
+ post[:card_bin] = payment.first_digits
149
+ end
150
+
151
+ def add_payment_cc(post, credit_card)
152
+ post[:cc] = credit_card.number
153
+ post[:cvv] = credit_card.verification_value if credit_card.verification_value?
154
+ year = sprintf('%.4i', credit_card.year)
155
+ month = sprintf('%.2i', credit_card.month)
156
+ post[:expire] = "#{month}/#{year[2..3]}"
157
+ end
158
+
159
+ def add_credentials(post, key = :guid)
160
+ post[key] = @options[:guid]
161
+ post[:pwd] = Digest::SHA1.hexdigest(@options[:password])
162
+ end
163
+
164
+ def parse(body)
165
+ if /^ID:/.match?(body)
166
+ body.split('~').reduce(Hash.new) { |h, v|
167
+ m = v.match('(.*?):(.*)')
168
+ h.merge!(m[1].underscore.to_sym => m[2])
169
+ }
170
+ elsif (m = body.match('(.*?):(.*)'))
171
+ m[1] == 'OK' ?
172
+ { status: 'success', id: m[2] } :
173
+ { status: 'failure', message: m[2] }
174
+ else
175
+ Hash[status: body]
176
+ end
177
+ end
178
+
179
+ def commit(action, parameters, amount = nil)
180
+ url = (test? ? test_url : live_url)
181
+ response = parse(ssl_post(url, post_data(action, parameters)))
182
+
183
+ Response.new(
184
+ success_from(response),
185
+ message_from(response),
186
+ response,
187
+ authorization: authorization_from(parameters, response, amount),
188
+ test: test?
189
+ )
190
+ end
191
+
192
+ def authorization_from(parameters, response, amount)
193
+ identifier = (response[:id] || parameters[:init_transaction_id])
194
+ authorization = [identifier]
195
+ authorization << amount if amount
196
+ authorization.join('|')
197
+ end
198
+
199
+ def split_authorization(authorization)
200
+ if /|/.match?(authorization)
201
+ identifier, amount = authorization.split('|')
202
+ [identifier, amount.to_i]
203
+ else
204
+ authorization
205
+ end
206
+ end
207
+
208
+ def success_from(response)
209
+ (response[:status] =~ /success/i || response[:status] =~ /ok/i)
210
+ end
211
+
212
+ def message_from(response)
213
+ (response[:message] || response[:status])
214
+ end
215
+
216
+ def post_data(action, parameters = {})
217
+ parameters[:a] = action
218
+ parameters.to_s
219
+ end
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,21 @@
1
+ require File.join(File.dirname(__FILE__), 'smart_ps.rb')
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class TransaxGateway < SmartPs
6
+ self.live_url = self.test_url = 'https://secure.nelixtransax.net/api/transact.php'
7
+
8
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
9
+ self.supported_countries = ['US']
10
+
11
+ # The card types supported by the payment gateway
12
+ self.supported_cardtypes = %i[visa master american_express discover]
13
+
14
+ # The homepage URL of the gateway
15
+ self.homepage_url = 'https://www.nelixtransax.com/'
16
+
17
+ # The name of the gateway
18
+ self.display_name = 'NELiX TransaX'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class TransnationalGateway < NetworkMerchantsGateway
4
+ self.homepage_url = 'http://www.tnbci.com/'
5
+ self.display_name = 'Transnational'
6
+ self.supported_countries = ['US']
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,221 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class TrexleGateway < Gateway
4
+ self.test_url = 'https://core.trexle.com/api/v1'
5
+ self.live_url = 'https://core.trexle.com/api/v1'
6
+
7
+ self.default_currency = 'USD'
8
+ self.money_format = :cents
9
+ self.supported_countries = %w(AD AE AT AU BD BE BG BN CA CH CY CZ DE DK EE EG ES FI FR GB
10
+ GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU LV MC
11
+ MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM
12
+ TR TT UM US VA VN ZA)
13
+ self.supported_cardtypes = %i[visa master american_express]
14
+ self.homepage_url = 'https://trexle.com'
15
+ self.display_name = 'Trexle'
16
+
17
+ def initialize(options = {})
18
+ requires!(options, :api_key)
19
+ super
20
+ end
21
+
22
+ # Create a charge using a credit card, card token or customer token
23
+ #
24
+ # To charge a credit card: purchase([money], [creditcard hash], ...)
25
+ # To charge a customer: purchase([money], [token], ...)
26
+ def purchase(money, creditcard, options = {})
27
+ post = {}
28
+
29
+ add_amount(post, money, options)
30
+ add_customer_data(post, options)
31
+ add_invoice(post, options)
32
+ add_creditcard(post, creditcard)
33
+ add_address(post, creditcard, options)
34
+ commit(:post, 'charges', post, options)
35
+ end
36
+
37
+ # Create a customer and associated credit card. The token that is returned
38
+ # can be used instead of a credit card parameter in the purchase method
39
+ def store(creditcard, options = {})
40
+ post = {}
41
+
42
+ add_creditcard(post, creditcard)
43
+ add_customer_data(post, options)
44
+ add_address(post, creditcard, options)
45
+ commit(:post, 'customers', post, options)
46
+ end
47
+
48
+ # Refund a transaction
49
+ def refund(money, token, options = {})
50
+ commit(:post, "charges/#{CGI.escape(token)}/refunds", { amount: amount(money) }, options)
51
+ end
52
+
53
+ # Authorize an amount on a credit card. Once authorized, you can later
54
+ # capture this charge using the charge token that is returned.
55
+ def authorize(money, creditcard, options = {})
56
+ post = {}
57
+
58
+ add_amount(post, money, options)
59
+ add_customer_data(post, options)
60
+ add_invoice(post, options)
61
+ add_creditcard(post, creditcard)
62
+ add_address(post, creditcard, options)
63
+ post[:capture] = false
64
+ commit(:post, 'charges', post, options)
65
+ end
66
+
67
+ # Captures a previously authorized charge. Capturing only part of the original
68
+ # authorization is currently not supported.
69
+ def capture(money, token, options = {})
70
+ commit(:put, "charges/#{CGI.escape(token)}/capture", { amount: amount(money) }, options)
71
+ end
72
+
73
+ # Updates the credit card for the customer.
74
+ def update(token, creditcard, options = {})
75
+ post = {}
76
+
77
+ add_creditcard(post, creditcard)
78
+ add_customer_data(post, options)
79
+ add_address(post, creditcard, options)
80
+ commit(:put, "customers/#{CGI.escape(token)}", post, options)
81
+ end
82
+
83
+ def supports_scrubbing
84
+ true
85
+ end
86
+
87
+ def scrub(transcript)
88
+ transcript.
89
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
90
+ gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]').
91
+ gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]')
92
+ end
93
+
94
+ private
95
+
96
+ def add_amount(post, money, options)
97
+ post[:amount] = amount(money)
98
+ post[:currency] = (options[:currency] || currency(money))
99
+ post[:currency] = post[:currency].upcase if post[:currency]
100
+ end
101
+
102
+ def add_customer_data(post, options)
103
+ post[:email] = options[:email] if options[:email]
104
+ post[:ip_address] = options[:ip] if options[:ip]
105
+ end
106
+
107
+ def add_address(post, creditcard, options)
108
+ return if creditcard.kind_of?(String)
109
+
110
+ address = (options[:billing_address] || options[:address])
111
+ return unless address
112
+
113
+ post[:card] ||= {}
114
+ post[:card].merge!(
115
+ address_line1: address[:address1],
116
+ address_line2: address[:address_line2],
117
+ address_city: address[:city],
118
+ address_postcode: address[:zip],
119
+ address_state: address[:state],
120
+ address_country: address[:country]
121
+ )
122
+ end
123
+
124
+ def add_invoice(post, options)
125
+ post[:description] = options[:description] || 'Active Merchant Purchase'
126
+ end
127
+
128
+ def add_creditcard(post, creditcard)
129
+ if creditcard.respond_to?(:number)
130
+ post[:card] ||= {}
131
+
132
+ post[:card].merge!(
133
+ number: creditcard.number,
134
+ expiry_month: creditcard.month,
135
+ expiry_year: creditcard.year,
136
+ cvc: creditcard.verification_value,
137
+ name: creditcard.name
138
+ )
139
+ elsif creditcard.kind_of?(String)
140
+ if /^token_/.match?(creditcard)
141
+ post[:card_token] = creditcard
142
+ else
143
+ post[:customer_token] = creditcard
144
+ end
145
+ end
146
+ end
147
+
148
+ def headers(params = {})
149
+ result = {
150
+ 'Content-Type' => 'application/json',
151
+ 'Authorization' => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}"
152
+ }
153
+
154
+ result['X-Partner-Key'] = params[:partner_key] if params[:partner_key]
155
+ result['X-Safe-Card'] = params[:safe_card] if params[:safe_card]
156
+ result
157
+ end
158
+
159
+ def commit(method, action, params, options)
160
+ url = "#{test? ? test_url : live_url}/#{action}"
161
+ raw_response = ssl_request(method, url, post_data(params), headers(options))
162
+ parsed_response = parse(raw_response)
163
+ success_response(parsed_response)
164
+ rescue ResponseError => e
165
+ error_response(parse(e.response.body))
166
+ rescue JSON::ParserError
167
+ unparsable_response(raw_response)
168
+ end
169
+
170
+ def success_response(body)
171
+ return invalid_response unless body['response']
172
+
173
+ response = body['response']
174
+ Response.new(
175
+ true,
176
+ response['status_message'],
177
+ body,
178
+ authorization: token(response),
179
+ test: test?
180
+ )
181
+ end
182
+
183
+ def error_response(body)
184
+ return invalid_response unless body['error']
185
+
186
+ Response.new(
187
+ false,
188
+ body['error'],
189
+ body,
190
+ authorization: nil,
191
+ test: test?
192
+ )
193
+ end
194
+
195
+ def unparsable_response(raw_response)
196
+ message = 'Invalid JSON response received from Trexle. Please contact support@trexle.com if you continue to receive this message.'
197
+ message += " (The raw response returned by the API was #{raw_response.inspect})"
198
+ return Response.new(false, message)
199
+ end
200
+
201
+ def invalid_response
202
+ message = 'Invalid response.'
203
+ return Response.new(false, message)
204
+ end
205
+
206
+ def token(response)
207
+ response['token']
208
+ end
209
+
210
+ def parse(body)
211
+ return {} if body.blank?
212
+
213
+ JSON.parse(body)
214
+ end
215
+
216
+ def post_data(parameters = {})
217
+ parameters.to_json
218
+ end
219
+ end
220
+ end
221
+ end