activemerchant 1.42.6 → 1.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG +1420 -2
  3. data/CONTRIBUTORS +106 -0
  4. data/README.md +107 -103
  5. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  6. data/lib/active_merchant/billing/avs_result.rb +12 -13
  7. data/lib/active_merchant/billing/base.rb +13 -16
  8. data/lib/active_merchant/billing/check.rb +35 -24
  9. data/lib/active_merchant/billing/compatibility.rb +117 -0
  10. data/lib/active_merchant/billing/credit_card.rb +196 -81
  11. data/lib/active_merchant/billing/credit_card_formatting.rb +6 -4
  12. data/lib/active_merchant/billing/credit_card_methods.rb +199 -75
  13. data/lib/active_merchant/billing/cvv_result.rb +15 -15
  14. data/lib/active_merchant/billing/gateway.rb +171 -39
  15. data/lib/active_merchant/billing/gateways/adyen.rb +380 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +933 -604
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +74 -54
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  21. data/lib/active_merchant/billing/gateways/balanced.rb +130 -370
  22. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  23. data/lib/active_merchant/billing/gateways/banwire.rb +23 -12
  24. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +351 -0
  25. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +6 -6
  26. data/lib/active_merchant/billing/gateways/be2bill.rb +2 -2
  27. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +109 -32
  28. data/lib/active_merchant/billing/gateways/beanstream.rb +59 -13
  29. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +12 -9
  30. data/lib/active_merchant/billing/gateways/blue_pay.rb +520 -498
  31. data/lib/active_merchant/billing/gateways/blue_snap.rb +347 -0
  32. data/lib/active_merchant/billing/gateways/bogus.rb +80 -46
  33. data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
  34. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  35. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +15 -2
  36. data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
  37. data/lib/active_merchant/billing/gateways/braintree_blue.rb +311 -121
  38. data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -4
  39. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  40. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  41. data/lib/active_merchant/billing/gateways/card_connect.rb +311 -0
  42. data/lib/active_merchant/billing/gateways/card_save.rb +6 -7
  43. data/lib/active_merchant/billing/gateways/card_stream.rb +235 -89
  44. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  45. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  46. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
  47. data/lib/active_merchant/billing/gateways/cc5.rb +50 -8
  48. data/lib/active_merchant/billing/gateways/cecabank.rb +27 -14
  49. data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  51. data/lib/active_merchant/billing/gateways/checkout_v2.rb +233 -0
  52. data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
  53. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  54. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  55. data/lib/active_merchant/billing/gateways/conekta.rb +91 -97
  56. data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
  57. data/lib/active_merchant/billing/gateways/credorax.rb +356 -0
  58. data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
  59. data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
  60. data/lib/active_merchant/billing/gateways/cyber_source.rb +294 -158
  61. data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
  62. data/lib/active_merchant/billing/gateways/data_cash.rb +59 -347
  63. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  64. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  65. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  66. data/lib/active_merchant/billing/gateways/efsnet.rb +24 -39
  67. data/lib/active_merchant/billing/gateways/elavon.rb +146 -147
  68. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  69. data/lib/active_merchant/billing/gateways/epay.rb +41 -31
  70. data/lib/active_merchant/billing/gateways/evo_ca.rb +1 -1
  71. data/lib/active_merchant/billing/gateways/eway.rb +79 -78
  72. data/lib/active_merchant/billing/gateways/eway_managed.rb +35 -36
  73. data/lib/active_merchant/billing/gateways/eway_rapid.rb +369 -228
  74. data/lib/active_merchant/billing/gateways/exact.rb +32 -26
  75. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  76. data/lib/active_merchant/billing/gateways/fat_zebra.rb +90 -64
  77. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -14
  78. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
  79. data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
  80. data/lib/active_merchant/billing/gateways/first_pay.rb +128 -122
  81. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +190 -64
  82. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +446 -0
  83. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  84. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  85. data/lib/active_merchant/billing/gateways/forte.rb +270 -0
  86. data/lib/active_merchant/billing/gateways/garanti.rb +29 -27
  87. data/lib/active_merchant/billing/gateways/global_collect.rb +340 -0
  88. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  89. data/lib/active_merchant/billing/gateways/hdfc.rb +35 -36
  90. data/lib/active_merchant/billing/gateways/hps.rb +305 -0
  91. data/lib/active_merchant/billing/gateways/iats_payments.rb +271 -16
  92. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  93. data/lib/active_merchant/billing/gateways/inspire.rb +29 -32
  94. data/lib/active_merchant/billing/gateways/instapay.rb +5 -6
  95. data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
  96. data/lib/active_merchant/billing/gateways/iridium.rb +247 -41
  97. data/lib/active_merchant/billing/gateways/itransact.rb +4 -5
  98. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  99. data/lib/active_merchant/billing/gateways/jetpay.rb +198 -71
  100. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  101. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  102. data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
  103. data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
  104. data/lib/active_merchant/billing/gateways/linkpoint.rb +45 -43
  105. data/lib/active_merchant/billing/gateways/litle.rb +328 -444
  106. data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
  107. data/lib/active_merchant/billing/gateways/maxipago.rb +145 -115
  108. data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
  109. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +37 -19
  110. data/lib/active_merchant/billing/gateways/merchant_one.rb +13 -15
  111. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  112. data/lib/active_merchant/billing/gateways/merchant_ware.rb +57 -60
  113. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +59 -48
  114. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +38 -19
  115. data/lib/active_merchant/billing/gateways/mercury.rb +77 -54
  116. data/lib/active_merchant/billing/gateways/metrics_global.rb +11 -30
  117. data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
  118. data/lib/active_merchant/billing/gateways/migs.rb +81 -22
  119. data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
  120. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +23 -25
  121. data/lib/active_merchant/billing/gateways/monei.rb +307 -0
  122. data/lib/active_merchant/billing/gateways/moneris.rb +146 -64
  123. data/lib/active_merchant/billing/gateways/moneris_us.rb +197 -53
  124. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -15
  125. data/lib/active_merchant/billing/gateways/mundipagg.rb +292 -0
  126. data/lib/active_merchant/billing/gateways/nab_transact.rb +86 -64
  127. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  128. data/lib/active_merchant/billing/gateways/net_registry.rb +11 -5
  129. data/lib/active_merchant/billing/gateways/netaxept.rb +21 -22
  130. data/lib/active_merchant/billing/gateways/netbanx.rb +290 -0
  131. data/lib/active_merchant/billing/gateways/netbilling.rb +70 -35
  132. data/lib/active_merchant/billing/gateways/netpay.rb +5 -6
  133. data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
  134. data/lib/active_merchant/billing/gateways/nmi.rb +274 -10
  135. data/lib/active_merchant/billing/gateways/ogone.rb +90 -47
  136. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  137. data/lib/active_merchant/billing/gateways/openpay.rb +48 -20
  138. data/lib/active_merchant/billing/gateways/opp.rb +369 -0
  139. data/lib/active_merchant/billing/gateways/optimal_payment.rb +79 -44
  140. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
  141. data/lib/active_merchant/billing/gateways/orbital.rb +346 -102
  142. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +48 -29
  143. data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
  144. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  145. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  146. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +67 -48
  147. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  148. data/lib/active_merchant/billing/gateways/pay_junction.rb +20 -26
  149. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +188 -0
  150. data/lib/active_merchant/billing/gateways/pay_secure.rb +7 -15
  151. data/lib/active_merchant/billing/gateways/paybox_direct.rb +40 -36
  152. data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
  153. data/lib/active_merchant/billing/gateways/payex.rb +38 -30
  154. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +62 -36
  155. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -7
  156. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  157. data/lib/active_merchant/billing/gateways/payflow.rb +74 -27
  158. data/lib/active_merchant/billing/gateways/payflow_express.rb +77 -81
  159. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
  160. data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
  161. data/lib/active_merchant/billing/gateways/payment_express.rb +54 -45
  162. data/lib/active_merchant/billing/gateways/paymentez.rb +304 -0
  163. data/lib/active_merchant/billing/gateways/paymill.rb +160 -66
  164. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +54 -7
  165. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  166. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +17 -3
  167. data/lib/active_merchant/billing/gateways/paypal.rb +36 -27
  168. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  169. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +7 -6
  170. data/lib/active_merchant/billing/gateways/paypal_express.rb +32 -4
  171. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  172. data/lib/active_merchant/billing/gateways/payscout.rb +2 -13
  173. data/lib/active_merchant/billing/gateways/paystation.rb +96 -88
  174. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  175. data/lib/active_merchant/billing/gateways/payu_latam.rb +445 -0
  176. data/lib/active_merchant/billing/gateways/payway.rb +8 -8
  177. data/lib/active_merchant/billing/gateways/pin.rb +74 -18
  178. data/lib/active_merchant/billing/gateways/plugnpay.rb +66 -76
  179. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  180. data/lib/active_merchant/billing/gateways/psigate.rb +30 -30
  181. data/lib/active_merchant/billing/gateways/psl_card.rb +27 -34
  182. data/lib/active_merchant/billing/gateways/qbms.rb +65 -54
  183. data/lib/active_merchant/billing/gateways/quantum.rb +18 -18
  184. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  185. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  186. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +295 -0
  187. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  188. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -350
  189. data/lib/active_merchant/billing/gateways/qvalent.rb +236 -0
  190. data/lib/active_merchant/billing/gateways/realex.rb +78 -48
  191. data/lib/active_merchant/billing/gateways/redsys.rb +310 -170
  192. data/lib/active_merchant/billing/gateways/s5.rb +246 -0
  193. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  194. data/lib/active_merchant/billing/gateways/sage.rb +415 -119
  195. data/lib/active_merchant/billing/gateways/sage_pay.rb +195 -90
  196. data/lib/active_merchant/billing/gateways/sallie_mae.rb +11 -12
  197. data/lib/active_merchant/billing/gateways/secure_net.rb +51 -43
  198. data/lib/active_merchant/billing/gateways/secure_pay.rb +182 -10
  199. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +25 -14
  200. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +10 -18
  201. data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
  202. data/lib/active_merchant/billing/gateways/skip_jack.rb +35 -38
  203. data/lib/active_merchant/billing/gateways/smart_ps.rb +50 -42
  204. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +9 -9
  205. data/lib/active_merchant/billing/gateways/spreedly_core.rb +62 -12
  206. data/lib/active_merchant/billing/gateways/stripe.rb +536 -103
  207. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +12 -18
  208. data/lib/active_merchant/billing/gateways/telr.rb +274 -0
  209. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  210. data/lib/active_merchant/billing/gateways/trans_first.rb +143 -30
  211. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  212. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  213. data/lib/active_merchant/billing/gateways/transax.rb +5 -6
  214. data/lib/active_merchant/billing/gateways/transnational.rb +2 -232
  215. data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
  216. data/lib/active_merchant/billing/gateways/trust_commerce.rb +86 -57
  217. data/lib/active_merchant/billing/gateways/usa_epay.rb +4 -4
  218. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +196 -89
  219. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +157 -32
  220. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  221. data/lib/active_merchant/billing/gateways/verifi.rb +42 -49
  222. data/lib/active_merchant/billing/gateways/viaklix.rb +11 -24
  223. data/lib/active_merchant/billing/gateways/visanet_peru.rb +233 -0
  224. data/lib/active_merchant/billing/gateways/webpay.rb +26 -28
  225. data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
  226. data/lib/active_merchant/billing/gateways/wirecard.rb +153 -31
  227. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  228. data/lib/active_merchant/billing/gateways/worldpay.rb +207 -63
  229. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
  230. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  231. data/lib/active_merchant/billing/gateways.rb +8 -11
  232. data/lib/active_merchant/billing/model.rb +30 -0
  233. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  234. data/lib/active_merchant/billing/payment_token.rb +21 -0
  235. data/lib/active_merchant/billing/rails.rb +3 -0
  236. data/lib/active_merchant/billing/response.rb +31 -24
  237. data/lib/active_merchant/billing.rb +7 -1
  238. data/lib/active_merchant/connection.rb +195 -0
  239. data/lib/active_merchant/country.rb +335 -0
  240. data/lib/active_merchant/empty.rb +20 -0
  241. data/lib/active_merchant/errors.rb +35 -0
  242. data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
  243. data/lib/active_merchant/network_connection_retries.rb +80 -0
  244. data/lib/active_merchant/post_data.rb +25 -0
  245. data/lib/active_merchant/posts_data.rb +92 -0
  246. data/lib/active_merchant/version.rb +1 -1
  247. data/lib/active_merchant.rb +23 -27
  248. data/lib/activemerchant.rb +1 -1
  249. data/lib/certs/cacert.pem +3988 -0
  250. data/lib/support/gateway_support.rb +7 -9
  251. data/lib/support/outbound_hosts.rb +13 -10
  252. data/lib/support/ssl_verify.rb +6 -7
  253. data/lib/support/ssl_version.rb +87 -0
  254. metadata +148 -323
  255. checksums.yaml.gz.sig +0 -0
  256. data/gem-public_cert.pem +0 -21
  257. data/lib/active_merchant/billing/expiry_date.rb +0 -34
  258. data/lib/active_merchant/billing/gateways/app55.rb +0 -185
  259. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  260. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -277
  261. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -249
  262. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  263. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  264. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  265. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
  266. data/lib/active_merchant/billing/gateways/orbital/cvv_result.rb +0 -34
  267. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -93
  268. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  269. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  270. data/lib/active_merchant/billing/gateways/samurai.rb +0 -118
  271. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -361
  272. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
  273. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
  274. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
  275. data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
  276. data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -74
  277. data/lib/active_merchant/billing/integrations/alipay/helper.rb +0 -34
  278. data/lib/active_merchant/billing/integrations/alipay/notification.rb +0 -101
  279. data/lib/active_merchant/billing/integrations/alipay.rb +0 -18
  280. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
  281. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
  282. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
  283. data/lib/active_merchant/billing/integrations/bit_pay/helper.rb +0 -64
  284. data/lib/active_merchant/billing/integrations/bit_pay/notification.rb +0 -74
  285. data/lib/active_merchant/billing/integrations/bit_pay/return.rb +0 -10
  286. data/lib/active_merchant/billing/integrations/bit_pay.rb +0 -30
  287. data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
  288. data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
  289. data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
  290. data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
  291. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
  292. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
  293. data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
  294. data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
  295. data/lib/active_merchant/billing/integrations/citrus/helper.rb +0 -40
  296. data/lib/active_merchant/billing/integrations/citrus/notification.rb +0 -133
  297. data/lib/active_merchant/billing/integrations/citrus/return.rb +0 -40
  298. data/lib/active_merchant/billing/integrations/citrus.rb +0 -51
  299. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
  300. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
  301. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
  302. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
  303. data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
  304. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
  305. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
  306. data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
  307. data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
  308. data/lib/active_merchant/billing/integrations/doku/helper.rb +0 -102
  309. data/lib/active_merchant/billing/integrations/doku/notification.rb +0 -69
  310. data/lib/active_merchant/billing/integrations/doku/return.rb +0 -10
  311. data/lib/active_merchant/billing/integrations/doku.rb +0 -24
  312. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
  313. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
  314. data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
  315. data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
  316. data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
  317. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
  318. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
  319. data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
  320. data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
  321. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
  322. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
  323. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
  324. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
  325. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
  326. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
  327. data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
  328. data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
  329. data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
  330. data/lib/active_merchant/billing/integrations/epay.rb +0 -21
  331. data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
  332. data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
  333. data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
  334. data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
  335. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
  336. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
  337. data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
  338. data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
  339. data/lib/active_merchant/billing/integrations/helper.rb +0 -117
  340. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
  341. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
  342. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
  343. data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
  344. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -118
  345. data/lib/active_merchant/billing/integrations/ipay88/notification.rb +0 -103
  346. data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -29
  347. data/lib/active_merchant/billing/integrations/ipay88.rb +0 -23
  348. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
  349. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
  350. data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
  351. data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
  352. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
  353. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
  354. data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
  355. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
  356. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -123
  357. data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
  358. data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
  359. data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
  360. data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
  361. data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
  362. data/lib/active_merchant/billing/integrations/notification.rb +0 -71
  363. data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
  364. data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
  365. data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
  366. data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
  367. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
  368. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
  369. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
  370. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
  371. data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
  372. data/lib/active_merchant/billing/integrations/paydollar/helper.rb +0 -41
  373. data/lib/active_merchant/billing/integrations/paydollar/notification.rb +0 -60
  374. data/lib/active_merchant/billing/integrations/paydollar/return.rb +0 -15
  375. data/lib/active_merchant/billing/integrations/paydollar.rb +0 -59
  376. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
  377. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
  378. data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
  379. data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
  380. data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
  381. data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
  382. data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
  383. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
  384. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
  385. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
  386. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -39
  387. data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
  388. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -76
  389. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -154
  390. data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
  391. data/lib/active_merchant/billing/integrations/payu_in.rb +0 -36
  392. data/lib/active_merchant/billing/integrations/payu_in_paisa/helper.rb +0 -19
  393. data/lib/active_merchant/billing/integrations/payu_in_paisa/notification.rb +0 -13
  394. data/lib/active_merchant/billing/integrations/payu_in_paisa/return.rb +0 -16
  395. data/lib/active_merchant/billing/integrations/payu_in_paisa.rb +0 -30
  396. data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
  397. data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
  398. data/lib/active_merchant/billing/integrations/platron.rb +0 -28
  399. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -112
  400. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
  401. data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
  402. data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
  403. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -96
  404. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
  405. data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
  406. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
  407. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
  408. data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
  409. data/lib/active_merchant/billing/integrations/return.rb +0 -42
  410. data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
  411. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
  412. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
  413. data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
  414. data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
  415. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
  416. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
  417. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
  418. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
  419. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
  420. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -107
  421. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -171
  422. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -58
  423. data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
  424. data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
  425. data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
  426. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
  427. data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
  428. data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
  429. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
  430. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
  431. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
  432. data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
  433. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
  434. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
  435. data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
  436. data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
  437. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
  438. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
  439. data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
  440. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/common.rb +0 -104
  441. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb +0 -145
  442. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb +0 -101
  443. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/return.rb +0 -35
  444. data/lib/active_merchant/billing/integrations/wirecard_checkout_page.rb +0 -39
  445. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
  446. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
  447. data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
  448. data/lib/active_merchant/billing/integrations.rb +0 -17
  449. data.tar.gz.sig +0 -0
  450. metadata.gz.sig +0 -1
@@ -0,0 +1,608 @@
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 = [: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
+ customer_id = r.params['custId']
295
+
296
+ store_payment_method_request = build_xml_payment_storage_request do |doc|
297
+ doc['v1'].cust do
298
+ add_customer_id(doc, customer_id)
299
+ doc['v1'].pmt do
300
+ doc['v1'].type 0 # add
301
+ add_credit_card(doc, payment_method)
302
+ end
303
+ end
304
+ end
305
+
306
+ r.process { commit(:store, store_payment_method_request) }
307
+ end
308
+ end
309
+
310
+ def supports_scrubbing?
311
+ true
312
+ end
313
+
314
+ def scrub(transcript)
315
+ transcript.
316
+ gsub(%r((<[^>]+pan>)[^<]+(<))i, '\1[FILTERED]\2').
317
+ gsub(%r((<[^>]+sec>)[^<]+(<))i, '\1[FILTERED]\2').
318
+ gsub(%r((<[^>]+id>)[^<]+(<))i, '\1[FILTERED]\2').
319
+ gsub(%r((<[^>]+regKey>)[^<]+(<))i, '\1[FILTERED]\2')
320
+ end
321
+
322
+ private
323
+
324
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
325
+ CURRENCY_CODES['USD'] = '840'
326
+
327
+ def headers
328
+ {
329
+ 'Content-Type' => 'text/xml'
330
+ }
331
+ end
332
+
333
+ def commit(action, request)
334
+ request = add_transaction_code_to_request(request, action)
335
+
336
+ raw_response = begin
337
+ ssl_post(url, request, headers)
338
+ rescue ActiveMerchant::ResponseError => e
339
+ e.response.body
340
+ end
341
+
342
+ response = parse(raw_response)
343
+
344
+ succeeded = success_from(response)
345
+
346
+ Response.new(
347
+ succeeded,
348
+ message_from(succeeded, response),
349
+ response,
350
+ error_code: error_code_from(succeeded, response),
351
+ authorization: authorization_from(action, response),
352
+ avs_result: AVSResult.new(code: response['avsRslt']),
353
+ cvv_result: CVVResult.new(response['secRslt']),
354
+ test: test?
355
+ )
356
+ end
357
+
358
+ def url
359
+ test? ? test_url : live_url
360
+ end
361
+
362
+ def parse(xml)
363
+ response = {}
364
+ doc = Nokogiri::XML(xml).remove_namespaces!
365
+
366
+ doc.css('Envelope Body *').each do |node|
367
+ # node.name is more readable, but uniq_name is occasionally necessary
368
+ uniq_name = [node.parent.name, node.name].join('_')
369
+ response[uniq_name] = node.text
370
+ response[node.name] = node.text
371
+ end
372
+
373
+ response
374
+ end
375
+
376
+ def success_from(response)
377
+ fault = response['Fault']
378
+ approved_transaction = APPROVAL_CODES.include?(response['rspCode'])
379
+ found_contact = response['FndRecurrProfResponse']
380
+
381
+ return !fault && (approved_transaction || found_contact)
382
+ end
383
+
384
+ def error_code_from(succeeded, response)
385
+ return if succeeded
386
+ response['errorCode'] || response['rspCode']
387
+ end
388
+
389
+ def message_from(succeeded, response)
390
+ return 'Succeeded' if succeeded
391
+
392
+ if response['rspCode']
393
+ code = response['rspCode']
394
+ extended_code = response['extRspCode']
395
+
396
+ message = RESPONSE_MESSAGES[code]
397
+ extended = EXTENDED_RESPONSE_MESSAGES[extended_code]
398
+ ach_response = response['achResponse']
399
+
400
+ [message, extended, ach_response].compact.join('. ')
401
+ else
402
+ response['faultstring']
403
+ end
404
+ end
405
+
406
+ def authorization_from(action, response)
407
+ authorization = response['tranNr'] || response['pmtId']
408
+
409
+ # guard so we don't return something like "purchase|"
410
+ return unless authorization
411
+
412
+ [action, authorization].join(AUTHORIZATION_FIELD_SEPARATOR)
413
+ end
414
+
415
+ # -- helper methods ----------------------------------------------------
416
+ def credit_card?(payment_method)
417
+ payment_method.respond_to?(:verification_value)
418
+ end
419
+
420
+ def echeck?(payment_method)
421
+ payment_method.respond_to?(:routing_number)
422
+ end
423
+
424
+ def split_authorization(authorization)
425
+ authorization.split(AUTHORIZATION_FIELD_SEPARATOR)
426
+ end
427
+
428
+ def void_type(action)
429
+ action == 'purchase_echeck' ? :void_echeck : :"void_#{action}"
430
+ end
431
+
432
+ def refund_type(action)
433
+ action == 'purchase_echeck' ? :refund_echeck : :refund
434
+ end
435
+
436
+ # -- request methods ---------------------------------------------------
437
+ def build_xml_transaction_request
438
+ build_xml_request('SendTranRequest') do |doc|
439
+ yield doc
440
+ end
441
+ end
442
+
443
+ def build_xml_payment_storage_request
444
+ build_xml_request('UpdtRecurrProfRequest') do |doc|
445
+ yield doc
446
+ end
447
+ end
448
+
449
+ def build_xml_payment_update_request
450
+ merchant_product_type = 5 # credit card
451
+ build_xml_request('UpdtRecurrProfRequest', merchant_product_type) do |doc|
452
+ yield doc
453
+ end
454
+ end
455
+
456
+ def build_xml_payment_search_request
457
+ build_xml_request('FndRecurrProfRequest') do |doc|
458
+ yield doc
459
+ end
460
+ end
461
+
462
+ def build_xml_request(wrapper, merchant_product_type=nil)
463
+ Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
464
+ xml['soapenv'].Envelope('xmlns:soapenv' => SOAPENV_NAMESPACE) do
465
+ xml['soapenv'].Body do
466
+ xml['v1'].send(wrapper, 'xmlns:v1' => V1_NAMESPACE) do
467
+ add_merchant(xml)
468
+ yield(xml)
469
+ end
470
+ end
471
+ end
472
+ end.doc.root.to_xml
473
+ end
474
+
475
+ def add_transaction_code_to_request(request, action)
476
+ # store requests don't get a transaction code
477
+ return request if action == :store
478
+
479
+ doc = Nokogiri::XML::Document.parse(request)
480
+ merc_nodeset = doc.xpath('//v1:merc', 'v1' => V1_NAMESPACE)
481
+ merc_nodeset.after "<tranCode>#{TRANSACTION_CODES[action]}</tranCode>"
482
+ doc.root.to_xml
483
+ end
484
+
485
+ def add_merchant(doc, product_type=nil)
486
+ doc['v1'].merc do
487
+ doc['v1'].id @options[:gateway_id]
488
+ doc['v1'].regKey @options[:reg_key]
489
+ doc['v1'].inType '1'
490
+ doc['v1'].prodType product_type if product_type
491
+ end
492
+ end
493
+
494
+ def add_amount(doc, money)
495
+ doc['v1'].reqAmt amount(money)
496
+ end
497
+
498
+ def add_order_number(doc, options)
499
+ return unless options[:order_id]
500
+
501
+ doc['v1'].authReq {
502
+ doc['v1'].ordNr options[:order_id]
503
+ }
504
+ end
505
+
506
+ def add_credit_card(doc, payment_method)
507
+ doc['v1'].card {
508
+ doc['v1'].pan payment_method.number
509
+ doc['v1'].sec payment_method.verification_value if payment_method.verification_value?
510
+ doc['v1'].xprDt expiration_date(payment_method)
511
+ }
512
+ end
513
+
514
+ def add_echeck(doc, payment_method)
515
+ doc['v1'].achEcheck {
516
+ doc['v1'].bankRtNr payment_method.routing_number
517
+ doc['v1'].acctNr payment_method.account_number
518
+ }
519
+ end
520
+
521
+ def expiration_date(payment_method)
522
+ yy = format(payment_method.year, :two_digits)
523
+ mm = format(payment_method.month, :two_digits)
524
+ yy + mm
525
+ end
526
+
527
+ def add_pan(doc, payment_method)
528
+ doc['v1'].card do
529
+ doc['v1'].pan payment_method.number
530
+ end
531
+ end
532
+
533
+ def add_contact(doc, fullname, options)
534
+ doc['v1'].contact do
535
+ doc['v1'].fullName fullname
536
+ doc['v1'].coName options[:company_name] if options[:company_name]
537
+ doc['v1'].title options[:title] if options[:title]
538
+
539
+ if (billing_address = options[:billing_address])
540
+ if billing_address[:phone]
541
+ doc['v1'].phone do
542
+ doc['v1'].type(options[:phone_number_type] || '4')
543
+ doc['v1'].nr billing_address[:phone].gsub(/\D/, '')
544
+ end
545
+ end
546
+ doc['v1'].addrLn1 billing_address[:address1] if billing_address[:address1]
547
+ doc['v1'].addrLn2 billing_address[:address2] if billing_address[:address2]
548
+ doc['v1'].city billing_address[:city] if billing_address[:city]
549
+ doc['v1'].state billing_address[:state] if billing_address[:state]
550
+ doc['v1'].zipCode billing_address[:zip] if billing_address[:zip]
551
+ doc['v1'].ctry 'US'
552
+ end
553
+
554
+ doc['v1'].email options[:email] if options[:email]
555
+ doc['v1'].type options[:contact_type] if options[:contact_type]
556
+ doc['v1'].stat options[:contact_stat] if options[:contact_stat]
557
+
558
+ if (shipping_address = options[:shipping_address])
559
+ doc['v1'].ship do
560
+ doc['v1'].fullName fullname
561
+ doc['v1'].addrLn1 shipping_address[:address1] if shipping_address[:address1]
562
+ doc['v1'].addrLn2 shipping_address[:address2] if shipping_address[:address2]
563
+ doc['v1'].city shipping_address[:city] if shipping_address[:city]
564
+ doc['v1'].state shipping_address[:state] if shipping_address[:state]
565
+ doc['v1'].zipCode shipping_address[:zip] if shipping_address[:zip]
566
+ doc['v1'].phone shipping_address[:phone].gsub(/\D/, '') if shipping_address[:phone]
567
+ doc['v1'].email shipping_address[:email] if shipping_address[:email]
568
+ end
569
+ end
570
+ end
571
+ end
572
+
573
+ def add_name(doc, payment_method)
574
+ doc['v1'].contact do
575
+ doc['v1'].fullName payment_method.name
576
+ end
577
+ end
578
+
579
+ def add_original_transaction_data(doc, authorization)
580
+ doc['v1'].origTranData do
581
+ doc['v1'].tranNr authorization
582
+ end
583
+ end
584
+
585
+ def store_customer_details(doc, fullname, options)
586
+ options[:contact_type] = 1 # recurring
587
+ options[:contact_stat] = 1 # active
588
+
589
+ doc['v1'].cust do
590
+ doc['v1'].type 0 # add
591
+ add_contact(doc, fullname, options)
592
+ end
593
+ end
594
+
595
+ def add_customer_id(doc, customer_id)
596
+ doc['v1'].contact do
597
+ doc['v1'].id customer_id
598
+ end
599
+ end
600
+
601
+ def add_wallet_id(doc, wallet_id)
602
+ doc['v1'].recurMan do
603
+ doc['v1'].id wallet_id
604
+ end
605
+ end
606
+ end
607
+ end
608
+ end