active_accountability_merchant 1.97.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +2948 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +246 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +15 -0
  8. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  9. data/lib/active_merchant/billing/avs_result.rb +96 -0
  10. data/lib/active_merchant/billing/base.rb +61 -0
  11. data/lib/active_merchant/billing/check.rb +80 -0
  12. data/lib/active_merchant/billing/compatibility.rb +117 -0
  13. data/lib/active_merchant/billing/credit_card.rb +406 -0
  14. data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
  15. data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
  16. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  17. data/lib/active_merchant/billing/gateway.rb +330 -0
  18. data/lib/active_merchant/billing/gateways.rb +14 -0
  19. data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
  20. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  23. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -0
  24. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  25. data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
  26. data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -0
  27. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  28. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  29. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +384 -0
  30. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  31. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +217 -0
  33. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
  34. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  35. data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
  36. data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
  37. data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
  38. data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
  39. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  40. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  41. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +22 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -0
  43. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  44. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  45. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  46. data/lib/active_merchant/billing/gateways/card_connect.rb +316 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
  52. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  53. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  54. data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  59. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  60. data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
  61. data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
  62. data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
  63. data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
  64. data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
  65. data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
  68. data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  73. data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
  74. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  75. data/lib/active_merchant/billing/gateways/epay.rb +285 -0
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  77. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
  80. data/lib/active_merchant/billing/gateways/exact.rb +224 -0
  81. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -0
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  91. data/lib/active_merchant/billing/gateways/forte.rb +270 -0
  92. data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
  96. data/lib/active_merchant/billing/gateways/hps.rb +350 -0
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  99. data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
  100. data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
  101. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  102. data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
  103. data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
  104. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
  111. data/lib/active_merchant/billing/gateways/litle.rb +507 -0
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -0
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +286 -0
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
  121. data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
  124. data/lib/active_merchant/billing/gateways/migs.rb +332 -0
  125. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  126. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +217 -0
  128. data/lib/active_merchant/billing/gateways/monei.rb +338 -0
  129. data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
  130. data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
  131. data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
  132. data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
  133. data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
  134. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  135. data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
  136. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  137. data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
  138. data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
  139. data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
  140. data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
  141. data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
  142. data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
  143. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  144. data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
  145. data/lib/active_merchant/billing/gateways/opp.rb +388 -0
  146. data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
  147. data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
  149. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  150. data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
  151. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  152. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  153. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -0
  154. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  155. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  156. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +188 -0
  157. data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
  158. data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
  159. data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
  160. data/lib/active_merchant/billing/gateways/payex.rb +410 -0
  161. data/lib/active_merchant/billing/gateways/payflow.rb +383 -0
  162. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  163. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +43 -0
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  165. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  166. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  167. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  168. data/lib/active_merchant/billing/gateways/payment_express.rb +369 -0
  169. data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
  170. data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
  171. data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
  172. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -0
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  175. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  176. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  177. data/lib/active_merchant/billing/gateways/paypal_express.rb +269 -0
  178. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  179. data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
  180. data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
  181. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  182. data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
  183. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  184. data/lib/active_merchant/billing/gateways/pin.rb +234 -0
  185. data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
  186. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  187. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  188. data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
  189. data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
  190. data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
  191. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  192. data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
  193. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  194. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
  195. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  196. data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
  197. data/lib/active_merchant/billing/gateways/realex.rb +374 -0
  198. data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
  199. data/lib/active_merchant/billing/gateways/s5.rb +246 -0
  200. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  201. data/lib/active_merchant/billing/gateways/sage.rb +448 -0
  202. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  203. data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
  204. data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
  205. data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
  206. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
  207. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
  208. data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
  209. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  210. data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
  211. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  212. data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
  213. data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
  214. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
  215. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
  216. data/lib/active_merchant/billing/gateways/telr.rb +274 -0
  217. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  218. data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
  219. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  220. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  221. data/lib/active_merchant/billing/gateways/transax.rb +22 -0
  222. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  223. data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
  224. data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
  225. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  226. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
  227. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
  228. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  229. data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
  230. data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
  231. data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
  232. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  233. data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
  234. data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
  235. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  236. data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
  237. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
  238. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  239. data/lib/active_merchant/billing/model.rb +30 -0
  240. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  241. data/lib/active_merchant/billing/payment_token.rb +21 -0
  242. data/lib/active_merchant/billing/rails.rb +3 -0
  243. data/lib/active_merchant/billing/response.rb +92 -0
  244. data/lib/active_merchant/connection.rb +195 -0
  245. data/lib/active_merchant/country.rb +336 -0
  246. data/lib/active_merchant/empty.rb +20 -0
  247. data/lib/active_merchant/errors.rb +35 -0
  248. data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
  249. data/lib/active_merchant/network_connection_retries.rb +80 -0
  250. data/lib/active_merchant/post_data.rb +25 -0
  251. data/lib/active_merchant/posts_data.rb +92 -0
  252. data/lib/active_merchant/version.rb +3 -0
  253. data/lib/activemerchant.rb +1 -0
  254. data/lib/certs/cacert.pem +3988 -0
  255. data/lib/support/gateway_support.rb +69 -0
  256. data/lib/support/outbound_hosts.rb +28 -0
  257. data/lib/support/ssl_verify.rb +92 -0
  258. data/lib/support/ssl_version.rb +87 -0
  259. metadata +435 -0
@@ -0,0 +1,19 @@
1
+ require 'active_merchant/billing/gateways/smart_ps.rb'
2
+ require 'active_merchant/billing/gateways/braintree/braintree_common'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ class BraintreeOrangeGateway < SmartPs
7
+ include BraintreeCommon
8
+
9
+ self.display_name = 'Braintree (Orange Platform)'
10
+ self.supported_countries = ['US']
11
+
12
+ self.live_url = self.test_url = 'https://secure.braintreepaymentgateway.com/api/transact.php'
13
+
14
+ def add_processor(post, options)
15
+ post[:processor_id] = options[:processor] unless options[:processor].nil?
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,244 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class BridgePayGateway < Gateway
6
+ self.display_name = 'BridgePay'
7
+ self.homepage_url = 'http://www.bridgepaynetwork.com/'
8
+
9
+ self.test_url = 'https://gatewaystage.itstgate.com/SmartPayments/transact3.asmx'
10
+ self.live_url = 'https://gateway.itstgate.com/SmartPayments/transact3.asmx'
11
+
12
+ self.supported_countries = ['CA', 'US']
13
+ self.default_currency = 'USD'
14
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
15
+
16
+ def initialize(options={})
17
+ requires!(options, :user_name, :password)
18
+ super
19
+ end
20
+
21
+ def purchase(amount, payment_method, options={})
22
+ post = initialize_required_fields('Sale')
23
+
24
+ # Allow the same amount in multiple transactions.
25
+ post[:ExtData] = '<Force>T</Force>'
26
+ add_invoice(post, amount, options)
27
+ add_payment_method(post, payment_method)
28
+ add_customer_data(post, options)
29
+
30
+ commit(post)
31
+ end
32
+
33
+ def authorize(amount, payment_method, options={})
34
+ post = initialize_required_fields('Auth')
35
+
36
+ add_invoice(post, amount, options)
37
+ add_payment_method(post, payment_method)
38
+ add_customer_data(post, options)
39
+
40
+ commit(post)
41
+ end
42
+
43
+ def capture(amount, authorization, options={})
44
+ post = initialize_required_fields('Force')
45
+
46
+ add_invoice(post, amount, options)
47
+ add_reference(post, authorization)
48
+ add_customer_data(post, options)
49
+
50
+ commit(post)
51
+ end
52
+
53
+ def refund(amount, authorization, options={})
54
+ post = initialize_required_fields('Return')
55
+
56
+ add_invoice(post, amount, options)
57
+ add_reference(post, authorization)
58
+
59
+ commit(post)
60
+ end
61
+
62
+ def void(authorization, options={})
63
+ post = initialize_required_fields('Void')
64
+
65
+ add_reference(post, authorization)
66
+
67
+ commit(post)
68
+ end
69
+
70
+ def verify(creditcard, options = {})
71
+ MultiResponse.run(:use_first_response) do |r|
72
+ r.process { authorize(100, creditcard, options) }
73
+ r.process(:ignore_result) { void(r.authorization, options) }
74
+ end
75
+ end
76
+
77
+ def store(creditcard, options={})
78
+ post = initialize_required_fields('')
79
+ post[:transaction] = 'Create'
80
+ post[:CardNumber] = creditcard.number
81
+ post[:CustomerPaymentInfoKey] = ''
82
+ post[:token] = ''
83
+ add_payment_method(post, creditcard)
84
+
85
+ commit(post)
86
+ end
87
+
88
+ def supports_scrubbing?
89
+ true
90
+ end
91
+
92
+ def scrub(transcript)
93
+ transcript.
94
+ gsub(%r((&?CardNum=)[^&]*)i, '\1[FILTERED]').
95
+ gsub(%r((&?CVNum=)[^&]*)i, '\1[FILTERED]').
96
+ gsub(%r((&?Password=)[^&]*)i, '\1[FILTERED]').
97
+ gsub(%r((&?TransitNum=)[^&]*)i, '\1[FILTERED]').
98
+ gsub(%r((&?AccountNum=)[^&]*)i, '\1[FILTERED]')
99
+ end
100
+
101
+ private
102
+
103
+ def add_payment_method(post, payment_method)
104
+ if payment_method.respond_to? :brand
105
+ post[:NameOnCard] = payment_method.name if payment_method.name
106
+ post[:ExpDate] = expdate(payment_method)
107
+ post[:CardNum] = payment_method.number
108
+ post[:CVNum] = payment_method.verification_value
109
+ elsif payment_method.is_a?(String)
110
+ add_token(post, payment_method)
111
+ else
112
+ post[:CheckNum] = payment_method.number
113
+ post[:TransitNum] = payment_method.routing_number
114
+ post[:AccountNum] = payment_method.account_number
115
+ post[:NameOnCheck] = payment_method.name
116
+ post[:ExtData] = "<AccountType>#{payment_method.account_type.capitalize}</AccountType>" if payment_method.account_type
117
+ end
118
+ end
119
+
120
+ def add_token(post, payment_method)
121
+ payment_method = payment_method.split('|')
122
+ post[:ExtData] = "<Force>T</Force><CardVault><Transaction>Read</Transaction><CustomerPaymentInfoKey>#{payment_method[1]}</CustomerPaymentInfoKey><Token>#{payment_method[0]}</Token><ExpDate>#{payment_method[2]}</ExpDate></CardVault>"
123
+ end
124
+
125
+ def initialize_required_fields(transaction_type)
126
+ post = {}
127
+ post[:TransType] = transaction_type
128
+ post[:Amount] = ''
129
+ post[:PNRef] = ''
130
+ post[:InvNum] = ''
131
+ post[:CardNum] = ''
132
+ post[:ExpDate] = ''
133
+ post[:MagData] = ''
134
+ post[:NameOnCard] = ''
135
+ post[:Zip] = ''
136
+ post[:Street] = ''
137
+ post[:CVNum] = ''
138
+ post[:MagData] = ''
139
+ post[:ExtData] = ''
140
+ post[:MICR] = ''
141
+ post[:DL] = ''
142
+ post[:SS] = ''
143
+ post[:DOB] = ''
144
+ post[:StateCode] = ''
145
+ post[:CheckType] = ''
146
+ post
147
+ end
148
+
149
+ def add_customer_data(post, options)
150
+ if(billing_address = (options[:billing_address] || options[:address]))
151
+ post[:Street] = billing_address[:address1]
152
+ post[:Zip] = billing_address[:zip]
153
+ end
154
+ end
155
+
156
+ def add_invoice(post, amount, options)
157
+ post[:Amount] = amount(amount)
158
+ post[:InvNum] = options[:order_id]
159
+ end
160
+
161
+ def expdate(creditcard)
162
+ "#{format(creditcard.month, :two_digits)}#{format(creditcard.year, :two_digits)}"
163
+ end
164
+
165
+ def parse(xml)
166
+ response = {}
167
+
168
+ doc = Nokogiri::XML(xml)
169
+ doc.root&.xpath('*')&.each do |node|
170
+ if node.elements.size == 0
171
+ response[node.name.downcase.to_sym] = node.text
172
+ else
173
+ node.elements.each do |childnode|
174
+ name = "#{node.name.downcase}_#{childnode.name.downcase}"
175
+ response[name.to_sym] = childnode.text
176
+ end
177
+ end
178
+ end
179
+
180
+ response
181
+ end
182
+
183
+ def commit(parameters)
184
+ data = post_data(parameters)
185
+ raw = parse(ssl_post(url(parameters), data))
186
+
187
+ Response.new(
188
+ success_from(raw),
189
+ message_from(raw),
190
+ raw,
191
+ authorization: authorization_from(raw),
192
+ test: test?
193
+ )
194
+ end
195
+
196
+ def url(params)
197
+ if params[:transaction]
198
+ "#{base_url}/ManageCardVault"
199
+ else
200
+ action = params[:TransitNum] ? 'ProcessCheck' : 'ProcessCreditCard'
201
+ "#{base_url}/#{action}"
202
+ end
203
+ end
204
+
205
+ def base_url
206
+ test? ? test_url : live_url
207
+ end
208
+
209
+ def success_from(response)
210
+ response[:result] == '0'
211
+ end
212
+
213
+ def message_from(response)
214
+ response[:respmsg] || response[:message]
215
+ end
216
+
217
+ def authorization_from(response)
218
+ if response[:token]
219
+ [response[:token], response[:customerpaymentinfokey], response[:expdate]].join('|')
220
+ else
221
+ [response[:authcode], response[:pnref]].join('|')
222
+ end
223
+ end
224
+
225
+ def split_authorization(authorization)
226
+ authcode, pnref = authorization.split('|')
227
+ [authcode, pnref]
228
+ end
229
+
230
+ def add_reference(post, authorization)
231
+ authcode, pnref = split_authorization(authorization)
232
+ post[:AuthCode] = authcode
233
+ post[:PNRef] = pnref
234
+ end
235
+
236
+ def post_data(post)
237
+ {
238
+ :UserName => @options[:user_name],
239
+ :Password => @options[:password]
240
+ }.merge(post).collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
241
+ end
242
+ end
243
+ end
244
+ end
@@ -0,0 +1,230 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CamsGateway < Gateway
4
+ self.live_url = 'https://secure.centralams.com/gw/api/transact.php'
5
+
6
+ self.supported_countries = ['US']
7
+ self.default_currency = 'USD'
8
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
9
+
10
+ self.homepage_url = 'https://www.centralams.com/'
11
+ self.display_name = 'CAMS: Central Account Management System'
12
+
13
+ STANDARD_ERROR_CODE_MAPPING = {
14
+ '200' => STANDARD_ERROR_CODE[:card_declined],
15
+ '201' => STANDARD_ERROR_CODE[:card_declined],
16
+ '202' => STANDARD_ERROR_CODE[:card_declined],
17
+ '203' => STANDARD_ERROR_CODE[:card_declined],
18
+ '204' => STANDARD_ERROR_CODE[:card_declined],
19
+ '220' => STANDARD_ERROR_CODE[:card_declined],
20
+ '221' => STANDARD_ERROR_CODE[:card_declined],
21
+ '222' => STANDARD_ERROR_CODE[:incorrect_number],
22
+ '223' => STANDARD_ERROR_CODE[:expired_card],
23
+ '224' => STANDARD_ERROR_CODE[:invalid_expiry_date],
24
+ '225' => STANDARD_ERROR_CODE[:invalid_cvc],
25
+ '240' => STANDARD_ERROR_CODE[:call_issuer],
26
+ '250' => STANDARD_ERROR_CODE[:pickup_card],
27
+ '251' => STANDARD_ERROR_CODE[:pickup_card],
28
+ '252' => STANDARD_ERROR_CODE[:pickup_card],
29
+ '253' => STANDARD_ERROR_CODE[:pickup_card],
30
+ '260' => STANDARD_ERROR_CODE[:card_declined],
31
+ '261' => STANDARD_ERROR_CODE[:card_declined],
32
+ '262' => STANDARD_ERROR_CODE[:card_declined],
33
+ '263' => STANDARD_ERROR_CODE[:processing_error],
34
+ '264' => STANDARD_ERROR_CODE[:card_declined],
35
+ '300' => STANDARD_ERROR_CODE[:card_declined],
36
+ '400' => STANDARD_ERROR_CODE[:processing_error],
37
+ '410' => STANDARD_ERROR_CODE[:processing_error],
38
+ '411' => STANDARD_ERROR_CODE[:processing_error],
39
+ '420' => STANDARD_ERROR_CODE[:processing_error],
40
+ '421' => STANDARD_ERROR_CODE[:processing_error],
41
+ '430' => STANDARD_ERROR_CODE[:processing_error],
42
+ '440' => STANDARD_ERROR_CODE[:processing_error],
43
+ '441' => STANDARD_ERROR_CODE[:processing_error],
44
+ '460' => STANDARD_ERROR_CODE[:invalid_number],
45
+ '461' => STANDARD_ERROR_CODE[:processing_error],
46
+ '801' => STANDARD_ERROR_CODE[:processing_error],
47
+ '811' => STANDARD_ERROR_CODE[:processing_error],
48
+ '812' => STANDARD_ERROR_CODE[:processing_error],
49
+ '813' => STANDARD_ERROR_CODE[:processing_error],
50
+ '814' => STANDARD_ERROR_CODE[:processing_error],
51
+ '815' => STANDARD_ERROR_CODE[:processing_error],
52
+ '823' => STANDARD_ERROR_CODE[:processing_error],
53
+ '824' => STANDARD_ERROR_CODE[:processing_error],
54
+ '881' => STANDARD_ERROR_CODE[:processing_error],
55
+ '882' => STANDARD_ERROR_CODE[:processing_error],
56
+ '883' => STANDARD_ERROR_CODE[:processing_error],
57
+ '884' => STANDARD_ERROR_CODE[:card_declined],
58
+ '885' => STANDARD_ERROR_CODE[:card_declined],
59
+ '886' => STANDARD_ERROR_CODE[:card_declined],
60
+ '887' => STANDARD_ERROR_CODE[:processing_error],
61
+ '888' => STANDARD_ERROR_CODE[:processing_error],
62
+ '889' => STANDARD_ERROR_CODE[:processing_error],
63
+ '890' => STANDARD_ERROR_CODE[:processing_error],
64
+ '891' => STANDARD_ERROR_CODE[:incorrect_cvc],
65
+ '892' => STANDARD_ERROR_CODE[:incorrect_cvc],
66
+ '893' => STANDARD_ERROR_CODE[:processing_error],
67
+ '894' => STANDARD_ERROR_CODE[:processing_error]
68
+ }
69
+
70
+ def initialize(options={})
71
+ requires!(options, :username, :password)
72
+ super
73
+ end
74
+
75
+ def purchase(money, payment, options={})
76
+ post = {}
77
+ add_invoice(post, money, options)
78
+
79
+ if payment.respond_to?(:number)
80
+ add_payment(post, payment)
81
+ add_address(post, payment, options)
82
+ elsif payment.kind_of?(String)
83
+ post[:transactionid] = split_authorization(payment)[0]
84
+ end
85
+
86
+ commit('sale', post)
87
+ end
88
+
89
+ def authorize(money, payment, options={})
90
+ post = {}
91
+ add_invoice(post, money, options)
92
+ add_payment(post, payment)
93
+ add_address(post, payment, options)
94
+
95
+ commit('auth', post)
96
+ end
97
+
98
+ def capture(money, authorization, options={})
99
+ post = {}
100
+ add_reference(post, authorization)
101
+ add_invoice(post, money, options)
102
+
103
+ commit('capture', post)
104
+ end
105
+
106
+ def refund(money, authorization, options={})
107
+ post = {}
108
+ add_reference(post, authorization)
109
+ add_invoice(post, money, options)
110
+ commit('refund', post)
111
+ end
112
+
113
+ def void(authorization, options={})
114
+ post = {}
115
+ add_reference(post, authorization)
116
+ commit('void', post)
117
+ end
118
+
119
+ def verify(credit_card, options={})
120
+ post = {}
121
+ add_invoice(post, 0, options)
122
+ add_payment(post, credit_card)
123
+ add_address(post, credit_card, options)
124
+ commit('verify', post)
125
+ end
126
+
127
+ def supports_scrubbing?
128
+ true
129
+ end
130
+
131
+ def scrub(transcript)
132
+ %w(ccnumber cvv password).each do |field|
133
+ transcript = transcript.gsub(%r((#{field}=)[^&]+), '\1[FILTERED]\2')
134
+ end
135
+
136
+ transcript
137
+ end
138
+
139
+ private
140
+
141
+ def add_address(post, creditcard, options={})
142
+ post[:firstname] = creditcard.first_name
143
+ post[:lastname] = creditcard.last_name
144
+
145
+ return unless options[:billing_address]
146
+
147
+ address = options[:billing_address]
148
+ post[:address1] = address[:address1]
149
+ post[:address2] = address[:address2]
150
+ post[:city] = address[:city]
151
+ post[:state] = address[:state]
152
+ post[:zip] = address[:zip]
153
+ post[:country] = address[:country]
154
+ post[:phone] = address[:phone]
155
+ end
156
+
157
+ def add_reference(post, authorization)
158
+ transaction_id, authcode = split_authorization(authorization)
159
+ post['transactionid'] = transaction_id
160
+ post['authcode'] = authcode
161
+ end
162
+
163
+ def add_invoice(post, money, options)
164
+ post[:amount] = amount(money)
165
+ post[:currency] = (options[:currency] || default_currency)
166
+ end
167
+
168
+ def add_payment(post, payment)
169
+ post[:ccnumber] = payment.number
170
+ post[:ccexp] = "#{payment.month.to_s.rjust(2, "0")}#{payment.year.to_s[-2..-1]}"
171
+ post[:cvv] = payment.verification_value
172
+ end
173
+
174
+ def parse(body)
175
+ kvs = body.split('&')
176
+
177
+ kvs.inject({}) { |h, kv|
178
+ k, v = kv.split('=')
179
+ h[k] = v
180
+ h
181
+ }
182
+ end
183
+
184
+ def commit(action, parameters)
185
+ url = live_url
186
+ parameters[:type] = action
187
+
188
+ response_body = ssl_post(url, post_data(parameters))
189
+ response = parse(response_body)
190
+
191
+ Response.new(
192
+ success_from(response),
193
+ message_from(response),
194
+ response,
195
+ authorization: authorization_from(response),
196
+ test: test?,
197
+ error_code: error_code_from(response)
198
+ )
199
+ end
200
+
201
+ def success_from(response)
202
+ response['response_code'] == '100'
203
+ end
204
+
205
+ def message_from(response)
206
+ response['responsetext']
207
+ end
208
+
209
+ def authorization_from(response)
210
+ [response['transactionid'], response['authcode']].join('#')
211
+ end
212
+
213
+ def split_authorization(authorization)
214
+ transaction_id, authcode = authorization.split('#')
215
+ [transaction_id, authcode]
216
+ end
217
+
218
+ def post_data(parameters = {})
219
+ parameters[:password] = @options[:password]
220
+ parameters[:username] = @options[:username]
221
+
222
+ parameters.collect { |k, v| "#{k}=#{v}" }.join('&')
223
+ end
224
+
225
+ def error_code_from(response)
226
+ STANDARD_ERROR_CODE_MAPPING[response['response_code']]
227
+ end
228
+ end
229
+ end
230
+ end