archetype2142_activemerchant 1.124.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (271) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +3640 -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 +80 -0
  10. data/lib/active_merchant/billing/compatibility.rb +118 -0
  11. data/lib/active_merchant/billing/credit_card.rb +414 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +444 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +37 -0
  15. data/lib/active_merchant/billing/gateway.rb +331 -0
  16. data/lib/active_merchant/billing/gateways/adyen.rb +712 -0
  17. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +1107 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
  21. data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
  22. data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
  23. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  24. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  25. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  26. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +396 -0
  27. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  28. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  29. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
  30. data/lib/active_merchant/billing/gateways/beanstream.rb +220 -0
  31. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  32. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
  33. data/lib/active_merchant/billing/gateways/blue_snap.rb +613 -0
  34. data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
  35. data/lib/active_merchant/billing/gateways/borgun.rb +231 -0
  36. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  37. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +23 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +832 -0
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  42. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
  44. data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +371 -0
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +225 -0
  49. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  52. data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +311 -0
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  57. data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  59. data/lib/active_merchant/billing/gateways/credorax.rb +496 -0
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  61. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  62. data/lib/active_merchant/billing/gateways/cyber_source.rb +1074 -0
  63. data/lib/active_merchant/billing/gateways/d_local.rb +253 -0
  64. data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
  65. data/lib/active_merchant/billing/gateways/decidir.rb +331 -0
  66. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  67. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  68. data/lib/active_merchant/billing/gateways/ebanx.rb +333 -0
  69. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  70. data/lib/active_merchant/billing/gateways/elavon.rb +472 -0
  71. data/lib/active_merchant/billing/gateways/element.rb +386 -0
  72. data/lib/active_merchant/billing/gateways/epay.rb +296 -0
  73. data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
  74. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  75. data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
  76. data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
  77. data/lib/active_merchant/billing/gateways/exact.rb +219 -0
  78. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  79. data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
  80. data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
  81. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  82. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  83. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  84. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  85. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  86. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  87. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  88. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  89. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  90. data/lib/active_merchant/billing/gateways/global_collect.rb +463 -0
  91. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  92. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  93. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  94. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  95. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  96. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  97. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  98. data/lib/active_merchant/billing/gateways/ipg.rb +390 -0
  99. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  100. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  101. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  102. data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
  103. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  104. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  105. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  106. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  107. data/lib/active_merchant/billing/gateways/kushki.rb +270 -0
  108. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  109. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  110. data/lib/active_merchant/billing/gateways/litle.rb +531 -0
  111. data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
  112. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  113. data/lib/active_merchant/billing/gateways/mercado_pago.rb +329 -0
  114. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
  115. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  116. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  117. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  119. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  120. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  121. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  122. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  123. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  124. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  125. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  126. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  128. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  129. data/lib/active_merchant/billing/gateways/monei.rb +422 -0
  130. data/lib/active_merchant/billing/gateways/moneris.rb +446 -0
  131. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  132. data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
  133. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  134. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  135. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  136. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  137. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  138. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  139. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  140. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  141. data/lib/active_merchant/billing/gateways/nmi.rb +356 -0
  142. data/lib/active_merchant/billing/gateways/ogone.rb +481 -0
  143. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  144. data/lib/active_merchant/billing/gateways/openpay.rb +229 -0
  145. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  146. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  147. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  148. data/lib/active_merchant/billing/gateways/orbital.rb +1209 -0
  149. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  150. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  151. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  152. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  153. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  154. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  155. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  156. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  157. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  158. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  159. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  160. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  161. data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
  162. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  163. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  166. data/lib/active_merchant/billing/gateways/payflow.rb +411 -0
  167. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  168. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  169. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  170. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  171. data/lib/active_merchant/billing/gateways/paymentez.rb +327 -0
  172. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  175. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  176. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  177. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  178. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  179. data/lib/active_merchant/billing/gateways/paypal_express.rb +270 -0
  180. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  181. data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
  182. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  183. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  184. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  185. data/lib/active_merchant/billing/gateways/payu_latam.rb +469 -0
  186. data/lib/active_merchant/billing/gateways/payu_polska.rb +178 -0
  187. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  188. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  189. data/lib/active_merchant/billing/gateways/pin.rb +246 -0
  190. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  191. data/lib/active_merchant/billing/gateways/priority.rb +390 -0
  192. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  193. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  194. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  195. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  196. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  197. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  200. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  201. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  202. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  203. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  204. data/lib/active_merchant/billing/gateways/redsys.rb +718 -0
  205. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  206. data/lib/active_merchant/billing/gateways/safe_charge.rb +301 -0
  207. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  208. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  209. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  210. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  211. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  212. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  213. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  214. data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
  215. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  216. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  217. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  218. data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
  219. data/lib/active_merchant/billing/gateways/stripe.rb +813 -0
  220. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +463 -0
  221. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  222. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  223. data/lib/active_merchant/billing/gateways/tns.rb +26 -0
  224. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  225. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  226. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  227. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  228. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  229. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  230. data/lib/active_merchant/billing/gateways/trust_commerce.rb +489 -0
  231. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  232. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  233. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +353 -0
  234. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  235. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  236. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  237. data/lib/active_merchant/billing/gateways/visanet_peru.rb +246 -0
  238. data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
  239. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  240. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  241. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  242. data/lib/active_merchant/billing/gateways/wompi.rb +153 -0
  243. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  244. data/lib/active_merchant/billing/gateways/worldpay.rb +923 -0
  245. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  246. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  247. data/lib/active_merchant/billing/gateways.rb +14 -0
  248. data/lib/active_merchant/billing/model.rb +30 -0
  249. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  250. data/lib/active_merchant/billing/payment_token.rb +21 -0
  251. data/lib/active_merchant/billing/rails.rb +3 -0
  252. data/lib/active_merchant/billing/response.rb +97 -0
  253. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  254. data/lib/active_merchant/billing.rb +16 -0
  255. data/lib/active_merchant/connection.rb +196 -0
  256. data/lib/active_merchant/country.rb +337 -0
  257. data/lib/active_merchant/empty.rb +20 -0
  258. data/lib/active_merchant/errors.rb +35 -0
  259. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  260. data/lib/active_merchant/network_connection_retries.rb +78 -0
  261. data/lib/active_merchant/post_data.rb +26 -0
  262. data/lib/active_merchant/posts_data.rb +92 -0
  263. data/lib/active_merchant/version.rb +3 -0
  264. data/lib/active_merchant.rb +63 -0
  265. data/lib/activemerchant.rb +1 -0
  266. data/lib/certs/cacert.pem +3214 -0
  267. data/lib/support/gateway_support.rb +69 -0
  268. data/lib/support/outbound_hosts.rb +28 -0
  269. data/lib/support/ssl_verify.rb +88 -0
  270. data/lib/support/ssl_version.rb +86 -0
  271. metadata +463 -0
@@ -0,0 +1,489 @@
1
+ begin
2
+ require 'tclink'
3
+ rescue LoadError
4
+ # Falls back to an SSL post to TrustCommerce
5
+ end
6
+
7
+ module ActiveMerchant #:nodoc:
8
+ module Billing #:nodoc:
9
+ # TO USE:
10
+ # First, make sure you have everything setup correctly and all of your dependencies in place with:
11
+ #
12
+ # require 'rubygems'
13
+ # require 'active_merchant'
14
+ #
15
+ # ActiveMerchant expects amounts to be Integer values in cents
16
+ #
17
+ # tendollar = 1000
18
+ #
19
+ # Next, create a credit card object using a TC approved test card.
20
+ #
21
+ # creditcard = ActiveMerchant::Billing::CreditCard.new(
22
+ # :number => '4111111111111111',
23
+ # :month => 8,
24
+ # :year => 2006,
25
+ # :first_name => 'Longbob',
26
+ # :last_name => 'Longsen'
27
+ # )
28
+ #
29
+ # To finish setting up, create the active_merchant object you will be using, with the TrustCommerce gateway. If you have a
30
+ # functional TrustCommerce account, replace login and password with your account info. Otherwise the defaults will work for
31
+ # testing.
32
+ #
33
+ # gateway = ActiveMerchant::Billing::Base.gateway(:trust_commerce).new(:login => "TestMerchant", :password => "password")
34
+ #
35
+ # Now we are ready to process our transaction
36
+ #
37
+ # response = gateway.purchase(tendollar, creditcard)
38
+ #
39
+ # Sending a transaction to TrustCommerce with active_merchant returns a Response object, which consistently allows you to:
40
+ #
41
+ # 1) Check whether the transaction was successful
42
+ #
43
+ # response.success?
44
+ #
45
+ # 2) Retrieve any message returned by TrustCommerce, either a "transaction was successful" note or an explanation of why the
46
+ # transaction was rejected.
47
+ #
48
+ # response.message
49
+ #
50
+ # 3) Retrieve and store the unique transaction ID returned by Trust Commerece, for use in referencing the transaction in the future.
51
+ #
52
+ # response.params["transid"]
53
+ #
54
+ # For higher performance and failover with the TrustCommerceGateway you can install the TCLink library from http://www.trustcommerce.com/tclink.html.
55
+ # Follow the instructions available there to get it working on your system. ActiveMerchant will automatically use tclink if available.
56
+ #
57
+ # The TCLink library has the following added benefits:
58
+ # * Good transaction times. Transaction duration under 1.2 seconds are common.
59
+ # * Fail-over to geographically distributed servers for extreme reliability
60
+ #
61
+ # Once it is installed, you should be able to make sure
62
+ # that it is visible to your ruby install by opening irb and typing "require 'tclink'", which should return "true".
63
+ #
64
+ # This should be enough to get you started with Trust Commerce and active_merchant. For further information, review the methods
65
+ # below and the rest of active_merchant's documentation, as well as Trust Commerce's user and developer documentation.
66
+
67
+ class TrustCommerceGateway < Gateway
68
+ self.live_url = self.test_url = 'https://vault.trustcommerce.com/trans/'
69
+
70
+ SUCCESS_TYPES = %w[approved accepted]
71
+
72
+ DECLINE_CODES = {
73
+ 'decline' => 'The credit card was declined',
74
+ 'avs' => 'AVS failed; the address entered does not match the billing address on file at the bank',
75
+ 'cvv' => 'CVV failed; the number provided is not the correct verification number for the card',
76
+ 'call' => 'The card must be authorized manually over the phone',
77
+ 'expiredcard' => 'Issuer was not certified for card verification',
78
+ 'carderror' => 'Card number is invalid',
79
+ 'authexpired' => 'Attempt to postauth an expired (more than 14 days old) preauth',
80
+ 'fraud' => 'CrediGuard fraud score was below requested threshold',
81
+ 'blacklist' => 'CrediGuard blacklist value was triggered',
82
+ 'velocity' => 'CrediGuard velocity control value was triggered',
83
+ 'dailylimit' => 'Daily limit in transaction count or amount as been reached',
84
+ 'weeklylimit' => 'Weekly limit in transaction count or amount as been reached',
85
+ 'monthlylimit' => 'Monthly limit in transaction count or amount as been reached'
86
+ }
87
+
88
+ BADDATA_CODES = {
89
+ 'missingfields' => 'One or more parameters required for this transaction type were not sent',
90
+ 'extrafields' => 'Parameters not allowed for this transaction type were sent',
91
+ 'badformat' => 'A field was improperly formatted, such as non-digit characters in a number field',
92
+ 'badlength' => 'A field was longer or shorter than the server allows',
93
+ 'merchantcantaccept' => "The merchant can't accept data passed in this field",
94
+ 'mismatch' => 'Data in one of the offending fields did not cross-check with the other offending field'
95
+ }
96
+
97
+ ERROR_CODES = {
98
+ 'cantconnect' => "Couldn't connect to the TrustCommerce gateway",
99
+ 'dnsfailure' => 'The TCLink software was unable to resolve DNS hostnames',
100
+ 'linkfailure' => 'The connection was established, but was severed before the transaction could complete',
101
+ 'failtoprocess' => 'The bank servers are offline and unable to authorize transactions'
102
+ }
103
+
104
+ TEST_LOGIN = 'TestMerchant'
105
+ TEST_PASSWORD = 'password'
106
+
107
+ VOIDABLE_ACTIONS = %w(preauth sale postauth credit)
108
+
109
+ self.money_format = :cents
110
+ self.supported_cardtypes = %i[visa master discover american_express diners_club jcb]
111
+ self.supported_countries = ['US']
112
+ self.homepage_url = 'http://www.trustcommerce.com/'
113
+ self.display_name = 'TrustCommerce'
114
+
115
+ def self.tclink?
116
+ defined?(TCLink)
117
+ end
118
+
119
+ # Creates a new TrustCommerceGateway
120
+ #
121
+ # The gateway requires that a valid login and password be passed
122
+ # in the +options+ hash.
123
+ #
124
+ # ==== Options
125
+ #
126
+ # * <tt>:login</tt> -- The TrustCommerce account login.
127
+ # * <tt>:password</tt> -- The TrustCommerce account password.
128
+ # * <tt>:test => +true+ or +false+</tt> -- Perform test transactions
129
+ #
130
+ # ==== Test Account Credentials
131
+ # * <tt>:login</tt> -- TestMerchant
132
+ # * <tt>:password</tt> -- password
133
+ def initialize(options = {})
134
+ requires!(options, :login, :password)
135
+
136
+ super
137
+ end
138
+
139
+ def tclink?
140
+ self.class.tclink?
141
+ end
142
+
143
+ def test?
144
+ ((@options[:login] == TEST_LOGIN && @options[:password] == TEST_PASSWORD) || super)
145
+ end
146
+
147
+ # authorize() is the first half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
148
+ # preauth, we preserve active_merchant's nomenclature of authorize() for consistency with the rest of the library. This
149
+ # method simply checks to make sure funds are available for a transaction, and returns a transid that can be used later to
150
+ # postauthorize (capture) the funds.
151
+
152
+ def authorize(money, creditcard_or_billing_id, options = {})
153
+ parameters = {
154
+ amount: amount(money)
155
+ }
156
+
157
+ add_order_id(parameters, options)
158
+ add_aggregator(parameters, options)
159
+ add_customer_data(parameters, options)
160
+ add_payment_source(parameters, creditcard_or_billing_id)
161
+ add_addresses(parameters, options)
162
+ add_custom_fields(parameters, options)
163
+
164
+ commit('preauth', parameters)
165
+ end
166
+
167
+ # purchase() is a simple sale. This is one of the most common types of transactions, and is extremely simple. All that you need
168
+ # to process a purchase are an amount in cents or a money object and a creditcard object or billingid string.
169
+ def purchase(money, creditcard_or_billing_id, options = {})
170
+ parameters = {
171
+ amount: amount(money)
172
+ }
173
+
174
+ add_order_id(parameters, options)
175
+ add_aggregator(parameters, options)
176
+ add_customer_data(parameters, options)
177
+ add_payment_source(parameters, creditcard_or_billing_id)
178
+ add_addresses(parameters, options)
179
+ add_custom_fields(parameters, options)
180
+
181
+ commit('sale', parameters)
182
+ end
183
+
184
+ # capture() is the second half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
185
+ # postauth, we preserve active_merchant's nomenclature of capture() for consistency with the rest of the library. To process
186
+ # a postauthorization with TC, you need an amount in cents or a money object, and a TC transid.
187
+ def capture(money, authorization, options = {})
188
+ transaction_id, = split_authorization(authorization)
189
+ parameters = {
190
+ amount: amount(money),
191
+ transid: transaction_id
192
+ }
193
+ add_aggregator(parameters, options)
194
+ add_custom_fields(parameters, options)
195
+
196
+ commit('postauth', parameters)
197
+ end
198
+
199
+ # refund() allows you to return money to a card that was previously billed. You need to supply the amount, in cents or a money object,
200
+ # that you want to refund, and a TC transid for the transaction that you are refunding.
201
+ def refund(money, identification, options = {})
202
+ transaction_id, = split_authorization(identification)
203
+
204
+ parameters = {
205
+ amount: amount(money),
206
+ transid: transaction_id
207
+ }
208
+
209
+ add_aggregator(parameters, options)
210
+ add_custom_fields(parameters, options)
211
+
212
+ commit('credit', parameters)
213
+ end
214
+
215
+ def credit(money, identification, options = {})
216
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
217
+ refund(money, identification, options)
218
+ end
219
+
220
+ # void() clears an existing authorization and releases the reserved fund
221
+ # s back to the cardholder. The TC API refers to this transaction as a
222
+ # reversal. After voiding, you will no longer be able to capture funds
223
+ # from this authorization. TrustCommerce seems to always return a status
224
+ # of "accepted" even if the transid you are trying to deauthorize has
225
+ # already been captured. Note: Your account needs to be configured by
226
+ # TrustCommerce to allow for reversal transactions before you can use this
227
+ # method.
228
+ #
229
+ # void() is also used to to cancel a capture (postauth), purchase (sale),
230
+ # or refund (credit) or a before it is sent for settlement.
231
+ #
232
+ # NOTE: AMEX preauth's cannot be reversed. If you want to clear it more
233
+ # quickly than the automatic expiration (7-10 days), you will have to
234
+ # capture it and then immediately issue a credit for the same amount
235
+ # which should clear the customers credit card with 48 hours according to
236
+ # TC.
237
+ def void(authorization, options = {})
238
+ transaction_id, original_action = split_authorization(authorization)
239
+ action = (VOIDABLE_ACTIONS - ['preauth']).include?(original_action) ? 'void' : 'reversal'
240
+
241
+ parameters = {
242
+ transid: transaction_id
243
+ }
244
+
245
+ add_aggregator(parameters, options)
246
+ add_custom_fields(parameters, options)
247
+
248
+ commit(action, parameters)
249
+ end
250
+
251
+ # recurring() a TrustCommerce account that is activated for Citadel, TrustCommerce's
252
+ # hosted customer billing info database.
253
+ #
254
+ # Recurring billing uses the same TC action as a plain-vanilla 'store', but we have a separate method for clarity. It can be called
255
+ # like store, with the addition of a required 'periodicity' parameter:
256
+ #
257
+ # The parameter :periodicity should be specified as either :bimonthly, :monthly, :biweekly, :weekly, :yearly or :daily
258
+ #
259
+ # gateway.recurring(tendollar, creditcard, :periodicity => :weekly)
260
+ #
261
+ # You can optionally specify how long you want payments to continue using 'payments'
262
+ def recurring(money, creditcard, options = {})
263
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
264
+
265
+ requires!(options, %i[periodicity bimonthly monthly biweekly weekly yearly daily])
266
+
267
+ cycle =
268
+ case options[:periodicity]
269
+ when :monthly
270
+ '1m'
271
+ when :bimonthly
272
+ '2m'
273
+ when :weekly
274
+ '1w'
275
+ when :biweekly
276
+ '2w'
277
+ when :yearly
278
+ '1y'
279
+ when :daily
280
+ '1d'
281
+ end
282
+
283
+ parameters = {
284
+ amount: amount(money),
285
+ cycle: cycle,
286
+ verify: options[:verify] || 'y',
287
+ billingid: options[:billingid] || nil,
288
+ payments: options[:payments] || nil
289
+ }
290
+
291
+ add_creditcard(parameters, creditcard)
292
+
293
+ commit('store', parameters)
294
+ end
295
+
296
+ # store() requires a TrustCommerce account that is activated for Citadel. You can call it with a credit card and a billing ID
297
+ # you would like to use to reference the stored credit card info for future captures. Use 'verify' to specify whether you want
298
+ # to simply store the card in the DB, or you want TC to verify the data first.
299
+
300
+ def store(creditcard, options = {})
301
+ parameters = {
302
+ verify: options[:verify] || 'y',
303
+ billingid: options[:billingid] || options[:billing_id] || nil
304
+ }
305
+
306
+ add_creditcard(parameters, creditcard)
307
+ add_addresses(parameters, options)
308
+ add_custom_fields(parameters, options)
309
+
310
+ commit('store', parameters)
311
+ end
312
+
313
+ # To unstore a creditcard stored in Citadel using store() or recurring(), all that is required is the billing id. When you run
314
+ # unstore() the information will be removed and a Response object will be returned indicating the success of the action.
315
+ def unstore(identification, options = {})
316
+ parameters = {
317
+ billingid: identification
318
+ }
319
+
320
+ add_custom_fields(parameters, options)
321
+
322
+ commit('unstore', parameters)
323
+ end
324
+
325
+ def supports_scrubbing
326
+ true
327
+ end
328
+
329
+ def scrub(transcript)
330
+ transcript.
331
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
332
+ gsub(%r((&?cc=)\d*(&?)), '\1[FILTERED]\2').
333
+ gsub(%r((&?password=)[^&]+(&?)), '\1[FILTERED]\2').
334
+ gsub(%r((&?cvv=)\d*(&?)), '\1[FILTERED]\2').
335
+ gsub(%r((&?account=)\d*(&?)), '\1[FILTERED]\2')
336
+ end
337
+
338
+ private
339
+
340
+ def add_custom_fields(params, options)
341
+ options[:custom_fields]&.each do |key, value|
342
+ params[key.to_sym] = value
343
+ end
344
+ end
345
+
346
+ def add_aggregator(params, options)
347
+ if @options[:aggregator_id] || application_id != Gateway.application_id
348
+ params[:aggregators] = 1
349
+ params[:aggregator1] = @options[:aggregator_id] || application_id
350
+ end
351
+ end
352
+
353
+ def add_payment_source(params, source)
354
+ if source.is_a?(String)
355
+ add_billing_id(params, source)
356
+ elsif card_brand(source) == 'check'
357
+ add_check(params, source)
358
+ else
359
+ add_creditcard(params, source)
360
+ end
361
+ end
362
+
363
+ def add_check(params, check)
364
+ params[:media] = 'ach'
365
+ params[:routing] = check.routing_number
366
+ params[:account] = check.account_number
367
+ params[:savings] = 'y' if check.account_type == 'savings'
368
+ params[:name] = check.name
369
+ end
370
+
371
+ def add_creditcard(params, creditcard)
372
+ params[:media] = 'cc'
373
+ params[:name] = creditcard.name
374
+ params[:cc] = creditcard.number
375
+ params[:exp] = expdate(creditcard)
376
+ params[:cvv] = creditcard.verification_value if creditcard.verification_value?
377
+ end
378
+
379
+ def add_order_id(params, options)
380
+ params[:ticket] = options[:order_id] unless options[:order_id].blank?
381
+ end
382
+
383
+ def add_billing_id(params, billingid)
384
+ params[:billingid] = billingid
385
+ end
386
+
387
+ def add_customer_data(params, options)
388
+ params[:email] = options[:email] unless options[:email].blank?
389
+ params[:ip] = options[:ip] unless options[:ip].blank?
390
+ end
391
+
392
+ def add_addresses(params, options)
393
+ address = options[:billing_address] || options[:address]
394
+
395
+ if address
396
+ params[:address1] = address[:address1] unless address[:address1].blank?
397
+ params[:address2] = address[:address2] unless address[:address2].blank?
398
+ params[:city] = address[:city] unless address[:city].blank?
399
+ params[:state] = address[:state] unless address[:state].blank?
400
+ params[:zip] = address[:zip] unless address[:zip].blank?
401
+ params[:country] = address[:country] unless address[:country].blank?
402
+ params[:avs] = 'n'
403
+ end
404
+
405
+ if shipping_address = options[:shipping_address]
406
+ params[:shipto_name] = shipping_address[:name] unless shipping_address[:name].blank?
407
+ params[:shipto_address1] = shipping_address[:address1] unless shipping_address[:address1].blank?
408
+ params[:shipto_address2] = shipping_address[:address2] unless shipping_address[:address2].blank?
409
+ params[:shipto_city] = shipping_address[:city] unless shipping_address[:city].blank?
410
+ params[:shipto_state] = shipping_address[:state] unless shipping_address[:state].blank?
411
+ params[:shipto_zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
412
+ params[:shipto_country] = shipping_address[:country] unless shipping_address[:country].blank?
413
+ end
414
+ end
415
+
416
+ def clean_and_stringify_params(parameters)
417
+ # TCLink wants us to send a hash with string keys, and activemerchant pushes everything around with
418
+ # symbol keys. Before sending our input to TCLink, we convert all our keys to strings and dump the symbol keys.
419
+ # We also remove any pairs with nil values, as these confuse TCLink.
420
+ parameters.keys.reverse_each do |key|
421
+ parameters[key.to_s] = parameters[key] if parameters[key]
422
+ parameters.delete(key)
423
+ end
424
+ end
425
+
426
+ def post_data(parameters)
427
+ parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
428
+ end
429
+
430
+ def commit(action, parameters)
431
+ parameters[:custid] = @options[:login]
432
+ parameters[:password] = @options[:password]
433
+ parameters[:demo] = test? ? 'y' : 'n'
434
+ parameters[:action] = action
435
+
436
+ clean_and_stringify_params(parameters)
437
+
438
+ data = if tclink?
439
+ TCLink.send(parameters)
440
+ else
441
+ parse(ssl_post(self.live_url, post_data(parameters)))
442
+ end
443
+
444
+ # to be considered successful, transaction status must be either "approved" or "accepted"
445
+ success = SUCCESS_TYPES.include?(data['status'])
446
+ message = message_from(data)
447
+ Response.new(success, message, data,
448
+ test: test?,
449
+ authorization: authorization_from(action, data),
450
+ cvv_result: data['cvv'],
451
+ avs_result: { code: data['avs'] })
452
+ end
453
+
454
+ def parse(body)
455
+ results = {}
456
+
457
+ body.split(/\n/).each do |pair|
458
+ key, val = pair.split(/=/)
459
+ results[key] = val
460
+ end
461
+
462
+ results
463
+ end
464
+
465
+ def message_from(data)
466
+ case data['status']
467
+ when 'decline'
468
+ return DECLINE_CODES[data['declinetype']]
469
+ when 'baddata'
470
+ return BADDATA_CODES[data['error']]
471
+ when 'error'
472
+ return ERROR_CODES[data['errortype']]
473
+ else
474
+ return 'The transaction was successful'
475
+ end
476
+ end
477
+
478
+ def authorization_from(action, data)
479
+ authorization = data['transid']
480
+ authorization = "#{authorization}|#{action}" if authorization && VOIDABLE_ACTIONS.include?(action)
481
+ authorization
482
+ end
483
+
484
+ def split_authorization(authorization)
485
+ authorization&.split('|')
486
+ end
487
+ end
488
+ end
489
+ end
@@ -0,0 +1,24 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ ##
4
+ # Delegates to the appropriate gateway, either the Transaction or Advanced
5
+ # depending on options passed to new.
6
+ #
7
+ class UsaEpayGateway < Gateway
8
+ self.abstract_class = true
9
+
10
+ ##
11
+ # Creates an instance of UsaEpayTransactionGateway by default, but if
12
+ # :software id or :live_url are passed in the options hash it will
13
+ # create an instance of UsaEpayAdvancedGateway.
14
+ #
15
+ def self.new(options = {})
16
+ if options.has_key?(:software_id) || options.has_key?(:live_url)
17
+ UsaEpayAdvancedGateway.new(options)
18
+ else
19
+ UsaEpayTransactionGateway.new(options)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end