activemerchant 1.38.0 → 1.79.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (400) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +1402 -3
  3. data/CONTRIBUTORS +154 -0
  4. data/README.md +157 -144
  5. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  6. data/lib/active_merchant/billing/base.rb +21 -17
  7. data/lib/active_merchant/billing/check.rb +32 -22
  8. data/lib/active_merchant/billing/compatibility.rb +120 -0
  9. data/lib/active_merchant/billing/credit_card.rb +215 -67
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -1
  11. data/lib/active_merchant/billing/credit_card_methods.rb +152 -53
  12. data/lib/active_merchant/billing/cvv_result.rb +15 -15
  13. data/lib/active_merchant/billing/gateway.rb +170 -24
  14. data/lib/active_merchant/billing/gateways/adyen.rb +299 -0
  15. data/lib/active_merchant/billing/gateways/allied_wallet.rb +206 -0
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +904 -606
  17. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +43 -18
  19. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  20. data/lib/active_merchant/billing/gateways/balanced.rb +134 -346
  21. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  22. data/lib/active_merchant/billing/gateways/banwire.rb +13 -2
  23. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +326 -0
  24. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  25. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +96 -15
  26. data/lib/active_merchant/billing/gateways/beanstream.rb +52 -9
  27. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +12 -8
  28. data/lib/active_merchant/billing/gateways/blue_pay.rb +520 -501
  29. data/lib/active_merchant/billing/gateways/blue_snap.rb +343 -0
  30. data/lib/active_merchant/billing/gateways/bogus.rb +94 -50
  31. data/lib/active_merchant/billing/gateways/borgun.rb +221 -0
  32. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  33. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +15 -2
  34. data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -139
  36. data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -4
  37. data/lib/active_merchant/billing/gateways/bridge_pay.rb +245 -0
  38. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  39. data/lib/active_merchant/billing/gateways/card_connect.rb +286 -0
  40. data/lib/active_merchant/billing/gateways/card_stream.rb +269 -118
  41. data/lib/active_merchant/billing/gateways/cardknox.rb +328 -0
  42. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  43. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
  44. data/lib/active_merchant/billing/gateways/cc5.rb +45 -0
  45. data/lib/active_merchant/billing/gateways/cecabank.rb +239 -0
  46. data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  48. data/lib/active_merchant/billing/gateways/checkout_v2.rb +233 -0
  49. data/lib/active_merchant/billing/gateways/citrus_pay.rb +23 -0
  50. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  51. data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
  52. data/lib/active_merchant/billing/gateways/conekta.rb +225 -0
  53. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  54. data/lib/active_merchant/billing/gateways/credorax.rb +345 -0
  55. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  56. data/lib/active_merchant/billing/gateways/cyber_source.rb +237 -98
  57. data/lib/active_merchant/billing/gateways/data_cash.rb +41 -314
  58. data/lib/active_merchant/billing/gateways/dibs.rb +205 -0
  59. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  60. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  61. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -14
  62. data/lib/active_merchant/billing/gateways/elavon.rb +143 -142
  63. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  64. data/lib/active_merchant/billing/gateways/epay.rb +23 -12
  65. data/lib/active_merchant/billing/gateways/eway.rb +12 -12
  66. data/lib/active_merchant/billing/gateways/eway_managed.rb +1 -1
  67. data/lib/active_merchant/billing/gateways/eway_rapid.rb +417 -204
  68. data/lib/active_merchant/billing/gateways/exact.rb +10 -1
  69. data/lib/active_merchant/billing/gateways/ezic.rb +196 -0
  70. data/lib/active_merchant/billing/gateways/fat_zebra.rb +65 -37
  71. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -8
  72. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -2
  73. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  74. data/lib/active_merchant/billing/gateways/first_pay.rb +110 -124
  75. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +155 -29
  76. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  78. data/lib/active_merchant/billing/gateways/forte.rb +256 -0
  79. data/lib/active_merchant/billing/gateways/garanti.rb +11 -5
  80. data/lib/active_merchant/billing/gateways/global_collect.rb +334 -0
  81. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  82. data/lib/active_merchant/billing/gateways/hps.rb +305 -0
  83. data/lib/active_merchant/billing/gateways/iats_payments.rb +271 -16
  84. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +2 -5
  85. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -0
  86. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +1 -1
  87. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  88. data/lib/active_merchant/billing/gateways/inspire.rb +8 -10
  89. data/lib/active_merchant/billing/gateways/instapay.rb +0 -0
  90. data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
  91. data/lib/active_merchant/billing/gateways/iridium.rb +210 -4
  92. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  93. data/lib/active_merchant/billing/gateways/jetpay.rb +176 -49
  94. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  95. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  96. data/lib/active_merchant/billing/gateways/kushki.rb +227 -0
  97. data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
  98. data/lib/active_merchant/billing/gateways/linkpoint.rb +17 -13
  99. data/lib/active_merchant/billing/gateways/litle.rb +329 -439
  100. data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
  101. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  102. data/lib/active_merchant/billing/gateways/mercado_pago.rb +262 -0
  103. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +26 -7
  104. data/lib/active_merchant/billing/gateways/merchant_one.rb +0 -1
  105. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  106. data/lib/active_merchant/billing/gateways/merchant_ware.rb +12 -15
  107. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +24 -13
  108. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +33 -14
  109. data/lib/active_merchant/billing/gateways/mercury.rb +74 -29
  110. data/lib/active_merchant/billing/gateways/metrics_global.rb +2 -21
  111. data/lib/active_merchant/billing/gateways/micropayment.rb +185 -0
  112. data/lib/active_merchant/billing/gateways/migs.rb +73 -14
  113. data/lib/active_merchant/billing/gateways/modern_payments.rb +1 -1
  114. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +1 -3
  115. data/lib/active_merchant/billing/gateways/monei.rb +307 -0
  116. data/lib/active_merchant/billing/gateways/moneris.rb +119 -36
  117. data/lib/active_merchant/billing/gateways/moneris_us.rb +146 -45
  118. data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
  119. data/lib/active_merchant/billing/gateways/mundipagg.rb +292 -0
  120. data/lib/active_merchant/billing/gateways/nab_transact.rb +81 -56
  121. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  122. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -3
  123. data/lib/active_merchant/billing/gateways/netbanx.rb +289 -0
  124. data/lib/active_merchant/billing/gateways/netbilling.rb +61 -26
  125. data/lib/active_merchant/billing/gateways/netpay.rb +1 -1
  126. data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
  127. data/lib/active_merchant/billing/gateways/nmi.rb +265 -10
  128. data/lib/active_merchant/billing/gateways/ogone.rb +85 -27
  129. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  130. data/lib/active_merchant/billing/gateways/openpay.rb +227 -0
  131. data/lib/active_merchant/billing/gateways/opp.rb +372 -0
  132. data/lib/active_merchant/billing/gateways/optimal_payment.rb +59 -28
  133. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
  134. data/lib/active_merchant/billing/gateways/orbital.rb +346 -56
  135. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
  136. data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
  137. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  138. data/lib/active_merchant/billing/gateways/pay_conex.rb +246 -0
  139. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -14
  140. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  141. data/lib/active_merchant/billing/gateways/pay_junction.rb +19 -25
  142. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
  143. data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -7
  144. data/lib/active_merchant/billing/gateways/paybox_direct.rb +16 -12
  145. data/lib/active_merchant/billing/gateways/payeezy.rb +386 -0
  146. data/lib/active_merchant/billing/gateways/payex.rb +412 -0
  147. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +38 -17
  148. data/lib/active_merchant/billing/gateways/payflow.rb +100 -19
  149. data/lib/active_merchant/billing/gateways/payflow_express.rb +22 -22
  150. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -2
  151. data/lib/active_merchant/billing/gateways/payflow_uk.rb +6 -6
  152. data/lib/active_merchant/billing/gateways/payment_express.rb +15 -3
  153. data/lib/active_merchant/billing/gateways/paymentez.rb +276 -0
  154. data/lib/active_merchant/billing/gateways/paymill.rb +237 -48
  155. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -8
  156. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  157. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +18 -4
  158. data/lib/active_merchant/billing/gateways/paypal.rb +37 -20
  159. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +6 -5
  161. data/lib/active_merchant/billing/gateways/paypal_express.rb +32 -4
  162. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  163. data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
  164. data/lib/active_merchant/billing/gateways/paystation.rb +32 -24
  165. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  166. data/lib/active_merchant/billing/gateways/payu_latam.rb +440 -0
  167. data/lib/active_merchant/billing/gateways/pin.rb +68 -13
  168. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -12
  169. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  170. data/lib/active_merchant/billing/gateways/psigate.rb +14 -14
  171. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  172. data/lib/active_merchant/billing/gateways/qbms.rb +12 -1
  173. data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
  174. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  175. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
  176. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +299 -0
  177. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
  178. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -319
  179. data/lib/active_merchant/billing/gateways/qvalent.rb +236 -0
  180. data/lib/active_merchant/billing/gateways/realex.rb +40 -25
  181. data/lib/active_merchant/billing/gateways/redsys.rb +212 -80
  182. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  183. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  184. data/lib/active_merchant/billing/gateways/sage.rb +412 -119
  185. data/lib/active_merchant/billing/gateways/sage_pay.rb +176 -59
  186. data/lib/active_merchant/billing/gateways/secure_net.rb +35 -29
  187. data/lib/active_merchant/billing/gateways/secure_pay.rb +182 -9
  188. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +21 -7
  189. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -7
  190. data/lib/active_merchant/billing/gateways/securion_pay.rb +267 -0
  191. data/lib/active_merchant/billing/gateways/skip_jack.rb +1 -3
  192. data/lib/active_merchant/billing/gateways/smart_ps.rb +14 -3
  193. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  194. data/lib/active_merchant/billing/gateways/spreedly_core.rb +74 -14
  195. data/lib/active_merchant/billing/gateways/stripe.rb +472 -83
  196. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +156 -0
  197. data/lib/active_merchant/billing/gateways/telr.rb +275 -0
  198. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  199. data/lib/active_merchant/billing/gateways/trans_first.rb +142 -28
  200. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  201. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  202. data/lib/active_merchant/billing/gateways/transnational.rb +2 -231
  203. data/lib/active_merchant/billing/gateways/trexle.rb +217 -0
  204. data/lib/active_merchant/billing/gateways/trust_commerce.rb +17 -11
  205. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +193 -75
  206. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +156 -64
  207. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  208. data/lib/active_merchant/billing/gateways/verifi.rb +1 -8
  209. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -15
  210. data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
  211. data/lib/active_merchant/billing/gateways/webpay.rb +45 -28
  212. data/lib/active_merchant/billing/gateways/wepay.rb +238 -0
  213. data/lib/active_merchant/billing/gateways/wirecard.rb +167 -49
  214. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  215. data/lib/active_merchant/billing/gateways/worldpay.rb +171 -45
  216. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +218 -0
  217. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  218. data/lib/active_merchant/billing/gateways.rb +8 -11
  219. data/lib/active_merchant/billing/model.rb +30 -0
  220. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  221. data/lib/active_merchant/billing/payment_token.rb +21 -0
  222. data/lib/active_merchant/billing/rails.rb +3 -0
  223. data/lib/active_merchant/billing/response.rb +24 -17
  224. data/lib/active_merchant/billing.rb +7 -1
  225. data/lib/active_merchant/connection.rb +208 -0
  226. data/lib/active_merchant/country.rb +334 -0
  227. data/lib/active_merchant/empty.rb +20 -0
  228. data/lib/active_merchant/errors.rb +35 -0
  229. data/lib/active_merchant/net_http_ssl_connection.rb +9 -0
  230. data/lib/active_merchant/network_connection_retries.rb +81 -0
  231. data/lib/active_merchant/post_data.rb +24 -0
  232. data/lib/active_merchant/posts_data.rb +94 -0
  233. data/lib/active_merchant/version.rb +1 -1
  234. data/lib/active_merchant.rb +22 -22
  235. data/lib/certs/cacert.pem +3951 -0
  236. data/lib/support/gateway_support.rb +16 -10
  237. data/lib/support/outbound_hosts.rb +13 -10
  238. data/lib/support/ssl_version.rb +87 -0
  239. metadata +164 -306
  240. data/gem-public_cert.pem +0 -20
  241. data/lib/active_merchant/billing/expiry_date.rb +0 -34
  242. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  243. data/lib/active_merchant/billing/gateways/card_stream_modern.rb +0 -155
  244. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -277
  245. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
  246. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -93
  247. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  248. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  249. data/lib/active_merchant/billing/gateways/samurai.rb +0 -118
  250. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -361
  251. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
  252. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
  253. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
  254. data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
  255. data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -73
  256. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
  257. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
  258. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
  259. data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
  260. data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
  261. data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
  262. data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
  263. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
  264. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
  265. data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
  266. data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
  267. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
  268. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
  269. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
  270. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
  271. data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
  272. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
  273. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
  274. data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
  275. data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
  276. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
  277. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
  278. data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
  279. data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
  280. data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
  281. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
  282. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
  283. data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
  284. data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
  285. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
  286. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
  287. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
  288. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
  289. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
  290. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
  291. data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
  292. data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
  293. data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
  294. data/lib/active_merchant/billing/integrations/epay.rb +0 -21
  295. data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
  296. data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
  297. data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
  298. data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
  299. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
  300. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
  301. data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
  302. data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
  303. data/lib/active_merchant/billing/integrations/helper.rb +0 -117
  304. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
  305. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
  306. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
  307. data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
  308. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -114
  309. data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -95
  310. data/lib/active_merchant/billing/integrations/ipay88.rb +0 -19
  311. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
  312. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
  313. data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
  314. data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
  315. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
  316. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
  317. data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
  318. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
  319. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -129
  320. data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
  321. data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
  322. data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
  323. data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
  324. data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
  325. data/lib/active_merchant/billing/integrations/notification.rb +0 -71
  326. data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
  327. data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
  328. data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
  329. data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
  330. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
  331. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
  332. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
  333. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
  334. data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
  335. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
  336. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
  337. data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
  338. data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
  339. data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
  340. data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
  341. data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
  342. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
  343. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
  344. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
  345. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -28
  346. data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
  347. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -74
  348. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -165
  349. data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
  350. data/lib/active_merchant/billing/integrations/payu_in.rb +0 -43
  351. data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
  352. data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
  353. data/lib/active_merchant/billing/integrations/platron.rb +0 -28
  354. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -112
  355. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
  356. data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
  357. data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
  358. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -74
  359. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
  360. data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
  361. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
  362. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
  363. data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
  364. data/lib/active_merchant/billing/integrations/return.rb +0 -42
  365. data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
  366. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
  367. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
  368. data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
  369. data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
  370. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
  371. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
  372. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
  373. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
  374. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
  375. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -91
  376. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -139
  377. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -17
  378. data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
  379. data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
  380. data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
  381. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
  382. data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
  383. data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
  384. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
  385. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
  386. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
  387. data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
  388. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
  389. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
  390. data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
  391. data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
  392. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
  393. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
  394. data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
  395. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
  396. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
  397. data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
  398. data/lib/active_merchant/billing/integrations.rb +0 -17
  399. data.tar.gz.sig +0 -0
  400. metadata.gz.sig +0 -0
@@ -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