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,353 @@
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 = %i[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
+ post[:custid] = options[:customer] if options.has_key? :customer
157
+
158
+ post[:ip] = options[:ip] if options.has_key? :ip
159
+ end
160
+
161
+ def add_address(post, payment, options)
162
+ billing_address = options[:billing_address] || options[:address]
163
+
164
+ add_address_for_type(:billing, post, payment, billing_address) if billing_address
165
+ add_address_for_type(:shipping, post, payment, options[:shipping_address]) if options[:shipping_address]
166
+ end
167
+
168
+ def add_address_for_type(type, post, payment, address)
169
+ prefix = address_key_prefix(type)
170
+ first_name, last_name = split_names(address[:name])
171
+
172
+ post[address_key(prefix, 'fname')] = first_name.blank? && last_name.blank? ? payment.first_name : first_name
173
+ post[address_key(prefix, 'lname')] = first_name.blank? && last_name.blank? ? payment.last_name : last_name
174
+ post[address_key(prefix, 'company')] = address[:company] unless address[:company].blank?
175
+ post[address_key(prefix, 'street')] = address[:address1] unless address[:address1].blank?
176
+ post[address_key(prefix, 'street2')] = address[:address2] unless address[:address2].blank?
177
+ post[address_key(prefix, 'city')] = address[:city] unless address[:city].blank?
178
+ post[address_key(prefix, 'state')] = address[:state] unless address[:state].blank?
179
+ post[address_key(prefix, 'zip')] = address[:zip] unless address[:zip].blank?
180
+ post[address_key(prefix, 'country')] = address[:country] unless address[:country].blank?
181
+ post[address_key(prefix, 'phone')] = address[:phone] unless address[:phone].blank?
182
+ end
183
+
184
+ def address_key_prefix(type)
185
+ case type
186
+ when :shipping then 'ship'
187
+ when :billing then 'bill'
188
+ end
189
+ end
190
+
191
+ def address_key(prefix, key)
192
+ "#{prefix}#{key}".to_sym
193
+ end
194
+
195
+ def add_invoice(post, options)
196
+ post[:invoice] = options[:invoice]
197
+ post[:orderid] = options[:order_id]
198
+ post[:description] = options[:description]
199
+ end
200
+
201
+ def add_payment(post, payment, options = {})
202
+ if payment.respond_to?(:routing_number)
203
+ post[:checkformat] = options[:check_format] if options[:check_format]
204
+ if payment.account_type
205
+ account_type = payment.account_type.to_s.capitalize
206
+ raise ArgumentError, 'account_type must be checking or savings' unless %w(Checking Savings).include?(account_type)
207
+
208
+ post[:accounttype] = account_type
209
+ end
210
+ post[:account] = payment.account_number
211
+ post[:routing] = payment.routing_number
212
+ post[:name] = payment.name unless payment.name.blank?
213
+ elsif payment.respond_to?(:track_data) && payment.track_data.present?
214
+ post[:magstripe] = payment.track_data
215
+ post[:cardpresent] = true
216
+ else
217
+ post[:card] = payment.number
218
+ post[:cvv2] = payment.verification_value if payment.verification_value?
219
+ post[:expir] = expdate(payment)
220
+ post[:name] = payment.name unless payment.name.blank?
221
+ post[:cardpresent] = true if payment.manual_entry
222
+ end
223
+ end
224
+
225
+ def add_test_mode(post, options)
226
+ post[:testmode] = (options[:test_mode] ? 1 : 0) if options.has_key?(:test_mode)
227
+ end
228
+
229
+ # see: http://wiki.usaepay.com/developer/transactionapi#split_payments
230
+ def add_split_payments(post, options)
231
+ return unless options[:split_payments].is_a?(Array)
232
+
233
+ options[:split_payments].each_with_index do |payment, index|
234
+ prefix = '%02d' % (index + 2)
235
+ post["#{prefix}key"] = payment[:key]
236
+ post["#{prefix}amount"] = amount(payment[:amount])
237
+ post["#{prefix}description"] = payment[:description]
238
+ end
239
+
240
+ # When blank it's 'Stop'. 'Continue' is another one
241
+ post['onError'] = options[:on_error] || 'Void'
242
+ end
243
+
244
+ def add_recurring_fields(post, options)
245
+ return unless options[:recurring_fields].is_a?(Hash)
246
+
247
+ options[:recurring_fields].each do |key, value|
248
+ if value == true
249
+ value = 'yes'
250
+ elsif value == false
251
+ next
252
+ end
253
+
254
+ value = amount(value) if key == :bill_amount
255
+
256
+ post[key.to_s.delete('_')] = value
257
+ end
258
+ end
259
+
260
+ # see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields
261
+ def add_custom_fields(post, options)
262
+ return unless options[:custom_fields].is_a?(Hash)
263
+
264
+ options[:custom_fields].each do |index, custom|
265
+ raise ArgumentError.new('Cannot specify custom field with index 0') if index.to_s.to_i.zero?
266
+
267
+ post["custom#{index}"] = custom
268
+ end
269
+ end
270
+
271
+ # see: https://wiki.usaepay.com/developer/transactionapi#line_item_details
272
+ def add_line_items(post, options)
273
+ return unless options[:line_items].is_a?(Array)
274
+
275
+ options[:line_items].each_with_index do |line_item, index|
276
+ %w(product_ref_num sku qty name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
277
+ post["line#{index}#{key.delete('_')}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
278
+ end
279
+
280
+ {
281
+ quantity: 'qty',
282
+ unit: 'um'
283
+ }.each do |key, umkey|
284
+ post["line#{index}#{umkey}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
285
+ end
286
+
287
+ post["line#{index}cost"] = amount(line_item[:cost])
288
+ end
289
+ end
290
+
291
+ def parse(body)
292
+ fields = {}
293
+ for line in body.split('&')
294
+ key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
295
+ fields[key] = CGI.unescape(value.to_s)
296
+ end
297
+
298
+ {
299
+ status: fields['UMstatus'],
300
+ auth_code: fields['UMauthCode'],
301
+ ref_num: fields['UMrefNum'],
302
+ batch: fields['UMbatch'],
303
+ avs_result: fields['UMavsResult'],
304
+ avs_result_code: fields['UMavsResultCode'],
305
+ cvv2_result: fields['UMcvv2Result'],
306
+ cvv2_result_code: fields['UMcvv2ResultCode'],
307
+ vpas_result_code: fields['UMvpasResultCode'],
308
+ result: fields['UMresult'],
309
+ error: fields['UMerror'],
310
+ error_code: fields['UMerrorcode'],
311
+ acs_url: fields['UMacsurl'],
312
+ payload: fields['UMpayload']
313
+ }.delete_if { |_k, v| v.nil? }
314
+ end
315
+
316
+ def commit(action, parameters)
317
+ url = (test? ? self.test_url : self.live_url)
318
+ response = parse(ssl_post(url, post_data(action, parameters)))
319
+ approved = response[:status] == 'Approved'
320
+ error_code = nil
321
+ error_code = (STANDARD_ERROR_CODE_MAPPING[response[:error_code]] || STANDARD_ERROR_CODE[:processing_error]) unless approved
322
+ Response.new(approved, message_from(response), response,
323
+ test: test?,
324
+ authorization: response[:ref_num],
325
+ cvv_result: response[:cvv2_result_code],
326
+ avs_result: { code: response[:avs_result_code] },
327
+ error_code: error_code)
328
+ end
329
+
330
+ def message_from(response)
331
+ if response[:status] == 'Approved'
332
+ return 'Success'
333
+ else
334
+ return 'Unspecified error' if response[:error].blank?
335
+
336
+ return response[:error]
337
+ end
338
+ end
339
+
340
+ def post_data(action, parameters = {})
341
+ parameters[:command] = TRANSACTIONS[action]
342
+ parameters[:key] = @options[:login]
343
+ parameters[:software] = 'Active Merchant'
344
+ parameters[:testmode] = (@options[:test] ? 1 : 0) unless parameters.has_key?(:testmode)
345
+ seed = SecureRandom.hex(32).upcase
346
+ hash = Digest::SHA1.hexdigest("#{parameters[:command]}:#{@options[:pin] || @options[:password]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
347
+ parameters[:hash] = "s/#{seed}/#{hash}/n"
348
+
349
+ parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join('&')
350
+ end
351
+ end
352
+ end
353
+ 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 = %i[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
+
112
+ response[:error_message]
113
+ end
114
+
115
+ def authorization_from(response)
116
+ [
117
+ response[:response_customerref],
118
+ response[:response_paymentmethodref],
119
+ response[:response_transactionref]
120
+ ].join('|')
121
+ end
122
+
123
+ def split_authorization(authorization)
124
+ authorization.to_s.split('|')
125
+ end
126
+
127
+ def purchase_request(money, payment_method, session_id, options)
128
+ build_xml_request do |doc|
129
+ add_auth(doc, 'EFTAddCompleteTransaction', session_id)
130
+
131
+ doc.Request do
132
+ doc.RequestVars do
133
+ add_client_id(doc)
134
+ add_amount(doc, money, options)
135
+ add_payment_method(doc, payment_method, options)
136
+ add_options(doc, options)
137
+ add_purchase_noise(doc)
138
+ end
139
+ end
140
+ end
141
+ end
142
+
143
+ def refund_request(money, authorization, session_id)
144
+ build_xml_request do |doc|
145
+ add_auth(doc, 'EFTAddCredit', session_id)
146
+
147
+ doc.Request do
148
+ doc.RequestVars do
149
+ add_client_id(doc)
150
+ add_amount(doc, money, options)
151
+ add_reference(doc, authorization)
152
+ add_refund_noise(doc)
153
+ end
154
+ end
155
+ end
156
+ end
157
+
158
+ def add_request(doc, request_type)
159
+ doc.RequestType(request_type)
160
+ doc.RequestID(SecureRandom.hex(15))
161
+ doc.RequestTime(Time.now)
162
+ doc.Version(2)
163
+ end
164
+
165
+ def add_auth(doc, request_type, session_id)
166
+ doc.Auth do
167
+ add_request(doc, request_type)
168
+ doc.SessionID(session_id)
169
+ end
170
+ end
171
+
172
+ def add_reference(doc, authorization)
173
+ customer_ref, payment_method_ref, transaction_ref = split_authorization(authorization)
174
+ doc.CustomerRef(customer_ref)
175
+ doc.PaymentMethodRef(payment_method_ref)
176
+ doc.TransactionRef(transaction_ref)
177
+ end
178
+
179
+ def add_amount(doc, money, options)
180
+ if empty?(options[:fund_id])
181
+ doc.Amount(amount(money))
182
+ else
183
+ doc.Funds do
184
+ doc.Fund do
185
+ doc.FundID(options[:fund_id])
186
+ doc.FundAmount(amount(money))
187
+ end
188
+ end
189
+ end
190
+ end
191
+
192
+ def add_payment_method(doc, payment_method, options)
193
+ if card_brand(payment_method) == 'check'
194
+ add_echeck(doc, payment_method)
195
+ else
196
+ add_credit_card(doc, payment_method, options)
197
+ end
198
+ end
199
+
200
+ def add_credit_card(doc, credit_card, options)
201
+ doc.AccountNumber(credit_card.number)
202
+ doc.CustomerName("#{credit_card.last_name}, #{credit_card.first_name}")
203
+ doc.CardExpMonth(format(credit_card.month, :two_digits))
204
+ doc.CardExpYear(format(credit_card.year, :two_digits))
205
+ doc.CardCVV2(credit_card.verification_value)
206
+ doc.CardBillingName(credit_card.name)
207
+ doc.AccountType('CC')
208
+ add_billing_address(doc, options)
209
+ end
210
+
211
+ def add_billing_address(doc, options)
212
+ address = options[:billing_address]
213
+ return unless address
214
+
215
+ doc.CardBillingAddr1(address[:address1])
216
+ doc.CardBillingAddr2(address[:address2])
217
+ doc.CardBillingCity(address[:city])
218
+ doc.CardBillingState(address[:state])
219
+ doc.CardBillingZip(address[:zip])
220
+ doc.CardBillingCountryCode(address[:country])
221
+ end
222
+
223
+ def add_echeck(doc, echeck)
224
+ if echeck.account_type == 'savings'
225
+ doc.AccountType('S')
226
+ else
227
+ doc.AccountType('C')
228
+ end
229
+
230
+ doc.CustomerName("#{echeck.last_name}, #{echeck.first_name}")
231
+ doc.AccountNumber(echeck.account_number)
232
+ doc.RoutingNumber(echeck.routing_number)
233
+ doc.TransactionTypeCode('WEB')
234
+ end
235
+
236
+ def add_purchase_noise(doc)
237
+ doc.StartDate('0000-00-00')
238
+ doc.FrequencyCode('O')
239
+ end
240
+
241
+ def add_refund_noise(doc)
242
+ doc.ContactName('Bilbo Baggins')
243
+ doc.ContactPhone('1234567890')
244
+ doc.ContactExtension('None')
245
+ doc.ReasonForCredit('Refund requested')
246
+ end
247
+
248
+ def add_options(doc, options)
249
+ doc.CustomerIPAddress(options[:ip]) if options[:ip]
250
+ end
251
+
252
+ def add_client_id(doc)
253
+ doc.ClientID(@options[:client_id])
254
+ end
255
+
256
+ def login
257
+ commit(login_request, :response_sessionid)
258
+ end
259
+
260
+ def login_request
261
+ build_xml_request do |doc|
262
+ doc.Auth do
263
+ add_request(doc, 'Login')
264
+ end
265
+
266
+ doc.Request do
267
+ doc.RequestVars do
268
+ doc.UserID(@options[:user_id])
269
+ doc.Password(@options[:password])
270
+ end
271
+ end
272
+ end
273
+ end
274
+
275
+ def build_xml_request
276
+ builder = Nokogiri::XML::Builder.new
277
+ builder.__send__('VancoWS') do |doc|
278
+ yield(doc)
279
+ end
280
+ builder.to_xml
281
+ end
282
+
283
+ def url
284
+ (test? ? test_url : live_url)
285
+ end
286
+
287
+ def headers
288
+ {
289
+ 'Content-Type' => 'text/xml'
290
+ }
291
+ end
292
+ end
293
+ end
294
+ end