activemerchant 1.45.0 → 1.126.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +2167 -2
  3. data/CONTRIBUTORS +57 -0
  4. data/README.md +62 -41
  5. data/lib/active_merchant/billing/avs_result.rb +25 -28
  6. data/lib/active_merchant/billing/base.rb +11 -35
  7. data/lib/active_merchant/billing/check.rb +28 -24
  8. data/lib/active_merchant/billing/compatibility.rb +10 -12
  9. data/lib/active_merchant/billing/credit_card.rb +141 -69
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  11. data/lib/active_merchant/billing/credit_card_methods.rb +348 -52
  12. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  13. data/lib/active_merchant/billing/gateway.rb +125 -61
  14. data/lib/active_merchant/billing/gateways/adyen.rb +633 -127
  15. data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +883 -195
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -103
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
  21. data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
  24. data/lib/active_merchant/billing/gateways/banwire.rb +24 -13
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +143 -62
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +45 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +13 -10
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -506
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +623 -0
  33. data/lib/active_merchant/billing/gateways/bogus.rb +82 -36
  34. data/lib/active_merchant/billing/gateways/borgun.rb +61 -40
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +21 -2
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +3 -3
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +592 -203
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -4
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +116 -61
  42. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +248 -97
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +70 -26
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +73 -53
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  52. data/lib/active_merchant/billing/gateways/checkout.rb +32 -33
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +340 -0
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  57. data/lib/active_merchant/billing/gateways/conekta.rb +55 -34
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  59. data/lib/active_merchant/billing/gateways/credorax.rb +506 -0
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  61. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  62. data/lib/active_merchant/billing/gateways/cyber_source.rb +637 -221
  63. data/lib/active_merchant/billing/gateways/d_local.rb +303 -0
  64. data/lib/active_merchant/billing/gateways/data_cash.rb +57 -355
  65. data/lib/active_merchant/billing/gateways/decidir.rb +347 -0
  66. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  67. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  68. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  69. data/lib/active_merchant/billing/gateways/ebanx.rb +334 -0
  70. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  71. data/lib/active_merchant/billing/gateways/elavon.rb +377 -250
  72. data/lib/active_merchant/billing/gateways/element.rb +386 -0
  73. data/lib/active_merchant/billing/gateways/epay.rb +92 -71
  74. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  75. data/lib/active_merchant/billing/gateways/eway.rb +85 -73
  76. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  77. data/lib/active_merchant/billing/gateways/eway_rapid.rb +134 -80
  78. data/lib/active_merchant/billing/gateways/exact.rb +37 -36
  79. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  80. data/lib/active_merchant/billing/gateways/fat_zebra.rb +124 -74
  81. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  82. data/lib/active_merchant/billing/gateways/finansbank.rb +4 -5
  83. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  84. data/lib/active_merchant/billing/gateways/first_pay.rb +45 -23
  85. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +184 -87
  86. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  87. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  88. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  89. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  90. data/lib/active_merchant/billing/gateways/garanti.rb +31 -32
  91. data/lib/active_merchant/billing/gateways/global_collect.rb +507 -0
  92. data/lib/active_merchant/billing/gateways/global_transport.rb +25 -15
  93. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  94. data/lib/active_merchant/billing/gateways/hps.rb +252 -68
  95. data/lib/active_merchant/billing/gateways/iats_payments.rb +99 -38
  96. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  97. data/lib/active_merchant/billing/gateways/inspire.rb +48 -48
  98. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  99. data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
  100. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  101. data/lib/active_merchant/billing/gateways/iridium.rb +254 -244
  102. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  103. data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
  104. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +200 -80
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +277 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +95 -85
  111. data/lib/active_merchant/billing/gateways/litle.rb +371 -94
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +146 -123
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +331 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +47 -23
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +60 -44
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +76 -23
  121. data/lib/active_merchant/billing/gateways/mercury.rb +73 -54
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +33 -43
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  124. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  125. data/lib/active_merchant/billing/gateways/migs.rb +101 -37
  126. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
  128. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +30 -34
  129. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  130. data/lib/active_merchant/billing/gateways/monei.rb +422 -0
  131. data/lib/active_merchant/billing/gateways/moneris.rb +236 -72
  132. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  133. data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
  134. data/lib/active_merchant/billing/gateways/nab_transact.rb +87 -68
  135. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  136. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  137. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  138. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  139. data/lib/active_merchant/billing/gateways/netbilling.rb +82 -43
  140. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  141. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  142. data/lib/active_merchant/billing/gateways/nmi.rb +279 -174
  143. data/lib/active_merchant/billing/gateways/ogone.rb +96 -50
  144. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  145. data/lib/active_merchant/billing/gateways/openpay.rb +58 -23
  146. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  147. data/lib/active_merchant/billing/gateways/optimal_payment.rb +87 -69
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  149. data/lib/active_merchant/billing/gateways/orbital.rb +771 -328
  150. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +31 -32
  151. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  152. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  153. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  154. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  155. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +84 -68
  156. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  157. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  158. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  160. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  161. data/lib/active_merchant/billing/gateways/paybox_direct.rb +85 -49
  162. data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
  163. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +67 -41
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  166. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  167. data/lib/active_merchant/billing/gateways/payflow.rb +215 -46
  168. data/lib/active_merchant/billing/gateways/payflow_express.rb +64 -68
  169. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
  170. data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
  171. data/lib/active_merchant/billing/gateways/payment_express.rb +78 -58
  172. data/lib/active_merchant/billing/gateways/paymentez.rb +353 -0
  173. data/lib/active_merchant/billing/gateways/paymill.rb +163 -75
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -7
  175. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +1 -1
  176. data/lib/active_merchant/billing/gateways/paypal.rb +37 -18
  177. data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
  178. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +5 -5
  179. data/lib/active_merchant/billing/gateways/paypal_express.rb +12 -6
  180. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  181. data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
  182. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  183. data/lib/active_merchant/billing/gateways/paystation.rb +96 -91
  184. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  185. data/lib/active_merchant/billing/gateways/payu_latam.rb +479 -0
  186. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  187. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  188. data/lib/active_merchant/billing/gateways/pin.rb +113 -37
  189. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  190. data/lib/active_merchant/billing/gateways/priority.rb +369 -0
  191. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  192. data/lib/active_merchant/billing/gateways/psigate.rb +55 -44
  193. data/lib/active_merchant/billing/gateways/psl_card.rb +32 -40
  194. data/lib/active_merchant/billing/gateways/qbms.rb +86 -76
  195. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  196. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  197. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  200. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -353
  201. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  202. data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
  203. data/lib/active_merchant/billing/gateways/realex.rb +154 -52
  204. data/lib/active_merchant/billing/gateways/redsys.rb +488 -161
  205. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  206. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  207. data/lib/active_merchant/billing/gateways/sage.rb +404 -133
  208. data/lib/active_merchant/billing/gateways/sage_pay.rb +145 -109
  209. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  210. data/lib/active_merchant/billing/gateways/secure_net.rb +62 -54
  211. data/lib/active_merchant/billing/gateways/secure_pay.rb +32 -42
  212. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +36 -27
  213. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  214. data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
  215. data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
  216. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -54
  217. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  218. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  219. data/lib/active_merchant/billing/gateways/spreedly_core.rb +108 -43
  220. data/lib/active_merchant/billing/gateways/stripe.rb +536 -120
  221. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +516 -0
  222. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +19 -25
  223. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  224. data/lib/active_merchant/billing/gateways/tns.rb +16 -217
  225. data/lib/active_merchant/billing/gateways/trans_first.rb +148 -34
  226. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  227. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  228. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  229. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  230. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  231. data/lib/active_merchant/billing/gateways/trust_commerce.rb +162 -89
  232. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  233. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +332 -236
  234. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +185 -72
  235. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  236. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  237. data/lib/active_merchant/billing/gateways/viaklix.rb +19 -31
  238. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  239. data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
  240. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  241. data/lib/active_merchant/billing/gateways/wepay.rb +108 -62
  242. data/lib/active_merchant/billing/gateways/wirecard.rb +52 -43
  243. data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
  244. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  245. data/lib/active_merchant/billing/gateways/worldpay.rb +725 -121
  246. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  247. data/lib/active_merchant/billing/gateways/worldpay_us.rb +79 -39
  248. data/lib/active_merchant/billing/gateways.rb +8 -11
  249. data/lib/active_merchant/billing/model.rb +2 -2
  250. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  251. data/lib/active_merchant/billing/payment_token.rb +1 -1
  252. data/lib/active_merchant/billing/rails.rb +1 -1
  253. data/lib/active_merchant/billing/response.rb +19 -13
  254. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  255. data/lib/active_merchant/billing.rb +3 -0
  256. data/lib/active_merchant/connection.rb +196 -0
  257. data/lib/active_merchant/country.rb +13 -8
  258. data/lib/active_merchant/errors.rb +6 -0
  259. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  260. data/lib/active_merchant/network_connection_retries.rb +78 -0
  261. data/lib/active_merchant/post_data.rb +26 -0
  262. data/lib/active_merchant/posts_data.rb +92 -0
  263. data/lib/active_merchant/version.rb +1 -1
  264. data/lib/active_merchant.rb +14 -59
  265. data/lib/activemerchant.rb +1 -1
  266. data/lib/certs/cacert.pem +3214 -0
  267. data/lib/support/gateway_support.rb +8 -10
  268. data/lib/support/outbound_hosts.rb +13 -10
  269. data/lib/support/ssl_verify.rb +9 -14
  270. data/lib/support/ssl_version.rb +86 -0
  271. metadata +136 -94
  272. checksums.yaml.gz.sig +0 -1
  273. data/lib/active_merchant/billing/gateways/app55.rb +0 -176
  274. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  275. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  278. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  279. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  280. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -291
  281. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -87
  282. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  283. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
  284. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  285. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -385
  286. data/lib/active_merchant/offsite_payments_shim.rb +0 -19
  287. data.tar.gz.sig +0 -0
  288. metadata.gz.sig +0 -0
@@ -0,0 +1,363 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class MundipaggGateway < Gateway
4
+ self.live_url = 'https://api.mundipagg.com/core/v1'
5
+
6
+ self.supported_countries = ['US']
7
+ self.default_currency = 'USD'
8
+ self.supported_cardtypes = %i[visa master american_express discover alelo]
9
+
10
+ self.homepage_url = 'https://www.mundipagg.com/'
11
+ self.display_name = 'Mundipagg'
12
+
13
+ STANDARD_ERROR_CODE_MAPPING = {
14
+ '400' => STANDARD_ERROR_CODE[:processing_error],
15
+ '401' => STANDARD_ERROR_CODE[:config_error],
16
+ '404' => STANDARD_ERROR_CODE[:processing_error],
17
+ '412' => STANDARD_ERROR_CODE[:processing_error],
18
+ '422' => STANDARD_ERROR_CODE[:processing_error],
19
+ '500' => STANDARD_ERROR_CODE[:processing_error]
20
+ }
21
+
22
+ STANDARD_ERROR_MESSAGE_MAPPING = {
23
+ '400' => 'Invalid request;',
24
+ '401' => 'Invalid API key;',
25
+ '404' => 'The requested resource does not exist;',
26
+ '412' => 'Valid parameters but request failed;',
27
+ '422' => 'Invalid parameters;',
28
+ '500' => 'An internal error occurred;'
29
+ }
30
+
31
+ def initialize(options = {})
32
+ requires!(options, :api_key)
33
+ super
34
+ end
35
+
36
+ def purchase(money, payment, options = {})
37
+ post = {}
38
+ add_invoice(post, money, options)
39
+ add_customer_data(post, options) unless payment.is_a?(String)
40
+ add_shipping_address(post, options)
41
+ add_payment(post, payment, options)
42
+ add_submerchant(post, options)
43
+ add_auth_key(post, options)
44
+ commit('sale', post)
45
+ end
46
+
47
+ def authorize(money, payment, options = {})
48
+ post = {}
49
+ add_invoice(post, money, options)
50
+ add_customer_data(post, options) unless payment.is_a?(String)
51
+ add_shipping_address(post, options)
52
+ add_payment(post, payment, options)
53
+ add_capture_flag(post, payment)
54
+ add_submerchant(post, options)
55
+ add_auth_key(post, options)
56
+ commit('authonly', post)
57
+ end
58
+
59
+ def capture(money, authorization, options = {})
60
+ post = {}
61
+ post[:code] = authorization
62
+ add_invoice(post, money, options)
63
+ commit('capture', post, authorization)
64
+ end
65
+
66
+ def refund(money, authorization, options = {})
67
+ add_invoice(post = {}, money, options)
68
+ commit('refund', post, authorization)
69
+ end
70
+
71
+ def void(authorization, options = {})
72
+ commit('void', nil, authorization)
73
+ end
74
+
75
+ def store(payment, options = {})
76
+ post = {}
77
+ options.update(name: payment.name)
78
+ options = add_customer(options) unless options[:customer_id]
79
+ add_payment(post, payment, options)
80
+ commit('store', post, options[:customer_id])
81
+ end
82
+
83
+ def verify(credit_card, options = {})
84
+ MultiResponse.run(:use_first_response) do |r|
85
+ r.process { authorize(100, credit_card, options) }
86
+ r.process(:ignore_result) { void(r.authorization, options) }
87
+ end
88
+ end
89
+
90
+ def supports_scrubbing?
91
+ true
92
+ end
93
+
94
+ def scrub(transcript)
95
+ transcript.
96
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
97
+ gsub(%r(("cvv\\":\\")\d*), '\1[FILTERED]').
98
+ gsub(%r((card\\":{\\"number\\":\\")\d*), '\1[FILTERED]')
99
+ end
100
+
101
+ private
102
+
103
+ def add_customer(options)
104
+ post = {}
105
+ post[:name] = options[:name]
106
+ customer = commit('customer', post)
107
+ options.update(customer_id: customer.authorization)
108
+ end
109
+
110
+ def add_customer_data(post, options)
111
+ post[:customer] = {}
112
+ post[:customer][:email] = options[:email]
113
+ end
114
+
115
+ def add_billing_address(post, type, options)
116
+ if address = (options[:billing_address] || options[:address])
117
+ billing = {}
118
+ address = options[:billing_address] || options[:address]
119
+ billing[:street] = address[:address1].match(/\D+/)[0].strip if address[:address1]
120
+ billing[:number] = address[:address1].match(/\d+/)[0] if address[:address1]
121
+ billing[:compliment] = address[:address2] if address[:address2]
122
+ billing[:city] = address[:city] if address[:city]
123
+ billing[:state] = address[:state] if address[:state]
124
+ billing[:country] = address[:country] if address[:country]
125
+ billing[:zip_code] = address[:zip] if address[:zip]
126
+ billing[:neighborhood] = address[:neighborhood]
127
+ post[:payment][type.to_sym][:card][:billing_address] = billing
128
+ end
129
+ end
130
+
131
+ def add_shipping_address(post, options)
132
+ if address = options[:shipping_address]
133
+ post[:address] = {}
134
+ post[:address][:street] = address[:address1].match(/\D+/)[0].strip if address[:address1]&.match(/\D+/)
135
+ post[:address][:number] = address[:address1].match(/\d+/)[0] if address[:address1]&.match(/\d+/)
136
+ post[:address][:compliment] = address[:address2] if address[:address2]
137
+ post[:address][:city] = address[:city] if address[:city]
138
+ post[:address][:state] = address[:state] if address[:state]
139
+ post[:address][:country] = address[:country] if address[:country]
140
+ post[:address][:zip_code] = address[:zip] if address[:zip]
141
+ end
142
+ end
143
+
144
+ def add_invoice(post, money, options)
145
+ post[:amount] = money
146
+ post[:currency] = (options[:currency] || currency(money))
147
+ end
148
+
149
+ def add_capture_flag(post, payment)
150
+ if voucher?(payment)
151
+ post[:payment][:voucher][:capture] = false
152
+ else
153
+ post[:payment][:credit_card][:capture] = false
154
+ end
155
+ end
156
+
157
+ def add_payment(post, payment, options)
158
+ post[:customer][:name] = payment.name if post[:customer]
159
+ post[:customer_id] = parse_auth(payment)[0] if payment.is_a?(String)
160
+ post[:payment] = {}
161
+ affiliation = options[:gateway_affiliation_id] || @options[:gateway_id]
162
+ post[:payment][:gateway_affiliation_id] = affiliation if affiliation
163
+ post[:payment][:metadata] = { mundipagg_payment_method_code: '1' } if test?
164
+ if voucher?(payment)
165
+ add_voucher(post, payment, options)
166
+ else
167
+ add_credit_card(post, payment, options)
168
+ end
169
+ end
170
+
171
+ def add_credit_card(post, payment, options)
172
+ post[:payment][:payment_method] = 'credit_card'
173
+ post[:payment][:credit_card] = {}
174
+ if payment.is_a?(String)
175
+ post[:payment][:credit_card][:card_id] = parse_auth(payment)[1]
176
+ else
177
+ post[:payment][:credit_card][:card] = {}
178
+ post[:payment][:credit_card][:card][:number] = payment.number
179
+ post[:payment][:credit_card][:card][:holder_name] = payment.name
180
+ post[:payment][:credit_card][:card][:exp_month] = payment.month
181
+ post[:payment][:credit_card][:card][:exp_year] = payment.year
182
+ post[:payment][:credit_card][:card][:cvv] = payment.verification_value
183
+ post[:payment][:credit_card][:card][:holder_document] = options[:holder_document] if options[:holder_document]
184
+ add_billing_address(post, 'credit_card', options)
185
+ end
186
+ end
187
+
188
+ def add_voucher(post, payment, options)
189
+ post[:currency] = 'BRL'
190
+ post[:payment][:payment_method] = 'voucher'
191
+ post[:payment][:voucher] = {}
192
+ post[:payment][:voucher][:card] = {}
193
+ post[:payment][:voucher][:card][:number] = payment.number
194
+ post[:payment][:voucher][:card][:holder_name] = payment.name
195
+ post[:payment][:voucher][:card][:holder_document] = options[:holder_document]
196
+ post[:payment][:voucher][:card][:exp_month] = payment.month
197
+ post[:payment][:voucher][:card][:exp_year] = payment.year
198
+ post[:payment][:voucher][:card][:cvv] = payment.verification_value
199
+ add_billing_address(post, 'voucher', options)
200
+ end
201
+
202
+ def voucher?(payment)
203
+ return false if payment.is_a?(String)
204
+
205
+ %w[sodexo vr].include? card_brand(payment)
206
+ end
207
+
208
+ def add_submerchant(post, options)
209
+ if submerchant = options[:submerchant]
210
+ post[:SubMerchant] = {}
211
+ post[:SubMerchant][:Merchant_Category_Code] = submerchant[:merchant_category_code] if submerchant[:merchant_category_code]
212
+ post[:SubMerchant][:Payment_Facilitator_Code] = submerchant[:payment_facilitator_code] if submerchant[:payment_facilitator_code]
213
+ post[:SubMerchant][:Code] = submerchant[:code] if submerchant[:code]
214
+ post[:SubMerchant][:Name] = submerchant[:name] if submerchant[:name]
215
+ post[:SubMerchant][:Document] = submerchant[:document] if submerchant[:document]
216
+ post[:SubMerchant][:Type] = submerchant[:type] if submerchant[:type]
217
+ post[:SubMerchant][:Phone] = {}
218
+ post[:SubMerchant][:Phone][:Country_Code] = submerchant[:phone][:country_code] if submerchant.dig(:phone, :country_code)
219
+ post[:SubMerchant][:Phone][:Number] = submerchant[:phone][:number] if submerchant.dig(:phone, :number)
220
+ post[:SubMerchant][:Phone][:Area_Code] = submerchant[:phone][:area_code] if submerchant.dig(:phone, :area_code)
221
+ post[:SubMerchant][:Address] = {}
222
+ post[:SubMerchant][:Address][:Street] = submerchant[:address][:street] if submerchant.dig(:address, :street)
223
+ post[:SubMerchant][:Address][:Number] = submerchant[:address][:number] if submerchant.dig(:address, :number)
224
+ post[:SubMerchant][:Address][:Complement] = submerchant[:address][:complement] if submerchant.dig(:address, :complement)
225
+ post[:SubMerchant][:Address][:Neighborhood] = submerchant[:address][:neighborhood] if submerchant.dig(:address, :neighborhood)
226
+ post[:SubMerchant][:Address][:City] = submerchant[:address][:city] if submerchant.dig(:address, :city)
227
+ post[:SubMerchant][:Address][:State] = submerchant[:address][:state] if submerchant.dig(:address, :state)
228
+ post[:SubMerchant][:Address][:Country] = submerchant[:address][:country] if submerchant.dig(:address, :country)
229
+ post[:SubMerchant][:Address][:Zip_Code] = submerchant[:address][:zip_code] if submerchant.dig(:address, :zip_code)
230
+ end
231
+ end
232
+
233
+ def add_auth_key(post, options)
234
+ if authorization_secret_key = options[:authorization_secret_key]
235
+ post[:authorization_secret_key] = authorization_secret_key
236
+ end
237
+ end
238
+
239
+ def headers(authorization_secret_key = nil)
240
+ basic_token = authorization_secret_key || @options[:api_key]
241
+ {
242
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{basic_token}:"),
243
+ 'Content-Type' => 'application/json',
244
+ 'Accept' => 'application/json'
245
+ }
246
+ end
247
+
248
+ def parse(body)
249
+ JSON.parse(body)
250
+ end
251
+
252
+ def url_for(action, auth = nil)
253
+ url = live_url
254
+ case action
255
+ when 'store'
256
+ "#{url}/customers/#{auth}/cards/"
257
+ when 'customer'
258
+ "#{url}/customers/"
259
+ when 'refund', 'void'
260
+ "#{url}/charges/#{auth}/"
261
+ when 'capture'
262
+ "#{url}/charges/#{auth}/capture/"
263
+ else
264
+ "#{url}/charges/"
265
+ end
266
+ end
267
+
268
+ def commit(action, parameters, auth = nil)
269
+ url = url_for(action, auth)
270
+ authorization_secret_key = parameters[:authorization_secret_key] if parameters
271
+ parameters.merge!(parameters[:payment][:credit_card].delete(:card)).delete(:payment) if action == 'store'
272
+ response = if %w[refund void].include? action
273
+ parse(ssl_request(:delete, url, post_data(parameters), headers(authorization_secret_key)))
274
+ else
275
+ parse(ssl_post(url, post_data(parameters), headers(authorization_secret_key)))
276
+ end
277
+
278
+ Response.new(
279
+ success_from(response, action),
280
+ message_from(response),
281
+ response,
282
+ authorization: authorization_from(response, action),
283
+ avs_result: AVSResult.new(code: response['some_avs_response_key']),
284
+ cvv_result: CVVResult.new(response['some_cvv_response_key']),
285
+ test: test?,
286
+ error_code: error_code_from(response, action)
287
+ )
288
+ rescue ResponseError => e
289
+ message = get_error_messages(e)
290
+
291
+ return Response.new(
292
+ false,
293
+ "#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}",
294
+ parse(e.response.body),
295
+ test: test?,
296
+ error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code]
297
+ )
298
+ end
299
+
300
+ def success_from(response, action)
301
+ success = response.try(:[], 'last_transaction').try(:[], 'success') unless action == 'store'
302
+ success = !response.try(:[], 'id').nil? if action == 'store'
303
+ success
304
+ end
305
+
306
+ def message_from(response)
307
+ return gateway_response_errors(response) if gateway_response_errors?(response)
308
+ return response['message'] if response['message']
309
+ return response['last_transaction']['acquirer_message'] if response['last_transaction']
310
+ end
311
+
312
+ def get_error_messages(error)
313
+ parsed_response_body = parse(error.response.body)
314
+ message = parsed_response_body['message']
315
+
316
+ parsed_response_body['errors']&.each do |_type, descriptions|
317
+ message += ' | '
318
+ message += descriptions.join(', ')
319
+ end
320
+
321
+ message
322
+ end
323
+
324
+ def gateway_response_errors?(response)
325
+ response.try(:[], 'last_transaction').try(:[], 'gateway_response').try(:[], 'errors').present?
326
+ end
327
+
328
+ def gateway_response_errors(response)
329
+ error_string = ''
330
+
331
+ response['last_transaction']['gateway_response']['errors']&.each do |error|
332
+ error.each do |_key, value|
333
+ error_string += ' | ' unless error_string.blank?
334
+ error_string += value
335
+ end
336
+ end
337
+
338
+ error_string
339
+ end
340
+
341
+ def authorization_from(response, action)
342
+ return "#{response['customer']['id']}|#{response['id']}" if action == 'store'
343
+
344
+ response['id']
345
+ end
346
+
347
+ def parse_auth(auth)
348
+ auth.split('|')
349
+ end
350
+
351
+ def post_data(parameters = {})
352
+ parameters.to_json
353
+ end
354
+
355
+ def error_code_from(response, action)
356
+ return if success_from(response, action)
357
+ return response['last_transaction']['acquirer_return_code'] if response['last_transaction']
358
+
359
+ STANDARD_ERROR_CODE[:processing_error]
360
+ end
361
+ end
362
+ end
363
+ end
@@ -6,42 +6,40 @@ module ActiveMerchant #:nodoc:
6
6
  # be a rebadged Securepay Australia service, though some differences exist.
7
7
  class NabTransactGateway < Gateway
8
8
  API_VERSION = 'xml-4.2'
9
- PERIODIC_API_VERSION = "spxml-4.2"
9
+ PERIODIC_API_VERSION = 'spxml-4.2'
10
10
 
11
11
  class_attribute :test_periodic_url, :live_periodic_url
12
12
 
13
- self.test_url = 'https://transact.nab.com.au/test/xmlapi/payment'
13
+ self.test_url = 'https://demo.transact.nab.com.au/xmlapi/payment'
14
14
  self.live_url = 'https://transact.nab.com.au/live/xmlapi/payment'
15
- self.test_periodic_url = 'https://transact.nab.com.au/xmlapidemo/periodic'
15
+ self.test_periodic_url = 'https://demo.transact.nab.com.au/xmlapi/periodic'
16
16
  self.live_periodic_url = 'https://transact.nab.com.au/xmlapi/periodic'
17
17
 
18
18
  self.supported_countries = ['AU']
19
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
19
+ self.supported_cardtypes = %i[visa master american_express diners_club jcb]
20
20
 
21
21
  self.homepage_url = 'http://transact.nab.com.au'
22
22
  self.display_name = 'NAB Transact'
23
23
  self.money_format = :cents
24
24
  self.default_currency = 'AUD'
25
25
 
26
- #Transactions currently accepted by NAB Transact XML API
26
+ # Transactions currently accepted by NAB Transact XML API
27
27
  TRANSACTIONS = {
28
- :purchase => 0, #Standard Payment
29
- :refund => 4, #Refund
30
- :void => 6, #Client Reversal (Void)
31
- :unmatched_refund => 666, #Unmatched Refund
32
- :authorization => 10, #Preauthorise
33
- :capture => 11 #Preauthorise Complete (Advice)
28
+ purchase: 0, # Standard Payment
29
+ refund: 4, # Refund
30
+ void: 6, # Client Reversal (Void)
31
+ unmatched_refund: 666, # Unmatched Refund
32
+ authorization: 10, # Preauthorise
33
+ capture: 11 # Preauthorise Complete (Advice)
34
34
  }
35
35
 
36
36
  PERIODIC_TYPES = {
37
- :addcrn => 5,
38
- :editcrn => 5,
39
- :deletecrn => 5,
40
- :trigger => 8
37
+ addcrn: 5,
38
+ deletecrn: 5,
39
+ trigger: 8
41
40
  }
42
41
 
43
- SUCCESS_CODES = [ '00', '08', '11', '16', '77' ]
44
-
42
+ SUCCESS_CODES = %w[00 08 11 16 77]
45
43
 
46
44
  def initialize(options = {})
47
45
  requires!(options, :login, :password)
@@ -50,12 +48,9 @@ module ActiveMerchant #:nodoc:
50
48
 
51
49
  def purchase(money, credit_card_or_stored_id, options = {})
52
50
  if credit_card_or_stored_id.respond_to?(:number)
53
- #Credit card for instant payment
54
51
  commit :purchase, build_purchase_request(money, credit_card_or_stored_id, options)
55
52
  else
56
- #Triggered payment for an existing stored credit card
57
- options[:billing_id] = credit_card_or_stored_id.to_s
58
- commit_periodic build_periodic_item(:trigger, money, nil, options)
53
+ commit_periodic(:trigger, build_purchase_using_stored_card_request(money, credit_card_or_stored_id, options))
59
54
  end
60
55
  end
61
56
 
@@ -75,14 +70,25 @@ module ActiveMerchant #:nodoc:
75
70
  commit :capture, build_reference_request(money, authorization, options)
76
71
  end
77
72
 
78
- def store(creditcard, options = {})
79
- requires!(options, :billing_id, :amount)
80
- commit_periodic(build_periodic_item(:addcrn, options[:amount], creditcard, options))
73
+ def store(credit_card, options = {})
74
+ commit_periodic(:addcrn, build_store_request(credit_card, options))
81
75
  end
82
76
 
83
77
  def unstore(identification, options = {})
84
- options[:billing_id] = identification
85
- commit_periodic(build_periodic_item(:deletecrn, options[:amount], nil, options))
78
+ commit_periodic(:deletecrn, build_unstore_request(identification, options))
79
+ end
80
+
81
+ def supports_scrubbing?
82
+ true
83
+ end
84
+
85
+ def scrub(transcript)
86
+ return '' if transcript.blank?
87
+
88
+ transcript.
89
+ gsub(%r((<cardNumber>)[^<]+(<))i, '\1[FILTERED]\2').
90
+ gsub(%r((<cvv>)[^<]+(<))i, '\1[FILTERED]\2').
91
+ gsub(%r((<password>)[^<]+(<))i, '\1[FILTERED]\2')
86
92
  end
87
93
 
88
94
  private
@@ -90,15 +96,15 @@ module ActiveMerchant #:nodoc:
90
96
  def add_metadata(xml, options)
91
97
  if options[:merchant_name] || options[:merchant_location]
92
98
  xml.tag! 'metadata' do
93
- xml.tag! 'meta', :name => 'ca_name', :value => options[:merchant_name] if options[:merchant_name]
94
- xml.tag! 'meta', :name => 'ca_location', :value => options[:merchant_location] if options[:merchant_location]
99
+ xml.tag! 'meta', name: 'ca_name', value: options[:merchant_name] if options[:merchant_name]
100
+ xml.tag! 'meta', name: 'ca_location', value: options[:merchant_location] if options[:merchant_location]
95
101
  end
96
102
  end
97
103
  end
98
104
 
99
105
  def build_purchase_request(money, credit_card, options)
100
106
  xml = Builder::XmlMarkup.new
101
- xml.tag! 'amount', amount(money)
107
+ xml.tag! 'amount', localized_amount(money, options[:currency] || currency(money))
102
108
  xml.tag! 'currency', options[:currency] || currency(money)
103
109
  xml.tag! 'purchaseOrderNo', options[:order_id].to_s.gsub(/[ ']/, '')
104
110
 
@@ -118,7 +124,7 @@ module ActiveMerchant #:nodoc:
118
124
 
119
125
  transaction_id, order_id, preauth_id, original_amount = reference.split('*')
120
126
 
121
- xml.tag! 'amount', (money ? amount(money) : original_amount)
127
+ xml.tag! 'amount', (money ? localized_amount(money, options[:currency] || currency(money)) : original_amount)
122
128
  xml.tag! 'currency', options[:currency] || currency(money)
123
129
  xml.tag! 'txnID', transaction_id
124
130
  xml.tag! 'purchaseOrderNo', order_id
@@ -129,7 +135,7 @@ module ActiveMerchant #:nodoc:
129
135
  xml.target!
130
136
  end
131
137
 
132
- #Generate payment request XML
138
+ # Generate payment request XML
133
139
  # - API is set to allow multiple Txn's but currently only allows one
134
140
  # - txnSource = 23 - (XML)
135
141
  def build_request(action, body)
@@ -150,8 +156,8 @@ module ActiveMerchant #:nodoc:
150
156
 
151
157
  xml.tag! 'RequestType', 'Payment'
152
158
  xml.tag! 'Payment' do
153
- xml.tag! 'TxnList', "count" => 1 do
154
- xml.tag! 'Txn', "ID" => 1 do
159
+ xml.tag! 'TxnList', 'count' => 1 do
160
+ xml.tag! 'Txn', 'ID' => 1 do
155
161
  xml.tag! 'txnType', TRANSACTIONS[action]
156
162
  xml.tag! 'txnSource', 23
157
163
  xml << body
@@ -163,27 +169,7 @@ module ActiveMerchant #:nodoc:
163
169
  xml.target!
164
170
  end
165
171
 
166
- def build_periodic_item(action, money, credit_card, options)
167
- xml = Builder::XmlMarkup.new
168
-
169
- xml.tag! 'actionType', action.to_s
170
- xml.tag! 'periodicType', PERIODIC_TYPES[action] if PERIODIC_TYPES[action]
171
- xml.tag! 'currency', options[:currency] || currency(money)
172
- xml.tag! 'crn', options[:billing_id]
173
-
174
- if credit_card
175
- xml.tag! 'CreditCardInfo' do
176
- xml.tag! 'cardNumber', credit_card.number
177
- xml.tag! 'expiryDate', expdate(credit_card)
178
- xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
179
- end
180
- end
181
- xml.tag! 'amount', amount(money)
182
-
183
- xml.target!
184
- end
185
-
186
- def build_periodic_request(body)
172
+ def build_periodic_request(action, body)
187
173
  xml = Builder::XmlMarkup.new
188
174
  xml.instruct!
189
175
  xml.tag! 'NABTransactMessage' do
@@ -201,8 +187,10 @@ module ActiveMerchant #:nodoc:
201
187
 
202
188
  xml.tag! 'RequestType', 'Periodic'
203
189
  xml.tag! 'Periodic' do
204
- xml.tag! 'PeriodicList', "count" => 1 do
205
- xml.tag! 'PeriodicItem', "ID" => 1 do
190
+ xml.tag! 'PeriodicList', 'count' => 1 do
191
+ xml.tag! 'PeriodicItem', 'ID' => 1 do
192
+ xml.tag! 'actionType', action.to_s
193
+ xml.tag! 'periodicType', PERIODIC_TYPES[action] if PERIODIC_TYPES[action]
206
194
  xml << body
207
195
  end
208
196
  end
@@ -212,29 +200,61 @@ module ActiveMerchant #:nodoc:
212
200
  xml.target!
213
201
  end
214
202
 
203
+ def build_purchase_using_stored_card_request(money, identification, options)
204
+ xml = Builder::XmlMarkup.new
205
+
206
+ xml.tag! 'crn', identification
207
+ xml.tag! 'currency', options[:currency] || currency(money)
208
+ xml.tag! 'amount', localized_amount(money, options[:currency] || currency(money))
209
+
210
+ xml.target!
211
+ end
212
+
213
+ def build_store_request(credit_card, options)
214
+ xml = Builder::XmlMarkup.new
215
+
216
+ xml.tag! 'crn', options[:billing_id] || SecureRandom.hex(10)
217
+ xml.tag! 'CreditCardInfo' do
218
+ xml.tag! 'cardNumber', credit_card.number
219
+ xml.tag! 'expiryDate', expdate(credit_card)
220
+ xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
221
+ end
222
+
223
+ xml.target!
224
+ end
225
+
226
+ def build_unstore_request(identification, options)
227
+ xml = Builder::XmlMarkup.new
228
+
229
+ xml.tag! 'crn', identification
230
+ xml.target!
231
+ end
232
+
215
233
  def commit(action, request)
216
234
  response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(action, request)))
217
235
 
218
236
  Response.new(success?(response), message_from(response), response,
219
- :test => test?,
220
- :authorization => authorization_from(response)
221
- )
237
+ test: test?,
238
+ authorization: authorization_from(action, response))
222
239
  end
223
240
 
224
- def commit_periodic(request)
225
- response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, build_periodic_request(request)))
241
+ def commit_periodic(action, request)
242
+ response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, build_periodic_request(action, request)))
226
243
  Response.new(success?(response), message_from(response), response,
227
- :test => test?,
228
- :authorization => authorization_from(response)
229
- )
244
+ test: test?,
245
+ authorization: authorization_from(action, response))
230
246
  end
231
247
 
232
248
  def success?(response)
233
249
  SUCCESS_CODES.include?(response[:response_code])
234
250
  end
235
251
 
236
- def authorization_from(response)
237
- [response[:txn_id], response[:purchase_order_no], response[:preauth_id], response[:amount]].join('*')
252
+ def authorization_from(action, response)
253
+ if action == :addcrn
254
+ response[:crn]
255
+ else
256
+ [response[:txn_id], response[:purchase_order_no], response[:preauth_id], response[:amount]].join('*')
257
+ end
238
258
  end
239
259
 
240
260
  def message_from(response)
@@ -259,7 +279,7 @@ module ActiveMerchant #:nodoc:
259
279
 
260
280
  def parse_element(response, node)
261
281
  if node.has_elements?
262
- node.elements.each{|element| parse_element(response, element) }
282
+ node.elements.each { |element| parse_element(response, element) }
263
283
  else
264
284
  response[node.name.underscore.to_sym] = node.text
265
285
  end
@@ -274,7 +294,6 @@ module ActiveMerchant #:nodoc:
274
294
  def request_timeout
275
295
  @options[:request_timeout] || 60
276
296
  end
277
-
278
297
  end
279
298
  end
280
299
  end