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
@@ -1,17 +1,8 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
- # See the remote and mocked unit test files for example usage. Pay special
4
- # attention to the contents of the options hash.
5
- #
6
3
  # Initial setup instructions can be found in
7
4
  # http://cybersource.com/support_center/implementation/downloads/soap_api/SOAP_toolkits.pdf
8
5
  #
9
- # Debugging
10
- # If you experience an issue with this gateway be sure to examine the
11
- # transaction information from a general transaction search inside the
12
- # CyberSource Business Center for the full error messages including field
13
- # names.
14
- #
15
6
  # Important Notes
16
7
  # * For checks you can purchase and store.
17
8
  # * AVS and CVV only work against the production server. You will always
@@ -27,67 +18,73 @@ module ActiveMerchant #:nodoc:
27
18
  # * To process pinless debit cards through the pinless debit card
28
19
  # network, your Cybersource merchant account must accept pinless
29
20
  # debit card payments.
21
+ # * The order of the XML elements does matter, make sure to follow the order in
22
+ # the documentation exactly.
30
23
  class CyberSourceGateway < Gateway
31
- self.test_url = 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor'
32
- self.live_url = 'https://ics2ws.ic3.com/commerce/1.x/transactionProcessor'
24
+ self.test_url = 'https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor'
25
+ self.live_url = 'https://ics2wsa.ic3.com/commerce/1.x/transactionProcessor'
26
+
27
+ XSD_VERSION = '1.121'
33
28
 
34
- XSD_VERSION = "1.69"
29
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
30
+ self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB)
35
31
 
36
- # visa, master, american_express, discover
37
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
38
- self.supported_countries = %w(US BR CA CN DK FI FR DE JP MX NO SE GB SG)
39
32
  self.default_currency = 'USD'
33
+ self.currencies_without_fractions = %w(JPY)
34
+
40
35
  self.homepage_url = 'http://www.cybersource.com'
41
36
  self.display_name = 'CyberSource'
42
37
 
43
- # map credit card to the CyberSource expected representation
44
38
  @@credit_card_codes = {
45
39
  :visa => '001',
46
40
  :master => '002',
47
41
  :american_express => '003',
48
- :discover => '004'
42
+ :discover => '004',
43
+ :diners_club => '005',
44
+ :jcb => '007',
45
+ :dankort => '034',
46
+ :maestro => '042'
49
47
  }
50
48
 
51
- # map response codes to something humans can read
52
49
  @@response_codes = {
53
- :r100 => "Successful transaction",
54
- :r101 => "Request is missing one or more required fields" ,
55
- :r102 => "One or more fields contains invalid data",
56
- :r150 => "General failure",
57
- :r151 => "The request was received but a server time-out occurred",
58
- :r152 => "The request was received, but a service timed out",
59
- :r200 => "The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the AVS check",
60
- :r201 => "The issuing bank has questions about the request",
61
- :r202 => "Expired card",
62
- :r203 => "General decline of the card",
63
- :r204 => "Insufficient funds in the account",
64
- :r205 => "Stolen or lost card",
65
- :r207 => "Issuing bank unavailable",
66
- :r208 => "Inactive card or card not authorized for card-not-present transactions",
67
- :r209 => "American Express Card Identifiction Digits (CID) did not match",
68
- :r210 => "The card has reached the credit limit",
69
- :r211 => "Invalid card verification number",
50
+ :r100 => 'Successful transaction',
51
+ :r101 => 'Request is missing one or more required fields',
52
+ :r102 => 'One or more fields contains invalid data',
53
+ :r150 => 'General failure',
54
+ :r151 => 'The request was received but a server time-out occurred',
55
+ :r152 => 'The request was received, but a service timed out',
56
+ :r200 => 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the AVS check',
57
+ :r201 => 'The issuing bank has questions about the request',
58
+ :r202 => 'Expired card',
59
+ :r203 => 'General decline of the card',
60
+ :r204 => 'Insufficient funds in the account',
61
+ :r205 => 'Stolen or lost card',
62
+ :r207 => 'Issuing bank unavailable',
63
+ :r208 => 'Inactive card or card not authorized for card-not-present transactions',
64
+ :r209 => 'American Express Card Identifiction Digits (CID) did not match',
65
+ :r210 => 'The card has reached the credit limit',
66
+ :r211 => 'Invalid card verification number',
70
67
  :r221 => "The customer matched an entry on the processor's negative file",
71
- :r230 => "The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification check",
72
- :r231 => "Invalid account number",
73
- :r232 => "The card type is not accepted by the payment processor",
74
- :r233 => "General decline by the processor",
75
- :r234 => "A problem exists with your CyberSource merchant configuration",
76
- :r235 => "The requested amount exceeds the originally authorized amount",
77
- :r236 => "Processor failure",
78
- :r237 => "The authorization has already been reversed",
79
- :r238 => "The authorization has already been captured",
80
- :r239 => "The requested transaction amount must match the previous transaction amount",
81
- :r240 => "The card type sent is invalid or does not correlate with the credit card number",
82
- :r241 => "The request ID is invalid",
83
- :r242 => "You requested a capture, but there is no corresponding, unused authorization record.",
84
- :r243 => "The transaction has already been settled or reversed",
85
- :r244 => "The bank account number failed the validation check",
86
- :r246 => "The capture or credit is not voidable because the capture or credit information has already been submitted to your processor",
87
- :r247 => "You requested a credit for a capture that was previously voided",
88
- :r250 => "The request was received, but a time-out occurred with the payment processor",
89
- :r254 => "Your CyberSource account is prohibited from processing stand-alone refunds",
90
- :r255 => "Your CyberSource account is not configured to process the service in the country you specified"
68
+ :r230 => 'The authorization request was approved by the issuing bank but declined by CyberSource because it did not pass the card verification check',
69
+ :r231 => 'Invalid account number',
70
+ :r232 => 'The card type is not accepted by the payment processor',
71
+ :r233 => 'General decline by the processor',
72
+ :r234 => 'A problem exists with your CyberSource merchant configuration',
73
+ :r235 => 'The requested amount exceeds the originally authorized amount',
74
+ :r236 => 'Processor failure',
75
+ :r237 => 'The authorization has already been reversed',
76
+ :r238 => 'The authorization has already been captured',
77
+ :r239 => 'The requested transaction amount must match the previous transaction amount',
78
+ :r240 => 'The card type sent is invalid or does not correlate with the credit card number',
79
+ :r241 => 'The request ID is invalid',
80
+ :r242 => 'You requested a capture, but there is no corresponding, unused authorization record.',
81
+ :r243 => 'The transaction has already been settled or reversed',
82
+ :r244 => 'The bank account number failed the validation check',
83
+ :r246 => 'The capture or credit is not voidable because the capture or credit information has already been submitted to your processor',
84
+ :r247 => 'You requested a credit for a capture that was previously voided',
85
+ :r250 => 'The request was received, but a time-out occurred with the payment processor',
86
+ :r254 => 'Your CyberSource account is prohibited from processing stand-alone refunds',
87
+ :r255 => 'Your CyberSource account is not configured to process the service in the country you specified'
91
88
  }
92
89
 
93
90
  # These are the options that can be used when creating a new CyberSource
@@ -114,74 +111,67 @@ module ActiveMerchant #:nodoc:
114
111
  super
115
112
  end
116
113
 
117
- # Request an authorization for an amount from CyberSource
118
- #
119
- # You must supply an :order_id in the options hash
120
114
  def authorize(money, creditcard_or_reference, options = {})
121
- requires!(options, :order_id)
122
115
  setup_address_hash(options)
123
- commit(build_auth_request(money, creditcard_or_reference, options), options )
116
+ commit(build_auth_request(money, creditcard_or_reference, options), :authorize, money, options)
124
117
  end
125
118
 
126
- def auth_reversal(money, identification, options = {})
127
- commit(build_auth_reversal_request(money, identification, options), options)
128
- end
129
-
130
- # Capture an authorization that has previously been requested
131
119
  def capture(money, authorization, options = {})
132
120
  setup_address_hash(options)
133
- commit(build_capture_request(money, authorization, options), options)
121
+ commit(build_capture_request(money, authorization, options), :capture, money, options)
134
122
  end
135
123
 
136
- # Purchase is an auth followed by a capture
137
- # You must supply an order_id in the options hash
138
124
  # options[:pinless_debit_card] => true # attempts to process as pinless debit card
139
125
  def purchase(money, payment_method_or_reference, options = {})
140
- requires!(options, :order_id)
141
126
  setup_address_hash(options)
142
- commit(build_purchase_request(money, payment_method_or_reference, options), options)
127
+ commit(build_purchase_request(money, payment_method_or_reference, options), :purchase, money, options)
143
128
  end
144
129
 
145
130
  def void(identification, options = {})
146
- commit(build_void_request(identification, options), options)
131
+ commit(build_void_request(identification, options), :void, nil, options)
147
132
  end
148
133
 
149
134
  def refund(money, identification, options = {})
150
- commit(build_refund_request(money, identification, options), options)
135
+ commit(build_refund_request(money, identification, options), :refund, money, options)
136
+ end
137
+
138
+ def verify(payment, options = {})
139
+ MultiResponse.run(:use_first_response) do |r|
140
+ r.process { authorize(100, payment, options) }
141
+ r.process(:ignore_result) { void(r.authorization, options) }
142
+ end
151
143
  end
152
144
 
153
145
  # Adds credit to a subscription (stand alone credit).
154
146
  def credit(money, reference, options = {})
155
- requires!(options, :order_id)
156
- commit(build_credit_request(money, reference, options), options)
147
+ commit(build_credit_request(money, reference, options), :credit, money, options)
157
148
  end
158
149
 
159
150
  # Stores a customer subscription/profile with type "on-demand".
160
151
  # To charge the card while creating a profile, pass
161
152
  # options[:setup_fee] => money
162
153
  def store(payment_method, options = {})
163
- requires!(options, :order_id)
164
154
  setup_address_hash(options)
165
- commit(build_create_subscription_request(payment_method, options), options)
155
+ commit(build_create_subscription_request(payment_method, options), :store, nil, options)
166
156
  end
167
157
 
168
158
  # Updates a customer subscription/profile
169
159
  def update(reference, creditcard, options = {})
170
160
  requires!(options, :order_id)
171
161
  setup_address_hash(options)
172
- commit(build_update_subscription_request(reference, creditcard, options), options)
162
+ commit(build_update_subscription_request(reference, creditcard, options), :update, nil, options)
173
163
  end
174
164
 
175
165
  # Removes a customer subscription/profile
176
166
  def unstore(reference, options = {})
177
167
  requires!(options, :order_id)
178
- commit(build_delete_subscription_request(reference, options), options)
168
+ commit(build_delete_subscription_request(reference, options), :unstore, nil, options)
179
169
  end
180
170
 
181
171
  # Retrieves a customer subscription/profile
182
172
  def retrieve(reference, options = {})
183
173
  requires!(options, :order_id)
184
- commit(build_retrieve_subscription_request(reference, options), options)
174
+ commit(build_retrieve_subscription_request(reference, options), :retrieve, nil, options)
185
175
  end
186
176
 
187
177
  # CyberSource requires that you provide line item information for tax
@@ -213,29 +203,63 @@ module ActiveMerchant #:nodoc:
213
203
  def calculate_tax(creditcard, options)
214
204
  requires!(options, :line_items)
215
205
  setup_address_hash(options)
216
- commit(build_tax_calculation_request(creditcard, options), options)
206
+ commit(build_tax_calculation_request(creditcard, options), :calculate_tax, nil, options)
217
207
  end
218
208
 
219
209
  # Determines if a card can be used for Pinless Debit Card transactions
220
210
  def validate_pinless_debit_card(creditcard, options = {})
221
211
  requires!(options, :order_id)
222
- commit(build_validate_pinless_debit_request(creditcard,options), options)
212
+ commit(build_validate_pinless_debit_request(creditcard, options), :validate_pinless_debit_card, nil, options)
213
+ end
214
+
215
+ def supports_scrubbing?
216
+ true
217
+ end
218
+
219
+ def scrub(transcript)
220
+ transcript.
221
+ gsub(%r((<wsse:Password [^>]*>)[^<]*(</wsse:Password>))i, '\1[FILTERED]\2').
222
+ gsub(%r((<accountNumber>)[^<]*(</accountNumber>))i, '\1[FILTERED]\2').
223
+ gsub(%r((<cvNumber>)[^<]*(</cvNumber>))i, '\1[FILTERED]\2').
224
+ gsub(%r((<cavv>)[^<]*(</cavv>))i, '\1[FILTERED]\2').
225
+ gsub(%r((<xid>)[^<]*(</xid>))i, '\1[FILTERED]\2').
226
+ gsub(%r((<authenticationData>)[^<]*(</authenticationData>))i, '\1[FILTERED]\2')
227
+ end
228
+
229
+ def supports_network_tokenization?
230
+ true
231
+ end
232
+
233
+ def verify_credentials
234
+ response = void('0')
235
+ response.params['reasonCode'] == '102'
223
236
  end
224
237
 
225
238
  private
226
239
 
227
240
  # Create all address hash key value pairs so that we still function if we
228
- # were only provided with one or two of them
241
+ # were only provided with one or two of them or even none
229
242
  def setup_address_hash(options)
230
- options[:billing_address] = options[:billing_address] || options[:address] || {}
243
+ default_address = {
244
+ :address1 => 'Unspecified',
245
+ :city => 'Unspecified',
246
+ :state => 'NC',
247
+ :zip => '00000',
248
+ :country => 'US'
249
+ }
250
+ options[:billing_address] = options[:billing_address] || options[:address] || default_address
231
251
  options[:shipping_address] = options[:shipping_address] || {}
232
252
  end
233
253
 
234
254
  def build_auth_request(money, creditcard_or_reference, options)
235
255
  xml = Builder::XmlMarkup.new :indent => 2
236
256
  add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
237
- add_auth_service(xml)
238
- add_business_rules_data(xml)
257
+ add_decision_manager_fields(xml, options)
258
+ add_mdd_fields(xml, options)
259
+ add_auth_service(xml, creditcard_or_reference, options)
260
+ add_threeds_services(xml, options)
261
+ add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference)
262
+ add_business_rules_data(xml, creditcard_or_reference, options)
239
263
  xml.target!
240
264
  end
241
265
 
@@ -246,53 +270,53 @@ module ActiveMerchant #:nodoc:
246
270
  add_line_item_data(xml, options)
247
271
  add_purchase_data(xml, 0, false, options)
248
272
  add_tax_service(xml)
249
- add_business_rules_data(xml)
273
+ add_business_rules_data(xml, creditcard, options)
250
274
  xml.target!
251
275
  end
252
276
 
253
277
  def build_capture_request(money, authorization, options)
254
- order_id, request_id, request_token = authorization.split(";")
278
+ order_id, request_id, request_token = authorization.split(';')
255
279
  options[:order_id] = order_id
256
280
 
257
281
  xml = Builder::XmlMarkup.new :indent => 2
258
282
  add_purchase_data(xml, money, true, options)
259
283
  add_capture_service(xml, request_id, request_token)
260
- add_business_rules_data(xml)
284
+ add_business_rules_data(xml, authorization, options)
261
285
  xml.target!
262
286
  end
263
287
 
264
288
  def build_purchase_request(money, payment_method_or_reference, options)
265
289
  xml = Builder::XmlMarkup.new :indent => 2
266
290
  add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
291
+ add_decision_manager_fields(xml, options)
292
+ add_mdd_fields(xml, options)
267
293
  if !payment_method_or_reference.is_a?(String) && card_brand(payment_method_or_reference) == 'check'
268
294
  add_check_service(xml)
269
295
  else
270
- add_purchase_service(xml, options)
271
- add_business_rules_data(xml) unless options[:pinless_debit_card]
296
+ add_purchase_service(xml, payment_method_or_reference, options)
297
+ add_threeds_services(xml, options)
298
+ add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference)
299
+ add_business_rules_data(xml, payment_method_or_reference, options) unless options[:pinless_debit_card]
272
300
  end
273
301
  xml.target!
274
302
  end
275
303
 
276
304
  def build_void_request(identification, options)
277
- order_id, request_id, request_token = identification.split(";")
305
+ order_id, request_id, request_token, action, money, currency = identification.split(';')
278
306
  options[:order_id] = order_id
279
307
 
280
308
  xml = Builder::XmlMarkup.new :indent => 2
281
- add_void_service(xml, request_id, request_token)
282
- xml.target!
283
- end
284
-
285
- def build_auth_reversal_request(money, identification, options)
286
- order_id, request_id, request_token = identification.split(";")
287
- options[:order_id] = order_id
288
- xml = Builder::XmlMarkup.new :indent => 2
289
- add_purchase_data(xml, money, true, options)
290
- add_auth_reversal_service(xml, request_id, request_token)
309
+ if action == 'capture'
310
+ add_void_service(xml, request_id, request_token)
311
+ else
312
+ add_purchase_data(xml, money, true, options.merge(:currency => currency || default_currency))
313
+ add_auth_reversal_service(xml, request_id, request_token)
314
+ end
291
315
  xml.target!
292
316
  end
293
317
 
294
318
  def build_refund_request(money, identification, options)
295
- order_id, request_id, request_token = identification.split(";")
319
+ order_id, request_id, request_token = identification.split(';')
296
320
  options[:order_id] = order_id
297
321
 
298
322
  xml = Builder::XmlMarkup.new :indent => 2
@@ -313,7 +337,7 @@ module ActiveMerchant #:nodoc:
313
337
  end
314
338
 
315
339
  def build_create_subscription_request(payment_method, options)
316
- default_subscription_params = {:frequency => "on-demand", :amount => 0, :automatic_renew => false}
340
+ default_subscription_params = {:frequency => 'on-demand', :amount => 0, :automatic_renew => false}
317
341
  options[:subscription] = default_subscription_params.update(
318
342
  options[:subscription] || {}
319
343
  )
@@ -331,13 +355,14 @@ module ActiveMerchant #:nodoc:
331
355
  add_subscription(xml, options)
332
356
  if options[:setup_fee]
333
357
  if card_brand(payment_method) == 'check'
334
- add_check_service(xml, options)
358
+ add_check_service(xml)
335
359
  else
336
- add_purchase_service(xml, options)
360
+ add_purchase_service(xml, payment_method, options)
361
+ add_payment_network_token(xml) if network_tokenization?(payment_method)
337
362
  end
338
363
  end
339
364
  add_subscription_create_service(xml, options)
340
- add_business_rules_data(xml)
365
+ add_business_rules_data(xml, payment_method, options)
341
366
  xml.target!
342
367
  end
343
368
 
@@ -349,7 +374,7 @@ module ActiveMerchant #:nodoc:
349
374
  add_creditcard_payment_method(xml) if creditcard
350
375
  add_subscription(xml, options, reference)
351
376
  add_subscription_update_service(xml, options)
352
- add_business_rules_data(xml)
377
+ add_business_rules_data(xml, creditcard, options)
353
378
  xml.target!
354
379
  end
355
380
 
@@ -367,24 +392,35 @@ module ActiveMerchant #:nodoc:
367
392
  xml.target!
368
393
  end
369
394
 
370
- def build_validate_pinless_debit_request(creditcard,options)
395
+ def build_validate_pinless_debit_request(creditcard, options)
371
396
  xml = Builder::XmlMarkup.new :indent => 2
372
397
  add_creditcard(xml, creditcard)
373
398
  add_validate_pinless_debit_service(xml)
374
399
  xml.target!
375
400
  end
376
401
 
377
- def add_business_rules_data(xml)
378
- xml.tag! 'businessRules' do
379
- xml.tag!('ignoreAVSResult', 'true') if @options[:ignore_avs]
380
- xml.tag!('ignoreCVResult', 'true') if @options[:ignore_cvv]
402
+ def add_business_rules_data(xml, payment_method, options)
403
+ prioritized_options = [options, @options]
404
+
405
+ unless network_tokenization?(payment_method)
406
+ xml.tag! 'businessRules' do
407
+ xml.tag!('ignoreAVSResult', 'true') if extract_option(prioritized_options, :ignore_avs)
408
+ xml.tag!('ignoreCVResult', 'true') if extract_option(prioritized_options, :ignore_cvv)
409
+ end
381
410
  end
382
411
  end
383
412
 
413
+ def extract_option(prioritized_options, option_name)
414
+ options_matching_key = prioritized_options.detect do |options|
415
+ options.has_key? option_name
416
+ end
417
+ options_matching_key[option_name] if options_matching_key
418
+ end
419
+
384
420
  def add_line_item_data(xml, options)
385
421
  options[:line_items].each_with_index do |value, index|
386
422
  xml.tag! 'item', {'id' => index} do
387
- xml.tag! 'unitPrice', amount(value[:declared_value])
423
+ xml.tag! 'unitPrice', localized_amount(value[:declared_value].to_i, options[:currency] || default_currency)
388
424
  xml.tag! 'quantity', value[:quantity]
389
425
  xml.tag! 'productCode', value[:code] || 'shipping_only'
390
426
  xml.tag! 'productName', value[:description]
@@ -395,16 +431,16 @@ module ActiveMerchant #:nodoc:
395
431
 
396
432
  def add_merchant_data(xml, options)
397
433
  xml.tag! 'merchantID', @options[:login]
398
- xml.tag! 'merchantReferenceCode', options[:order_id]
399
- xml.tag! 'clientLibrary' ,'Ruby Active Merchant'
434
+ xml.tag! 'merchantReferenceCode', options[:order_id] || generate_unique_id
435
+ xml.tag! 'clientLibrary', 'Ruby Active Merchant'
400
436
  xml.tag! 'clientLibraryVersion', VERSION
401
- xml.tag! 'clientEnvironment' , RUBY_PLATFORM
437
+ xml.tag! 'clientEnvironment', RUBY_PLATFORM
402
438
  end
403
439
 
404
440
  def add_purchase_data(xml, money = 0, include_grand_total = false, options={})
405
441
  xml.tag! 'purchaseTotals' do
406
442
  xml.tag! 'currency', options[:currency] || currency(money)
407
- xml.tag!('grandTotalAmount', amount(money)) if include_grand_total
443
+ xml.tag!('grandTotalAmount', localized_amount(money.to_i, options[:currency] || default_currency)) if include_grand_total
408
444
  end
409
445
  end
410
446
 
@@ -417,11 +453,12 @@ module ActiveMerchant #:nodoc:
417
453
  xml.tag! 'city', address[:city]
418
454
  xml.tag! 'state', address[:state]
419
455
  xml.tag! 'postalCode', address[:zip]
420
- xml.tag! 'country', address[:country]
456
+ xml.tag! 'country', lookup_country_code(address[:country]) unless address[:country].blank?
421
457
  xml.tag! 'company', address[:company] unless address[:company].blank?
422
458
  xml.tag! 'companyTaxID', address[:companyTaxID] unless address[:company_tax_id].blank?
423
459
  xml.tag! 'phoneNumber', address[:phone] unless address[:phone].blank?
424
- xml.tag! 'email', options[:email]
460
+ xml.tag! 'email', options[:email] || 'null@cybersource.com'
461
+ xml.tag! 'ipAddress', options[:ip] unless options[:ip].blank? || shipTo
425
462
  xml.tag! 'driversLicenseNumber', options[:drivers_license_number] unless options[:drivers_license_number].blank?
426
463
  xml.tag! 'driversLicenseState', options[:drivers_license_state] unless options[:drivers_license_state].blank?
427
464
  end
@@ -432,11 +469,31 @@ module ActiveMerchant #:nodoc:
432
469
  xml.tag! 'accountNumber', creditcard.number
433
470
  xml.tag! 'expirationMonth', format(creditcard.month, :two_digits)
434
471
  xml.tag! 'expirationYear', format(creditcard.year, :four_digits)
435
- xml.tag!('cvNumber', creditcard.verification_value) unless (@options[:ignore_cvv] || creditcard.verification_value.blank? )
472
+ xml.tag!('cvNumber', creditcard.verification_value) unless @options[:ignore_cvv] || creditcard.verification_value.blank?
436
473
  xml.tag! 'cardType', @@credit_card_codes[card_brand(creditcard).to_sym]
437
474
  end
438
475
  end
439
476
 
477
+ def add_decision_manager_fields(xml, options)
478
+ return unless options[:decision_manager_enabled]
479
+
480
+ xml.tag! 'decisionManager' do
481
+ xml.tag! 'enabled', options[:decision_manager_enabled] if options[:decision_manager_enabled]
482
+ xml.tag! 'profile', options[:decision_manager_profile] if options[:decision_manager_profile]
483
+ end
484
+ end
485
+
486
+ def add_mdd_fields(xml, options)
487
+ return unless options.keys.any? { |key| key.to_s.start_with?('mdd_field') }
488
+
489
+ xml.tag! 'merchantDefinedData' do
490
+ (1..100).each do |each|
491
+ key = "mdd_field_#{each}".to_sym
492
+ xml.tag!("field#{each}", options[key]) if options[key]
493
+ end
494
+ end
495
+ end
496
+
440
497
  def add_check(xml, check)
441
498
  xml.tag! 'check' do
442
499
  xml.tag! 'accountNumber', check.account_number
@@ -452,8 +509,50 @@ module ActiveMerchant #:nodoc:
452
509
  end
453
510
  end
454
511
 
455
- def add_auth_service(xml)
456
- xml.tag! 'ccAuthService', {'run' => 'true'}
512
+ def add_auth_service(xml, payment_method, options)
513
+ if network_tokenization?(payment_method)
514
+ add_auth_network_tokenization(xml, payment_method, options)
515
+ else
516
+ xml.tag! 'ccAuthService', {'run' => 'true'}
517
+ end
518
+ end
519
+
520
+ def network_tokenization?(payment_method)
521
+ payment_method.is_a?(NetworkTokenizationCreditCard)
522
+ end
523
+
524
+ def add_auth_network_tokenization(xml, payment_method, options)
525
+ return unless network_tokenization?(payment_method)
526
+
527
+ case card_brand(payment_method).to_sym
528
+ when :visa
529
+ xml.tag! 'ccAuthService', {'run' => 'true'} do
530
+ xml.tag!('cavv', payment_method.payment_cryptogram)
531
+ xml.tag!('commerceIndicator', 'vbv')
532
+ xml.tag!('xid', payment_method.payment_cryptogram)
533
+ end
534
+ when :mastercard
535
+ xml.tag! 'ucaf' do
536
+ xml.tag!('authenticationData', payment_method.payment_cryptogram)
537
+ xml.tag!('collectionIndicator', '2')
538
+ end
539
+ xml.tag! 'ccAuthService', {'run' => 'true'} do
540
+ xml.tag!('commerceIndicator', 'spa')
541
+ end
542
+ when :american_express
543
+ cryptogram = Base64.decode64(payment_method.payment_cryptogram)
544
+ xml.tag! 'ccAuthService', {'run' => 'true'} do
545
+ xml.tag!('cavv', Base64.encode64(cryptogram[0...20]))
546
+ xml.tag!('commerceIndicator', 'aesk')
547
+ xml.tag!('xid', Base64.encode64(cryptogram[20...40]))
548
+ end
549
+ end
550
+ end
551
+
552
+ def add_payment_network_token(xml)
553
+ xml.tag! 'paymentNetworkToken' do
554
+ xml.tag!('transactionType', '1')
555
+ end
457
556
  end
458
557
 
459
558
  def add_capture_service(xml, request_id, request_token)
@@ -463,11 +562,11 @@ module ActiveMerchant #:nodoc:
463
562
  end
464
563
  end
465
564
 
466
- def add_purchase_service(xml, options)
565
+ def add_purchase_service(xml, payment_method, options)
467
566
  if options[:pinless_debit_card]
468
567
  xml.tag! 'pinlessDebitService', {'run' => 'true'}
469
568
  else
470
- xml.tag! 'ccAuthService', {'run' => 'true'}
569
+ add_auth_service(xml, payment_method, options)
471
570
  xml.tag! 'ccCaptureService', {'run' => 'true'}
472
571
  end
473
572
  end
@@ -518,17 +617,17 @@ module ActiveMerchant #:nodoc:
518
617
 
519
618
  xml.tag! 'recurringSubscriptionInfo' do
520
619
  if reference
521
- _, subscription_id, _ = reference.split(";")
620
+ subscription_id = reference.split(';')[6]
522
621
  xml.tag! 'subscriptionID', subscription_id
523
622
  end
524
623
 
525
624
  xml.tag! 'status', options[:subscription][:status] if options[:subscription][:status]
526
- xml.tag! 'amount', options[:subscription][:amount] if options[:subscription][:amount]
625
+ xml.tag! 'amount', localized_amount(options[:subscription][:amount].to_i, options[:currency] || default_currency) if options[:subscription][:amount]
527
626
  xml.tag! 'numberOfPayments', options[:subscription][:occurrences] if options[:subscription][:occurrences]
528
627
  xml.tag! 'automaticRenew', options[:subscription][:automatic_renew] if options[:subscription][:automatic_renew]
529
628
  xml.tag! 'frequency', options[:subscription][:frequency] if options[:subscription][:frequency]
530
- xml.tag! 'startDate', options[:subscription][:start_date].strftime("%Y%m%d") if options[:subscription][:start_date]
531
- xml.tag! 'endDate', options[:subscription][:end_date].strftime("%Y%m%d") if options[:subscription][:end_date]
629
+ xml.tag! 'startDate', options[:subscription][:start_date].strftime('%Y%m%d') if options[:subscription][:start_date]
630
+ xml.tag! 'endDate', options[:subscription][:end_date].strftime('%Y%m%d') if options[:subscription][:end_date]
532
631
  xml.tag! 'approvalRequired', options[:subscription][:approval_required] || false
533
632
  xml.tag! 'event', options[:subscription][:event] if options[:subscription][:event]
534
633
  xml.tag! 'billPayment', options[:subscription][:bill_payment] if options[:subscription][:bill_payment]
@@ -537,13 +636,13 @@ module ActiveMerchant #:nodoc:
537
636
 
538
637
  def add_creditcard_payment_method(xml)
539
638
  xml.tag! 'subscription' do
540
- xml.tag! 'paymentMethod', "credit card"
639
+ xml.tag! 'paymentMethod', 'credit card'
541
640
  end
542
641
  end
543
642
 
544
643
  def add_check_payment_method(xml)
545
644
  xml.tag! 'subscription' do
546
- xml.tag! 'paymentMethod', "check"
645
+ xml.tag! 'paymentMethod', 'check'
547
646
  end
548
647
  end
549
648
 
@@ -557,46 +656,72 @@ module ActiveMerchant #:nodoc:
557
656
  add_check(xml, payment_method_or_reference)
558
657
  else
559
658
  add_address(xml, payment_method_or_reference, options[:billing_address], options)
659
+ add_address(xml, payment_method_or_reference, options[:shipping_address], options, true)
560
660
  add_purchase_data(xml, money, true, options)
561
661
  add_creditcard(xml, payment_method_or_reference)
562
662
  end
563
663
  end
564
664
 
565
665
  def add_validate_pinless_debit_service(xml)
566
- xml.tag!'pinlessDebitValidateService', {'run' => 'true'}
666
+ xml.tag! 'pinlessDebitValidateService', {'run' => 'true'}
667
+ end
668
+
669
+ def add_threeds_services(xml, options)
670
+ xml.tag! 'payerAuthEnrollService', {'run' => 'true'} if options[:payer_auth_enroll_service]
671
+ if options[:payer_auth_validate_service]
672
+ xml.tag! 'payerAuthValidateService', {'run' => 'true'} do
673
+ xml.tag! 'signedPARes', options[:pares]
674
+ end
675
+ end
676
+ end
677
+
678
+ def lookup_country_code(country_field)
679
+ country_code = Country.find(country_field) rescue nil
680
+ country_code&.code(:alpha2)
567
681
  end
568
682
 
569
683
  # Where we actually build the full SOAP request using builder
570
684
  def build_request(body, options)
571
685
  xml = Builder::XmlMarkup.new :indent => 2
572
- xml.instruct!
573
- xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do
574
- xml.tag! 's:Header' do
575
- xml.tag! 'wsse:Security', {'s:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'} do
576
- xml.tag! 'wsse:UsernameToken' do
577
- xml.tag! 'wsse:Username', @options[:login]
578
- xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'
579
- end
686
+ xml.instruct!
687
+ xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do
688
+ xml.tag! 's:Header' do
689
+ xml.tag! 'wsse:Security', {'s:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'} do
690
+ xml.tag! 'wsse:UsernameToken' do
691
+ xml.tag! 'wsse:Username', @options[:login]
692
+ xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'
580
693
  end
581
694
  end
582
- xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
583
- xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{XSD_VERSION}"} do
584
- add_merchant_data(xml, options)
585
- xml << body
586
- end
695
+ end
696
+ xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
697
+ xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{XSD_VERSION}"} do
698
+ add_merchant_data(xml, options)
699
+ xml << body
587
700
  end
588
701
  end
702
+ end
589
703
  xml.target!
590
704
  end
591
705
 
592
706
  # Contact CyberSource, make the SOAP request, and parse the reply into a
593
707
  # Response object
594
- def commit(request, options)
595
- response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(request, options)))
708
+ def commit(request, action, amount, options)
709
+ begin
710
+ raw_response = ssl_post(test? ? self.test_url : self.live_url, build_request(request, options))
711
+ rescue ResponseError => e
712
+ raw_response = e.response.body
713
+ end
714
+
715
+ begin
716
+ response = parse(raw_response)
717
+ rescue REXML::ParseException => e
718
+ response = { message: e.to_s }
719
+ end
596
720
 
597
- success = response[:decision] == "ACCEPT"
598
- message = @@response_codes[('r' + response[:reasonCode]).to_sym] rescue response[:message]
599
- authorization = success ? [ options[:order_id], response[:requestID], response[:requestToken] ].compact.join(";") : nil
721
+ success = response[:decision] == 'ACCEPT'
722
+ message = response[:message]
723
+
724
+ authorization = success ? authorization_from(response, action, amount, options) : nil
600
725
 
601
726
  Response.new(success, message, response,
602
727
  :test => test?,
@@ -611,16 +736,17 @@ module ActiveMerchant #:nodoc:
611
736
  def parse(xml)
612
737
  reply = {}
613
738
  xml = REXML::Document.new(xml)
614
- if root = REXML::XPath.first(xml, "//c:replyMessage")
739
+ if root = REXML::XPath.first(xml, '//c:replyMessage')
615
740
  root.elements.to_a.each do |node|
616
- case node.name
741
+ case node.expanded_name
617
742
  when 'c:reasonCode'
618
- reply[:message] = reply(node.text)
743
+ reply[:reasonCode] = node.text
744
+ reply[:message] = reason_message(node.text)
619
745
  else
620
746
  parse_element(reply, node)
621
747
  end
622
748
  end
623
- elsif root = REXML::XPath.first(xml, "//soap:Fault")
749
+ elsif root = REXML::XPath.first(xml, '//soap:Fault')
624
750
  parse_element(reply, root)
625
751
  reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}"
626
752
  end
@@ -629,17 +755,27 @@ module ActiveMerchant #:nodoc:
629
755
 
630
756
  def parse_element(reply, node)
631
757
  if node.has_elements?
632
- node.elements.each{|e| parse_element(reply, e) }
758
+ node.elements.each { |e| parse_element(reply, e) }
633
759
  else
634
760
  if node.parent.name =~ /item/
635
- parent = node.parent.name + (node.parent.attributes["id"] ? "_" + node.parent.attributes["id"] : '')
636
- reply[(parent + '_' + node.name).to_sym] = node.text
637
- else
638
- reply[node.name.to_sym] = node.text
761
+ parent = node.parent.name
762
+ parent += '_' + node.parent.attributes['id'] if node.parent.attributes['id']
763
+ parent += '_'
639
764
  end
765
+ reply["#{parent}#{node.name}".to_sym] ||= node.text
640
766
  end
641
767
  return reply
642
768
  end
769
+
770
+ def reason_message(reason_code)
771
+ return if reason_code.blank?
772
+ @@response_codes[:"r#{reason_code}"]
773
+ end
774
+
775
+ def authorization_from(response, action, amount, options)
776
+ [options[:order_id], response[:requestID], response[:requestToken], action, amount,
777
+ options[:currency], response[:subscriptionID]].join(';')
778
+ end
643
779
  end
644
780
  end
645
781
  end