swiss-activemerchant 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (287) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +4033 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +249 -0
  6. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  7. data/lib/active_merchant/billing/avs_result.rb +95 -0
  8. data/lib/active_merchant/billing/base.rb +48 -0
  9. data/lib/active_merchant/billing/check.rb +112 -0
  10. data/lib/active_merchant/billing/compatibility.rb +118 -0
  11. data/lib/active_merchant/billing/credit_card.rb +451 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +37 -0
  15. data/lib/active_merchant/billing/gateway.rb +332 -0
  16. data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
  17. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  18. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  19. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
  23. data/lib/active_merchant/billing/gateways/axcessms.rb +243 -0
  24. data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
  25. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  26. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  27. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  28. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  29. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  30. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  31. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
  33. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  34. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
  35. data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
  36. data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
  37. data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
  38. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  39. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
  40. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  41. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
  43. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  44. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  45. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  46. data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +235 -0
  52. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  53. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  54. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  59. data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
  60. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  61. data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
  62. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  63. data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
  64. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  65. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  66. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  67. data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
  68. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  69. data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
  70. data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
  71. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  72. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  73. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  74. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  75. data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
  76. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
  78. data/lib/active_merchant/billing/gateways/element.rb +406 -0
  79. data/lib/active_merchant/billing/gateways/epay.rb +296 -0
  80. data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
  81. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  82. data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
  83. data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
  84. data/lib/active_merchant/billing/gateways/exact.rb +219 -0
  85. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  86. data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
  87. data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
  88. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  89. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  90. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  91. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  92. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  93. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  94. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  95. data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
  96. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  97. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  98. data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
  99. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  100. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  101. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  102. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  103. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  104. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  105. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  106. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  107. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  108. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  109. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  110. data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
  111. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  112. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  113. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  114. data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
  115. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  116. data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
  117. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  118. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  119. data/lib/active_merchant/billing/gateways/litle.rb +643 -0
  120. data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
  121. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  122. data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
  123. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
  124. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  125. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  126. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  127. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  128. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  129. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  130. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  131. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  132. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  133. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  134. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  135. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  136. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  137. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  138. data/lib/active_merchant/billing/gateways/monei.rb +424 -0
  139. data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
  140. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  141. data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
  142. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  143. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  144. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  145. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  146. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  147. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  148. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  149. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  150. data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
  151. data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
  152. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  153. data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
  154. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  155. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  156. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  157. data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
  158. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  160. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  161. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  162. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  163. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  164. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  165. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  166. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  167. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  168. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  169. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  170. data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
  171. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  172. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  173. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  174. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  175. data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
  176. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  177. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  178. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  179. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  180. data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
  181. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  182. data/lib/active_merchant/billing/gateways/paynetworx.rb +227 -0
  183. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  184. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
  185. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  186. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  187. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  188. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  189. data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
  190. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  191. data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
  192. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  193. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  194. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  195. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  196. data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
  197. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  198. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  199. data/lib/active_merchant/billing/gateways/pin.rb +273 -0
  200. data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
  201. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  202. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  203. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  204. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  205. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  206. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  207. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  208. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  209. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  210. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  211. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  212. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  213. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  214. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  215. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  216. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  217. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  218. data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
  219. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  220. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  221. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  222. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  223. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  224. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  225. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  226. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  227. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  228. data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
  229. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  230. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  231. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  232. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  233. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  234. data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
  235. data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
  236. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
  237. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  238. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  239. data/lib/active_merchant/billing/gateways/tns.rb +23 -0
  240. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  241. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  242. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  243. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  244. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  245. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  246. data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
  247. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  248. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  249. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
  250. data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
  251. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  252. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  253. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  254. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  255. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  256. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  257. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  258. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  259. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  260. data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
  261. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  262. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  263. data/lib/active_merchant/billing/gateways.rb +14 -0
  264. data/lib/active_merchant/billing/model.rb +30 -0
  265. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  266. data/lib/active_merchant/billing/payment_token.rb +21 -0
  267. data/lib/active_merchant/billing/rails.rb +3 -0
  268. data/lib/active_merchant/billing/response.rb +120 -0
  269. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  270. data/lib/active_merchant/billing.rb +16 -0
  271. data/lib/active_merchant/connection.rb +194 -0
  272. data/lib/active_merchant/country.rb +338 -0
  273. data/lib/active_merchant/empty.rb +20 -0
  274. data/lib/active_merchant/errors.rb +38 -0
  275. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  276. data/lib/active_merchant/network_connection_retries.rb +78 -0
  277. data/lib/active_merchant/post_data.rb +26 -0
  278. data/lib/active_merchant/posts_data.rb +92 -0
  279. data/lib/active_merchant/version.rb +3 -0
  280. data/lib/active_merchant.rb +63 -0
  281. data/lib/activemerchant.rb +1 -0
  282. data/lib/certs/cacert.pem +3214 -0
  283. data/lib/support/gateway_support.rb +69 -0
  284. data/lib/support/outbound_hosts.rb +28 -0
  285. data/lib/support/ssl_verify.rb +88 -0
  286. data/lib/support/ssl_version.rb +86 -0
  287. metadata +506 -0
@@ -0,0 +1,612 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class TransFirstTransactionExpressGateway < Gateway
6
+ self.display_name = 'TransFirst Transaction Express'
7
+ self.homepage_url = 'http://transactionexpress.com/'
8
+
9
+ self.test_url = 'https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl'
10
+ self.live_url = 'https://ws.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl'
11
+
12
+ self.supported_countries = ['US']
13
+ self.default_currency = 'USD'
14
+ self.money_format = :cents
15
+ self.supported_cardtypes = %i[visa master american_express discover diners_club]
16
+
17
+ V1_NAMESPACE = 'http://postilion/realtime/merchantframework/xsd/v1/'
18
+ SOAPENV_NAMESPACE = 'http://schemas.xmlsoap.org/soap/envelope/'
19
+ AUTHORIZATION_FIELD_SEPARATOR = '|'
20
+
21
+ APPROVAL_CODES = %w(00 10)
22
+
23
+ RESPONSE_MESSAGES = {
24
+ '00' => 'Approved',
25
+ '01' => 'Refer to card issuer',
26
+ '02' => 'Refer to card issuer, special condition',
27
+ '03' => 'Invalid merchant',
28
+ '04' => 'Pick-up card',
29
+ '05' => 'Do not honor',
30
+ '06' => 'Error',
31
+ '07' => 'Pick-up card, special condition',
32
+ '08' => 'Honor with identification',
33
+ '09' => 'Request in progress',
34
+ '10' => 'Approved, partial authorization',
35
+ '11' => 'VIP Approval',
36
+ '12' => 'Invalid transaction',
37
+ '13' => 'Invalid amount',
38
+ '14' => 'Invalid card number',
39
+ '15' => 'No such issuer',
40
+ '16' => 'Approved, update track 3',
41
+ '17' => 'Customer cancellation',
42
+ '18' => 'Customer dispute',
43
+ '19' => 'Re-enter transaction',
44
+ '20' => 'Invalid response',
45
+ '21' => 'No action taken',
46
+ '22' => 'Suspected malfunction',
47
+ '23' => 'Unacceptable transaction fee',
48
+ '24' => 'File update not supported',
49
+ '25' => 'Unable to locate record',
50
+ '26' => 'Duplicate record',
51
+ '27' => 'File update field edit error',
52
+ '28' => 'File update file locked',
53
+ '29' => 'File update failed',
54
+ '30' => 'Format error',
55
+ '31' => 'Bank not supported',
56
+ '33' => 'Expired card, pick-up',
57
+ '34' => 'Suspected fraud, pick-up',
58
+ '35' => 'Contact acquirer, pick-up',
59
+ '36' => 'Restricted card, pick-up',
60
+ '37' => 'Call acquirer security, pick-up',
61
+ '38' => 'PIN tries exceeded, pick-up',
62
+ '39' => 'No credit account',
63
+ '40' => 'Function not supported',
64
+ '41' => 'Lost card, pick-up',
65
+ '42' => 'No universal account',
66
+ '43' => 'Stolen card, pick-up',
67
+ '44' => 'No investment account',
68
+ '45' => 'Account closed',
69
+ '46' => 'Identification required',
70
+ '47' => 'Identification cross-check required',
71
+ '48' => 'No customer record',
72
+ '49' => 'Reserved for future Realtime use',
73
+ '50' => 'Reserved for future Realtime use',
74
+ '51' => 'Not sufficient funds',
75
+ '52' => 'No checking account',
76
+ '53' => 'No savings account',
77
+ '54' => 'Expired card',
78
+ '55' => 'Incorrect PIN',
79
+ '56' => 'No card record',
80
+ '57' => 'Transaction not permitted to cardholder',
81
+ '58' => 'Transaction not permitted on terminal',
82
+ '59' => 'Suspected fraud',
83
+ '60' => 'Contact acquirer',
84
+ '61' => 'Exceeds withdrawal limit',
85
+ '62' => 'Restricted card',
86
+ '63' => 'Security violation',
87
+ '64' => 'Original amount incorrect',
88
+ '65' => 'Exceeds withdrawal frequency',
89
+ '66' => 'Call acquirer security',
90
+ '67' => 'Hard capture',
91
+ '68' => 'Response received too late',
92
+ '69' => 'Advice received too late (the response from a request was received too late )',
93
+ '70' => 'Reserved for future use',
94
+ '71' => 'Reserved for future Realtime use',
95
+ '72' => 'Reserved for future Realtime use',
96
+ '73' => 'Reserved for future Realtime use',
97
+ '74' => 'Reserved for future Realtime use',
98
+ '75' => 'PIN tries exceeded',
99
+ '76' => 'Reversal: Unable to locate previous message (no match on Retrieval Reference Number)/ Reserved for future Realtime use',
100
+ '77' => 'Previous message located for a repeat or reversal, but repeat or reversal data is inconsistent with original message/ Intervene, bank approval required',
101
+ '78' => 'Invalid/non-existent account – Decline (MasterCard specific)/ Intervene, bank approval required for partial amount',
102
+ '79' => 'Already reversed (by Switch)/ Reserved for client-specific use (declined)',
103
+ '80' => 'No financial Impact (Reserved for declined debit)/ Reserved for client-specific use (declined)',
104
+ '81' => 'PIN cryptographic error found by the Visa security module during PIN decryption/ Reserved for client-specific use (declined)',
105
+ '82' => 'Incorrect CVV/ Reserved for client-specific use (declined)',
106
+ '83' => 'Unable to verify PIN/ Reserved for client-specific use (declined)',
107
+ '84' => 'Invalid Authorization Life Cycle – Decline (MasterCard) or Duplicate Transaction Detected (Visa)/ Reserved for client-specific use (declined)',
108
+ '85' => 'No reason to decline a request for Account Number Verification or Address Verification/ Reserved for client-specific use (declined)',
109
+ '86' => 'Cannot verify PIN/ Reserved for client-specific use (declined)',
110
+ '87' => 'Reserved for client-specific use (declined)',
111
+ '88' => 'Reserved for client-specific use (declined)',
112
+ '89' => 'Reserved for client-specific use (declined)',
113
+ '90' => 'Cut-off in progress',
114
+ '91' => 'Issuer or switch inoperative',
115
+ '92' => 'Routing error',
116
+ '93' => 'Violation of law',
117
+ '94' => 'Duplicate Transmission (Integrated Debit and MasterCard)',
118
+ '95' => 'Reconcile error',
119
+ '96' => 'System malfunction',
120
+ '97' => 'Reserved for future Realtime use',
121
+ '98' => 'Exceeds cash limit',
122
+ '99' => 'Reserved for future Realtime use',
123
+ '1106' => 'Reserved for future Realtime use',
124
+ '0A' => 'Reserved for future Realtime use',
125
+ 'A0' => 'Reserved for future Realtime use',
126
+ 'A1' => 'ATC not incremented',
127
+ 'A2' => 'ATC limit exceeded',
128
+ 'A3' => 'ATC configuration error',
129
+ 'A4' => 'CVR check failure',
130
+ 'A5' => 'CVR configuration error',
131
+ 'A6' => 'TVR check failure',
132
+ 'A7' => 'TVR configuration error',
133
+ 'A8' => 'Reserved for future Realtime use',
134
+ 'B1' => 'Surcharge amount not permitted on Visa cards or EBT Food Stamps/ Reserved for future Realtime use',
135
+ 'B2' => 'Surcharge amount not supported by debit network issuer/ Reserved for future Realtime use',
136
+ 'C1' => 'Unacceptable PIN',
137
+ 'C2' => 'PIN Change failed',
138
+ 'C3' => 'PIN Unblock failed',
139
+ 'D1' => 'MAC Error',
140
+ 'E1' => 'Prepay error',
141
+ 'N1' => 'Network Error within the TXP platform',
142
+ 'N0' => 'Force STIP/ Reserved for client-specific use (declined)',
143
+ 'N3' => 'Cash service not available/ Reserved for client-specific use (declined)',
144
+ 'N4' => 'Cash request exceeds Issuer limit/ Reserved for client-specific use (declined)',
145
+ 'N5' => 'Ineligible for re-submission/ Reserved for client-specific use (declined)',
146
+ 'N7' => 'Decline for CVV2 failure/ Reserved for client-specific use (declined)',
147
+ 'N8' => 'Transaction amount exceeds preauthorized approval amount/ Reserved for client-specific use (declined)',
148
+ 'P0' => 'Approved; PVID code is missing, invalid, or has expired',
149
+ 'P1' => 'Declined; PVID code is missing, invalid, or has expired/ Reserved for client-specific use (declined)',
150
+ 'P2' => 'Invalid biller Information/ Reserved for client-specific use (declined)/ Reserved for client-specific use (declined)',
151
+ 'R0' => 'The transaction was declined or returned, because the cardholder requested that payment of a specific recurring or installment payment transaction be stopped/ Reserved for client-specific use (declined)',
152
+ 'R1' => 'The transaction was declined or returned, because the cardholder requested that payment of all recurring or installment payment transactions for a specific merchant account be stopped/ Reserved for client-specific use (declined)',
153
+ 'Q1' => 'Card Authentication failed/ Reserved for client-specific use (declined)',
154
+ 'XA' => 'Forward to Issuer/ Reserved for client-specific use (declined)',
155
+ 'XD' => 'Forward to Issuer/ Reserved for client-specific use (declined)'
156
+ }
157
+
158
+ EXTENDED_RESPONSE_MESSAGES = {
159
+ 'B40K' => 'Declined Post – Credit linked to unextracted settle transaction'
160
+ }
161
+
162
+ TRANSACTION_CODES = {
163
+ authorize: 0,
164
+ void_authorize: 2,
165
+
166
+ purchase: 1,
167
+ capture: 3,
168
+ void_purchase: 6,
169
+ void_capture: 6,
170
+
171
+ refund: 4,
172
+ credit: 5,
173
+ void_refund: 13,
174
+ void_credit: 13,
175
+
176
+ verify: 9,
177
+
178
+ purchase_echeck: 11,
179
+ refund_echeck: 16,
180
+ void_echeck: 16,
181
+
182
+ wallet_sale: 14
183
+ }
184
+
185
+ def initialize(options = {})
186
+ requires!(options, :gateway_id, :reg_key)
187
+ super
188
+ end
189
+
190
+ def purchase(amount, payment_method, options = {})
191
+ if credit_card?(payment_method)
192
+ action = :purchase
193
+ request = build_xml_transaction_request do |doc|
194
+ add_credit_card(doc, payment_method)
195
+ add_contact(doc, payment_method.name, options)
196
+ add_amount(doc, amount)
197
+ add_order_number(doc, options)
198
+ end
199
+ elsif echeck?(payment_method)
200
+ action = :purchase_echeck
201
+ request = build_xml_transaction_request do |doc|
202
+ add_echeck(doc, payment_method)
203
+ add_contact(doc, payment_method.name, options)
204
+ add_amount(doc, amount)
205
+ add_order_number(doc, options)
206
+ end
207
+ else
208
+ action = :wallet_sale
209
+ wallet_id = split_authorization(payment_method).last
210
+ request = build_xml_transaction_request do |doc|
211
+ add_amount(doc, amount)
212
+ add_wallet_id(doc, wallet_id)
213
+ end
214
+ end
215
+
216
+ commit(action, request)
217
+ end
218
+
219
+ def authorize(amount, payment_method, options = {})
220
+ if credit_card?(payment_method)
221
+ request = build_xml_transaction_request do |doc|
222
+ add_credit_card(doc, payment_method)
223
+ add_contact(doc, payment_method.name, options)
224
+ add_amount(doc, amount)
225
+ end
226
+ else
227
+ wallet_id = split_authorization(payment_method).last
228
+ request = build_xml_transaction_request do |doc|
229
+ add_amount(doc, amount)
230
+ add_wallet_id(doc, wallet_id)
231
+ end
232
+ end
233
+
234
+ commit(:authorize, request)
235
+ end
236
+
237
+ def capture(amount, authorization, options = {})
238
+ transaction_id = split_authorization(authorization)[1]
239
+ request = build_xml_transaction_request do |doc|
240
+ add_amount(doc, amount)
241
+ add_original_transaction_data(doc, transaction_id)
242
+ end
243
+
244
+ commit(:capture, request)
245
+ end
246
+
247
+ def void(authorization, options = {})
248
+ action, transaction_id = split_authorization(authorization)
249
+
250
+ request = build_xml_transaction_request do |doc|
251
+ add_original_transaction_data(doc, transaction_id)
252
+ end
253
+
254
+ commit(void_type(action), request)
255
+ end
256
+
257
+ def refund(amount, authorization, options = {})
258
+ action, transaction_id = split_authorization(authorization)
259
+
260
+ request = build_xml_transaction_request do |doc|
261
+ add_amount(doc, amount) unless action == 'purchase_echeck'
262
+ add_original_transaction_data(doc, transaction_id)
263
+ end
264
+
265
+ commit(refund_type(action), request)
266
+ end
267
+
268
+ def credit(amount, payment_method, options = {})
269
+ request = build_xml_transaction_request do |doc|
270
+ add_pan(doc, payment_method)
271
+ add_amount(doc, amount)
272
+ end
273
+
274
+ commit(:credit, request)
275
+ end
276
+
277
+ def verify(credit_card, options = {})
278
+ request = build_xml_transaction_request do |doc|
279
+ add_credit_card(doc, credit_card)
280
+ add_contact(doc, credit_card.name, options)
281
+ end
282
+
283
+ commit(:verify, request)
284
+ end
285
+
286
+ def store(payment_method, options = {})
287
+ store_customer_request = build_xml_payment_storage_request do |doc|
288
+ store_customer_details(doc, payment_method.name, options)
289
+ end
290
+
291
+ MultiResponse.run do |r|
292
+ r.process { commit(:store, store_customer_request) }
293
+ return r unless r.success? && r.params['custId']
294
+
295
+ customer_id = r.params['custId']
296
+
297
+ store_payment_method_request = build_xml_payment_storage_request do |doc|
298
+ doc['v1'].cust do
299
+ add_customer_id(doc, customer_id)
300
+ doc['v1'].pmt do
301
+ doc['v1'].type 0 # add
302
+ add_credit_card(doc, payment_method)
303
+ end
304
+ end
305
+ end
306
+
307
+ r.process { commit(:store, store_payment_method_request) }
308
+ end
309
+ end
310
+
311
+ def supports_scrubbing?
312
+ true
313
+ end
314
+
315
+ def scrub(transcript)
316
+ transcript.
317
+ gsub(%r((<[^>]+pan>)[^<]+(<))i, '\1[FILTERED]\2').
318
+ gsub(%r((<[^>]+sec>)[^<]+(<))i, '\1[FILTERED]\2').
319
+ gsub(%r((<[^>]+id>)[^<]+(<))i, '\1[FILTERED]\2').
320
+ gsub(%r((<[^>]+regKey>)[^<]+(<))i, '\1[FILTERED]\2').
321
+ gsub(%r((<[^>]+acctNr>)[^<]+(<))i, '\1[FILTERED]\2')
322
+ end
323
+
324
+ private
325
+
326
+ CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
327
+ CURRENCY_CODES['USD'] = '840'
328
+
329
+ def headers
330
+ {
331
+ 'Content-Type' => 'text/xml'
332
+ }
333
+ end
334
+
335
+ def commit(action, request)
336
+ request = add_transaction_code_to_request(request, action)
337
+
338
+ raw_response =
339
+ begin
340
+ ssl_post(url, request, headers)
341
+ rescue ActiveMerchant::ResponseError => e
342
+ e.response.body
343
+ end
344
+
345
+ response = parse(raw_response)
346
+
347
+ succeeded = success_from(response)
348
+
349
+ Response.new(
350
+ succeeded,
351
+ message_from(succeeded, response),
352
+ response,
353
+ error_code: error_code_from(succeeded, response),
354
+ authorization: authorization_from(action, response),
355
+ avs_result: AVSResult.new(code: response['avsRslt']),
356
+ cvv_result: CVVResult.new(response['secRslt']),
357
+ test: test?
358
+ )
359
+ end
360
+
361
+ def url
362
+ test? ? test_url : live_url
363
+ end
364
+
365
+ def parse(xml)
366
+ response = {}
367
+ doc = Nokogiri::XML(xml).remove_namespaces!
368
+
369
+ doc.css('Envelope Body *').each do |node|
370
+ # node.name is more readable, but uniq_name is occasionally necessary
371
+ uniq_name = [node.parent.name, node.name].join('_')
372
+ response[uniq_name] = node.text
373
+ response[node.name] = node.text
374
+ end
375
+
376
+ response
377
+ end
378
+
379
+ def success_from(response)
380
+ fault = response['Fault']
381
+ approved_transaction = APPROVAL_CODES.include?(response['rspCode'])
382
+ found_contact = response['FndRecurrProfResponse']
383
+
384
+ return !fault && (approved_transaction || found_contact)
385
+ end
386
+
387
+ def error_code_from(succeeded, response)
388
+ return if succeeded
389
+
390
+ response['errorCode'] || response['rspCode']
391
+ end
392
+
393
+ def message_from(succeeded, response)
394
+ return 'Succeeded' if succeeded
395
+
396
+ if response['rspCode']
397
+ code = response['rspCode']
398
+ extended_code = response['extRspCode']
399
+
400
+ message = RESPONSE_MESSAGES[code]
401
+ extended = EXTENDED_RESPONSE_MESSAGES[extended_code]
402
+ ach_response = response['achResponse']
403
+
404
+ [message, extended, ach_response].compact.join('. ')
405
+ else
406
+ response['faultstring']
407
+ end
408
+ end
409
+
410
+ def authorization_from(action, response)
411
+ authorization = response['tranNr'] || response['pmtId']
412
+
413
+ # guard so we don't return something like "purchase|"
414
+ return unless authorization
415
+
416
+ [action, authorization].join(AUTHORIZATION_FIELD_SEPARATOR)
417
+ end
418
+
419
+ # -- helper methods ----------------------------------------------------
420
+ def credit_card?(payment_method)
421
+ payment_method.respond_to?(:verification_value)
422
+ end
423
+
424
+ def echeck?(payment_method)
425
+ payment_method.respond_to?(:routing_number)
426
+ end
427
+
428
+ def split_authorization(authorization)
429
+ authorization.split(AUTHORIZATION_FIELD_SEPARATOR)
430
+ end
431
+
432
+ def void_type(action)
433
+ action == 'purchase_echeck' ? :void_echeck : :"void_#{action}"
434
+ end
435
+
436
+ def refund_type(action)
437
+ action == 'purchase_echeck' ? :refund_echeck : :refund
438
+ end
439
+
440
+ # -- request methods ---------------------------------------------------
441
+ def build_xml_transaction_request
442
+ build_xml_request('SendTranRequest') do |doc|
443
+ yield doc
444
+ end
445
+ end
446
+
447
+ def build_xml_payment_storage_request
448
+ build_xml_request('UpdtRecurrProfRequest') do |doc|
449
+ yield doc
450
+ end
451
+ end
452
+
453
+ def build_xml_payment_update_request
454
+ merchant_product_type = 5 # credit card
455
+ build_xml_request('UpdtRecurrProfRequest', merchant_product_type) do |doc|
456
+ yield doc
457
+ end
458
+ end
459
+
460
+ def build_xml_payment_search_request
461
+ build_xml_request('FndRecurrProfRequest') do |doc|
462
+ yield doc
463
+ end
464
+ end
465
+
466
+ def build_xml_request(wrapper, merchant_product_type = nil)
467
+ Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
468
+ xml['soapenv'].Envelope('xmlns:soapenv' => SOAPENV_NAMESPACE) do
469
+ xml['soapenv'].Body do
470
+ xml['v1'].send(wrapper, 'xmlns:v1' => V1_NAMESPACE) do
471
+ add_merchant(xml)
472
+ yield(xml)
473
+ end
474
+ end
475
+ end
476
+ end.doc.root.to_xml
477
+ end
478
+
479
+ def add_transaction_code_to_request(request, action)
480
+ # store requests don't get a transaction code
481
+ return request if action == :store
482
+
483
+ doc = Nokogiri::XML::Document.parse(request)
484
+ merc_nodeset = doc.xpath('//v1:merc', 'v1' => V1_NAMESPACE)
485
+ merc_nodeset.after "<v1:tranCode>#{TRANSACTION_CODES[action]}</v1:tranCode>"
486
+ doc.root.to_xml
487
+ end
488
+
489
+ def add_merchant(doc, product_type = nil)
490
+ doc['v1'].merc do
491
+ doc['v1'].id @options[:gateway_id]
492
+ doc['v1'].regKey @options[:reg_key]
493
+ doc['v1'].inType '1'
494
+ doc['v1'].prodType product_type if product_type
495
+ end
496
+ end
497
+
498
+ def add_amount(doc, money)
499
+ doc['v1'].reqAmt amount(money)
500
+ end
501
+
502
+ def add_order_number(doc, options)
503
+ return unless options[:order_id]
504
+
505
+ doc['v1'].authReq {
506
+ doc['v1'].ordNr options[:order_id]
507
+ }
508
+ end
509
+
510
+ def add_credit_card(doc, payment_method)
511
+ doc['v1'].card {
512
+ doc['v1'].pan payment_method.number
513
+ doc['v1'].sec payment_method.verification_value if payment_method.verification_value?
514
+ doc['v1'].xprDt expiration_date(payment_method)
515
+ }
516
+ end
517
+
518
+ def add_echeck(doc, payment_method)
519
+ doc['v1'].achEcheck {
520
+ doc['v1'].bankRtNr payment_method.routing_number
521
+ doc['v1'].acctNr payment_method.account_number
522
+ }
523
+ end
524
+
525
+ def expiration_date(payment_method)
526
+ yy = format(payment_method.year, :two_digits)
527
+ mm = format(payment_method.month, :two_digits)
528
+ yy + mm
529
+ end
530
+
531
+ def add_pan(doc, payment_method)
532
+ doc['v1'].card do
533
+ doc['v1'].pan payment_method.number
534
+ end
535
+ end
536
+
537
+ def add_contact(doc, fullname, options)
538
+ doc['v1'].contact do
539
+ doc['v1'].fullName fullname unless fullname.blank?
540
+ doc['v1'].coName options[:company_name] if options[:company_name]
541
+ doc['v1'].title options[:title] if options[:title]
542
+
543
+ if (billing_address = options[:billing_address])
544
+ if billing_address[:phone]
545
+ doc['v1'].phone do
546
+ doc['v1'].type(options[:phone_number_type] || '4')
547
+ doc['v1'].nr billing_address[:phone].gsub(/\D/, '')
548
+ end
549
+ end
550
+ doc['v1'].addrLn1 billing_address[:address1] if billing_address[:address1]
551
+ doc['v1'].addrLn2 billing_address[:address2] unless billing_address[:address2].blank?
552
+ doc['v1'].city billing_address[:city] if billing_address[:city]
553
+ doc['v1'].state billing_address[:state] if billing_address[:state]
554
+ doc['v1'].zipCode billing_address[:zip].delete('-') if billing_address[:zip]
555
+ doc['v1'].ctry 'US'
556
+ end
557
+
558
+ doc['v1'].email options[:email] if options[:email]
559
+ doc['v1'].type options[:contact_type] if options[:contact_type]
560
+ doc['v1'].stat options[:contact_stat] if options[:contact_stat]
561
+
562
+ if (shipping_address = options[:shipping_address])
563
+ doc['v1'].ship do
564
+ doc['v1'].fullName fullname unless fullname.blank?
565
+ doc['v1'].addrLn1 shipping_address[:address1] if shipping_address[:address1]
566
+ doc['v1'].addrLn2 shipping_address[:address2] unless shipping_address[:address2].blank?
567
+ doc['v1'].city shipping_address[:city] if shipping_address[:city]
568
+ doc['v1'].state shipping_address[:state] if shipping_address[:state]
569
+ doc['v1'].zipCode shipping_address[:zip].delete('-') if shipping_address[:zip]
570
+ doc['v1'].phone shipping_address[:phone].gsub(/\D/, '') if shipping_address[:phone]
571
+ doc['v1'].email shipping_address[:email] if shipping_address[:email]
572
+ end
573
+ end
574
+ end
575
+ end
576
+
577
+ def add_name(doc, payment_method)
578
+ doc['v1'].contact do
579
+ doc['v1'].fullName payment_method.name unless payment_method.name.blank?
580
+ end
581
+ end
582
+
583
+ def add_original_transaction_data(doc, authorization)
584
+ doc['v1'].origTranData do
585
+ doc['v1'].tranNr authorization
586
+ end
587
+ end
588
+
589
+ def store_customer_details(doc, fullname, options)
590
+ options[:contact_type] = 1 # recurring
591
+ options[:contact_stat] = 1 # active
592
+
593
+ doc['v1'].cust do
594
+ doc['v1'].type 0 # add
595
+ add_contact(doc, fullname, options)
596
+ end
597
+ end
598
+
599
+ def add_customer_id(doc, customer_id)
600
+ doc['v1'].contact do
601
+ doc['v1'].id customer_id
602
+ end
603
+ end
604
+
605
+ def add_wallet_id(doc, wallet_id)
606
+ doc['v1'].recurMan do
607
+ doc['v1'].id wallet_id
608
+ end
609
+ end
610
+ end
611
+ end
612
+ end