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,355 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class UsaEpayTransactionGateway < Gateway
4
+ self.live_url = 'https://www.usaepay.com/gate'
5
+ self.test_url = 'https://sandbox.usaepay.com/gate'
6
+
7
+ self.supported_cardtypes = [:visa, :master, :american_express]
8
+ self.supported_countries = ['US']
9
+ self.homepage_url = 'http://www.usaepay.com/'
10
+ self.display_name = 'USA ePay'
11
+
12
+ TRANSACTIONS = {
13
+ :authorization => 'cc:authonly',
14
+ :purchase => 'cc:sale',
15
+ :capture => 'cc:capture',
16
+ :refund => 'cc:refund',
17
+ :void => 'cc:void',
18
+ :void_release => 'cc:void:release',
19
+ :check_purchase => 'check:sale'
20
+ }
21
+
22
+ STANDARD_ERROR_CODE_MAPPING = {
23
+ '00011' => STANDARD_ERROR_CODE[:incorrect_number],
24
+ '00012' => STANDARD_ERROR_CODE[:incorrect_number],
25
+ '00013' => STANDARD_ERROR_CODE[:incorrect_number],
26
+ '00014' => STANDARD_ERROR_CODE[:invalid_number],
27
+ '00015' => STANDARD_ERROR_CODE[:invalid_expiry_date],
28
+ '00016' => STANDARD_ERROR_CODE[:invalid_expiry_date],
29
+ '00017' => STANDARD_ERROR_CODE[:expired_card],
30
+ '10116' => STANDARD_ERROR_CODE[:incorrect_cvc],
31
+ '10107' => STANDARD_ERROR_CODE[:incorrect_zip],
32
+ '10109' => STANDARD_ERROR_CODE[:incorrect_address],
33
+ '10110' => STANDARD_ERROR_CODE[:incorrect_address],
34
+ '10111' => STANDARD_ERROR_CODE[:incorrect_address],
35
+ '10127' => STANDARD_ERROR_CODE[:card_declined],
36
+ '00043' => STANDARD_ERROR_CODE[:call_issuer],
37
+ '10205' => STANDARD_ERROR_CODE[:card_declined],
38
+ '10204' => STANDARD_ERROR_CODE[:pickup_card]
39
+ }
40
+
41
+ def initialize(options = {})
42
+ requires!(options, :login)
43
+ super
44
+ end
45
+
46
+ def authorize(money, credit_card, options = {})
47
+ post = {}
48
+
49
+ add_amount(post, money)
50
+ add_invoice(post, options)
51
+ add_payment(post, credit_card)
52
+ unless credit_card.track_data.present?
53
+ add_address(post, credit_card, options)
54
+ add_customer_data(post, options)
55
+ end
56
+ add_split_payments(post, options)
57
+ add_recurring_fields(post, options)
58
+ add_custom_fields(post, options)
59
+ add_line_items(post, options)
60
+ add_test_mode(post, options)
61
+
62
+ commit(:authorization, post)
63
+ end
64
+
65
+ def purchase(money, payment, options = {})
66
+ post = {}
67
+
68
+ add_amount(post, money)
69
+ add_invoice(post, options)
70
+ add_payment(post, payment, options)
71
+ unless payment.respond_to?(:track_data) && payment.track_data.present?
72
+ add_address(post, payment, options)
73
+ add_customer_data(post, options)
74
+ end
75
+ add_split_payments(post, options)
76
+ add_recurring_fields(post, options)
77
+ add_custom_fields(post, options)
78
+ add_line_items(post, options)
79
+ add_test_mode(post, options)
80
+
81
+ payment.respond_to?(:routing_number) ? commit(:check_purchase, post) : commit(:purchase, post)
82
+ end
83
+
84
+ def capture(money, authorization, options = {})
85
+ post = { :refNum => authorization }
86
+
87
+ add_amount(post, money)
88
+ add_test_mode(post, options)
89
+ commit(:capture, post)
90
+ end
91
+
92
+ def refund(money, authorization, options = {})
93
+ post = { :refNum => authorization }
94
+
95
+ add_amount(post, money)
96
+ add_test_mode(post, options)
97
+ commit(:refund, post)
98
+ end
99
+
100
+ def verify(creditcard, options = {})
101
+ MultiResponse.run(:use_first_response) do |r|
102
+ r.process { authorize(1, creditcard, options) }
103
+ r.process(:ignore_result) { void(r.authorization, options) }
104
+ end
105
+ end
106
+
107
+ # Pass `no_release: true` to keep the void from immediately settling
108
+ def void(authorization, options = {})
109
+ command = (options[:no_release] ? :void : :void_release)
110
+ post = { :refNum => authorization }
111
+ add_test_mode(post, options)
112
+ commit(command, post)
113
+ end
114
+
115
+ def supports_scrubbing?
116
+ true
117
+ end
118
+
119
+ def scrub(transcript)
120
+ transcript.
121
+ gsub(%r((&?UMcard=)\d*(&?))i, '\1[FILTERED]\2').
122
+ gsub(%r((&?UMcvv2=)\d*(&?))i, '\1[FILTERED]\2').
123
+ gsub(%r((&?UMmagstripe=)[^&]*)i, '\1[FILTERED]\2').
124
+ gsub(%r((&?UMaccount=)[^&]*)i, '\1[FILTERED]').
125
+ gsub(%r((&?UMkey=)[^&]*)i, '\1[FILTERED]')
126
+ end
127
+
128
+ private
129
+
130
+ def add_amount(post, money)
131
+ post[:amount] = amount(money)
132
+ end
133
+
134
+ def expdate(credit_card)
135
+ year = format(credit_card.year, :two_digits)
136
+ month = format(credit_card.month, :two_digits)
137
+
138
+ "#{month}#{year}"
139
+ end
140
+
141
+ def add_customer_data(post, options)
142
+ address = options[:billing_address] || options[:address] || {}
143
+ post[:street] = address[:address1]
144
+ post[:zip] = address[:zip]
145
+
146
+ if options.has_key? :email
147
+ post[:custemail] = options[:email]
148
+ if options[:cust_receipt]
149
+ post[:custreceipt] = options[:cust_receipt]
150
+ post[:custreceiptname] = options[:cust_receipt_name] if options[:cust_receipt_name]
151
+ else
152
+ post[:custreceipt] = 'No'
153
+ end
154
+ end
155
+
156
+ if options.has_key? :customer
157
+ post[:custid] = options[:customer]
158
+ end
159
+
160
+ if options.has_key? :ip
161
+ post[:ip] = options[:ip]
162
+ end
163
+ end
164
+
165
+ def add_address(post, payment, options)
166
+ billing_address = options[:billing_address] || options[:address]
167
+
168
+ add_address_for_type(:billing, post, payment, billing_address) if billing_address
169
+ add_address_for_type(:shipping, post, payment, options[:shipping_address]) if options[:shipping_address]
170
+ end
171
+
172
+ def add_address_for_type(type, post, payment, address)
173
+ prefix = address_key_prefix(type)
174
+ first_name, last_name = split_names(address[:name])
175
+
176
+ post[address_key(prefix, 'fname')] = first_name.blank? && last_name.blank? ? payment.first_name : first_name
177
+ post[address_key(prefix, 'lname')] = first_name.blank? && last_name.blank? ? payment.last_name : last_name
178
+ post[address_key(prefix, 'company')] = address[:company] unless address[:company].blank?
179
+ post[address_key(prefix, 'street')] = address[:address1] unless address[:address1].blank?
180
+ post[address_key(prefix, 'street2')] = address[:address2] unless address[:address2].blank?
181
+ post[address_key(prefix, 'city')] = address[:city] unless address[:city].blank?
182
+ post[address_key(prefix, 'state')] = address[:state] unless address[:state].blank?
183
+ post[address_key(prefix, 'zip')] = address[:zip] unless address[:zip].blank?
184
+ post[address_key(prefix, 'country')] = address[:country] unless address[:country].blank?
185
+ post[address_key(prefix, 'phone')] = address[:phone] unless address[:phone].blank?
186
+ end
187
+
188
+ def address_key_prefix(type)
189
+ case type
190
+ when :shipping then 'ship'
191
+ when :billing then 'bill'
192
+ end
193
+ end
194
+
195
+ def address_key(prefix, key)
196
+ "#{prefix}#{key}".to_sym
197
+ end
198
+
199
+ def add_invoice(post, options)
200
+ post[:invoice] = options[:invoice]
201
+ post[:orderid] = options[:order_id]
202
+ post[:description] = options[:description]
203
+ end
204
+
205
+ def add_payment(post, payment, options={})
206
+ if payment.respond_to?(:routing_number)
207
+ post[:checkformat] = options[:check_format] if options[:check_format]
208
+ if payment.account_type
209
+ account_type = payment.account_type.to_s.capitalize
210
+ raise ArgumentError, 'account_type must be checking or savings' unless %w(Checking Savings).include?(account_type)
211
+ post[:accounttype] = account_type
212
+ end
213
+ post[:account] = payment.account_number
214
+ post[:routing] = payment.routing_number
215
+ post[:name] = payment.name unless payment.name.blank?
216
+ elsif payment.respond_to?(:track_data) && payment.track_data.present?
217
+ post[:magstripe] = payment.track_data
218
+ post[:cardpresent] = true
219
+ else
220
+ post[:card] = payment.number
221
+ post[:cvv2] = payment.verification_value if payment.verification_value?
222
+ post[:expir] = expdate(payment)
223
+ post[:name] = payment.name unless payment.name.blank?
224
+ post[:cardpresent] = true if payment.manual_entry
225
+ end
226
+ end
227
+
228
+ def add_test_mode(post, options)
229
+ post[:testmode] = (options[:test_mode] ? 1 : 0) if options.has_key?(:test_mode)
230
+ end
231
+
232
+ # see: http://wiki.usaepay.com/developer/transactionapi#split_payments
233
+ def add_split_payments(post, options)
234
+ return unless options[:split_payments].is_a?(Array)
235
+ options[:split_payments].each_with_index do |payment, index|
236
+ prefix = '%02d' % (index + 2)
237
+ post["#{prefix}key"] = payment[:key]
238
+ post["#{prefix}amount"] = amount(payment[:amount])
239
+ post["#{prefix}description"] = payment[:description]
240
+ end
241
+
242
+ # When blank it's 'Stop'. 'Continue' is another one
243
+ post['onError'] = options[:on_error] || 'Void'
244
+ end
245
+
246
+ def add_recurring_fields(post, options)
247
+ return unless options[:recurring_fields].is_a?(Hash)
248
+ options[:recurring_fields].each do |key, value|
249
+ if value == true
250
+ value = 'yes'
251
+ elsif value == false
252
+ next
253
+ end
254
+
255
+ if key == :bill_amount
256
+ value = amount(value)
257
+ end
258
+
259
+ post[key.to_s.delete('_')] = value
260
+ end
261
+ end
262
+
263
+ # see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields
264
+ def add_custom_fields(post, options)
265
+ return unless options[:custom_fields].is_a?(Hash)
266
+
267
+ options[:custom_fields].each do |index, custom|
268
+ raise ArgumentError.new('Cannot specify custom field with index 0') if index.to_s.to_i.zero?
269
+
270
+ post["custom#{index}"] = custom
271
+ end
272
+ end
273
+
274
+ # see: https://wiki.usaepay.com/developer/transactionapi#line_item_details
275
+ def add_line_items(post, options)
276
+ return unless options[:line_items].is_a?(Array)
277
+ options[:line_items].each_with_index do |line_item, index|
278
+ %w(product_ref_num sku qty name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
279
+ post["line#{index}#{key.delete('_')}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
280
+ end
281
+
282
+ {
283
+ quantity: 'qty',
284
+ unit: 'um',
285
+ }.each do |key, umkey|
286
+ post["line#{index}#{umkey}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
287
+ end
288
+
289
+ post["line#{index}cost"] = amount(line_item[:cost])
290
+ end
291
+ end
292
+
293
+ def parse(body)
294
+ fields = {}
295
+ for line in body.split('&')
296
+ key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
297
+ fields[key] = CGI.unescape(value.to_s)
298
+ end
299
+
300
+ {
301
+ :status => fields['UMstatus'],
302
+ :auth_code => fields['UMauthCode'],
303
+ :ref_num => fields['UMrefNum'],
304
+ :batch => fields['UMbatch'],
305
+ :avs_result => fields['UMavsResult'],
306
+ :avs_result_code => fields['UMavsResultCode'],
307
+ :cvv2_result => fields['UMcvv2Result'],
308
+ :cvv2_result_code => fields['UMcvv2ResultCode'],
309
+ :vpas_result_code => fields['UMvpasResultCode'],
310
+ :result => fields['UMresult'],
311
+ :error => fields['UMerror'],
312
+ :error_code => fields['UMerrorcode'],
313
+ :acs_url => fields['UMacsurl'],
314
+ :payload => fields['UMpayload']
315
+ }.delete_if { |k, v| v.nil? }
316
+ end
317
+
318
+ def commit(action, parameters)
319
+ url = (test? ? self.test_url : self.live_url)
320
+ response = parse(ssl_post(url, post_data(action, parameters)))
321
+ approved = response[:status] == 'Approved'
322
+ error_code = nil
323
+ error_code = (STANDARD_ERROR_CODE_MAPPING[response[:error_code]] || STANDARD_ERROR_CODE[:processing_error]) unless approved
324
+ Response.new(approved, message_from(response), response,
325
+ :test => test?,
326
+ :authorization => response[:ref_num],
327
+ :cvv_result => response[:cvv2_result_code],
328
+ :avs_result => { :code => response[:avs_result_code] },
329
+ :error_code => error_code
330
+ )
331
+ end
332
+
333
+ def message_from(response)
334
+ if response[:status] == 'Approved'
335
+ return 'Success'
336
+ else
337
+ return 'Unspecified error' if response[:error].blank?
338
+ return response[:error]
339
+ end
340
+ end
341
+
342
+ def post_data(action, parameters = {})
343
+ parameters[:command] = TRANSACTIONS[action]
344
+ parameters[:key] = @options[:login]
345
+ parameters[:software] = 'Active Merchant'
346
+ parameters[:testmode] = (@options[:test] ? 1 : 0) unless parameters.has_key?(:testmode)
347
+ seed = SecureRandom.hex(32).upcase
348
+ hash = Digest::SHA1.hexdigest("#{parameters[:command]}:#{@options[:password]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
349
+ parameters[:hash] = "s/#{seed}/#{hash}/n"
350
+
351
+ parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join('&')
352
+ end
353
+ end
354
+ end
355
+ end
@@ -0,0 +1,294 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant
4
+ module Billing
5
+ class VancoGateway < Gateway
6
+ include Empty
7
+
8
+ self.test_url = 'https://uat.vancopayments.com/cgi-bin/ws2.vps'
9
+ self.live_url = 'https://myvanco.vancopayments.com/cgi-bin/ws2.vps'
10
+
11
+ self.supported_countries = ['US']
12
+ self.default_currency = 'USD'
13
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
14
+
15
+ self.homepage_url = 'http://vancopayments.com/'
16
+ self.display_name = 'Vanco Payment Solutions'
17
+
18
+ def initialize(options={})
19
+ requires!(options, :user_id, :password, :client_id)
20
+ super
21
+ end
22
+
23
+ def purchase(money, payment_method, options={})
24
+ MultiResponse.run do |r|
25
+ r.process { login }
26
+ r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) }
27
+ end
28
+ end
29
+
30
+ def refund(money, authorization, options={})
31
+ MultiResponse.run do |r|
32
+ r.process { login }
33
+ r.process { commit(refund_request(money, authorization, r.params['response_sessionid']), :response_creditrequestreceived) }
34
+ end
35
+ end
36
+
37
+ def supports_scrubbing?
38
+ true
39
+ end
40
+
41
+ def scrub(transcript)
42
+ transcript.
43
+ gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2').
44
+ gsub(%r((<CardCVV2>).+(</CardCVV2>))i, '\1[FILTERED]\2').
45
+ gsub(%r((<AccountNumber>).+(</AccountNumber>))i, '\1[FILTERED]\2')
46
+ end
47
+
48
+ private
49
+
50
+ def parse(xml)
51
+ response = {}
52
+
53
+ doc = Nokogiri::XML(xml)
54
+ doc.root.xpath('*').each do |node|
55
+ if node.elements.empty?
56
+ response[node.name.downcase.to_sym] = node.text
57
+ else
58
+ node.elements.each do |childnode|
59
+ childnode_to_response(response, node, childnode)
60
+ end
61
+ end
62
+ end
63
+
64
+ response
65
+ end
66
+
67
+ def childnode_to_response(response, node, childnode)
68
+ name = "#{node.name.downcase}_#{childnode.name.downcase}"
69
+ if name == 'response_errors' && !childnode.elements.empty?
70
+ add_errors_to_response(response, childnode.to_s)
71
+ else
72
+ response[name.downcase.to_sym] = childnode.text
73
+ end
74
+ end
75
+
76
+ def add_errors_to_response(response, errors_xml)
77
+ errors_hash = Hash.from_xml(errors_xml).values.first
78
+ response[:response_errors] = errors_hash
79
+
80
+ error = errors_hash['Error']
81
+ if error.kind_of?(Hash)
82
+ response[:error_message] = error['ErrorDescription']
83
+ response[:error_codes] = error['ErrorCode']
84
+ elsif error.kind_of?(Array)
85
+ error_str = error.map { |e| e['ErrorDescription'] }.join('. ')
86
+ error_codes = error.map { |e| e['ErrorCode'] }.join(', ')
87
+ response[:error_message] = "#{error_str}."
88
+ response[:error_codes] = error_codes
89
+ end
90
+ end
91
+
92
+ def commit(request, success_field_name)
93
+ response = parse(ssl_post(url, request, headers))
94
+ succeeded = success_from(response, success_field_name)
95
+
96
+ Response.new(
97
+ succeeded,
98
+ message_from(succeeded, response),
99
+ response,
100
+ authorization: authorization_from(response),
101
+ test: test?
102
+ )
103
+ end
104
+
105
+ def success_from(response, success_field_name)
106
+ !empty?(response[success_field_name])
107
+ end
108
+
109
+ def message_from(succeeded, response)
110
+ return 'Success' if succeeded
111
+ response[:error_message]
112
+ end
113
+
114
+ def authorization_from(response)
115
+ [
116
+ response[:response_customerref],
117
+ response[:response_paymentmethodref],
118
+ response[:response_transactionref]
119
+ ].join('|')
120
+ end
121
+
122
+ def split_authorization(authorization)
123
+ authorization.to_s.split('|')
124
+ end
125
+
126
+ def purchase_request(money, payment_method, session_id, options)
127
+ build_xml_request do |doc|
128
+ add_auth(doc, 'EFTAddCompleteTransaction', session_id)
129
+
130
+ doc.Request do
131
+ doc.RequestVars do
132
+ add_client_id(doc)
133
+ add_amount(doc, money, options)
134
+ add_payment_method(doc, payment_method, options)
135
+ add_options(doc, options)
136
+ add_purchase_noise(doc)
137
+ end
138
+ end
139
+ end
140
+ end
141
+
142
+ def refund_request(money, authorization, session_id)
143
+ build_xml_request do |doc|
144
+ add_auth(doc, 'EFTAddCredit', session_id)
145
+
146
+ doc.Request do
147
+ doc.RequestVars do
148
+ add_client_id(doc)
149
+ add_amount(doc, money, options)
150
+ add_reference(doc, authorization)
151
+ add_refund_noise(doc)
152
+ end
153
+ end
154
+ end
155
+ end
156
+
157
+ def add_request(doc, request_type)
158
+ doc.RequestType(request_type)
159
+ doc.RequestID(SecureRandom.hex(15))
160
+ doc.RequestTime(Time.now)
161
+ doc.Version(2)
162
+ end
163
+
164
+ def add_auth(doc, request_type, session_id)
165
+ doc.Auth do
166
+ add_request(doc, request_type)
167
+ doc.SessionID(session_id)
168
+ end
169
+ end
170
+
171
+ def add_reference(doc, authorization)
172
+ customer_ref, payment_method_ref, transaction_ref = split_authorization(authorization)
173
+ doc.CustomerRef(customer_ref)
174
+ doc.PaymentMethodRef(payment_method_ref)
175
+ doc.TransactionRef(transaction_ref)
176
+ end
177
+
178
+ def add_amount(doc, money, options)
179
+ if empty?(options[:fund_id])
180
+ doc.Amount(amount(money))
181
+ else
182
+ doc.Funds do
183
+ doc.Fund do
184
+ doc.FundID(options[:fund_id])
185
+ doc.FundAmount(amount(money))
186
+ end
187
+ end
188
+ end
189
+ end
190
+
191
+ def add_payment_method(doc, payment_method, options)
192
+ if card_brand(payment_method) == 'check'
193
+ add_echeck(doc, payment_method)
194
+ else
195
+ add_credit_card(doc, payment_method, options)
196
+ end
197
+ end
198
+
199
+ def add_credit_card(doc, credit_card, options)
200
+ doc.AccountNumber(credit_card.number)
201
+ doc.CustomerName("#{credit_card.last_name}, #{credit_card.first_name}")
202
+ doc.CardExpMonth(format(credit_card.month, :two_digits))
203
+ doc.CardExpYear(format(credit_card.year, :two_digits))
204
+ doc.CardCVV2(credit_card.verification_value)
205
+ doc.CardBillingName(credit_card.name)
206
+ doc.AccountType('CC')
207
+ add_billing_address(doc, options)
208
+ end
209
+
210
+ def add_billing_address(doc, options)
211
+ address = options[:billing_address]
212
+ return unless address
213
+
214
+ doc.CardBillingAddr1(address[:address1])
215
+ doc.CardBillingAddr2(address[:address2])
216
+ doc.CardBillingCity(address[:city])
217
+ doc.CardBillingState(address[:state])
218
+ doc.CardBillingZip(address[:zip])
219
+ doc.CardBillingCountryCode(address[:country])
220
+ end
221
+
222
+ def add_echeck(doc, echeck)
223
+ if echeck.account_type == 'savings'
224
+ doc.AccountType('S')
225
+ else
226
+ doc.AccountType('C')
227
+ end
228
+
229
+ doc.CustomerName("#{echeck.last_name}, #{echeck.first_name}")
230
+ doc.AccountNumber(echeck.account_number)
231
+ doc.RoutingNumber(echeck.routing_number)
232
+ doc.TransactionTypeCode('WEB')
233
+ end
234
+
235
+ def add_purchase_noise(doc)
236
+ doc.StartDate('0000-00-00')
237
+ doc.FrequencyCode('O')
238
+ end
239
+
240
+ def add_refund_noise(doc)
241
+ doc.ContactName('Bilbo Baggins')
242
+ doc.ContactPhone('1234567890')
243
+ doc.ContactExtension('None')
244
+ doc.ReasonForCredit('Refund requested')
245
+ end
246
+
247
+ def add_options(doc, options)
248
+ doc.CustomerIPAddress(options[:ip]) if options[:ip]
249
+ end
250
+
251
+ def add_client_id(doc)
252
+ doc.ClientID(@options[:client_id])
253
+ end
254
+
255
+ def login
256
+ commit(login_request, :response_sessionid)
257
+ end
258
+
259
+ def login_request
260
+ build_xml_request do |doc|
261
+ doc.Auth do
262
+ add_request(doc, 'Login')
263
+ end
264
+
265
+ doc.Request do
266
+ doc.RequestVars do
267
+ doc.UserID(@options[:user_id])
268
+ doc.Password(@options[:password])
269
+ end
270
+ end
271
+ end
272
+ end
273
+
274
+ def build_xml_request
275
+ builder = Nokogiri::XML::Builder.new
276
+ builder.__send__('VancoWS') do |doc|
277
+ yield(doc)
278
+ end
279
+ builder.to_xml
280
+ end
281
+
282
+ def url
283
+ (test? ? test_url : live_url)
284
+ end
285
+
286
+ def headers
287
+ {
288
+ 'Content-Type' => 'text/xml'
289
+ }
290
+ end
291
+
292
+ end
293
+ end
294
+ end