activemerchant 1.79.2 → 1.129.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +1391 -0
  3. data/README.md +29 -14
  4. data/lib/active_merchant/billing/avs_result.rb +25 -28
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +55 -22
  7. data/lib/active_merchant/billing/compatibility.rb +10 -12
  8. data/lib/active_merchant/billing/credit_card.rb +82 -62
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  10. data/lib/active_merchant/billing/credit_card_methods.rb +328 -58
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +61 -56
  13. data/lib/active_merchant/billing/gateways/adyen.rb +562 -87
  14. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  15. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +35 -36
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +297 -196
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +94 -98
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +64 -66
  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 +12 -12
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +140 -69
  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 +115 -115
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +39 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -2
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +87 -58
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +405 -104
  33. data/lib/active_merchant/billing/gateways/bogus.rb +34 -30
  34. data/lib/active_merchant/billing/gateways/borgun.rb +97 -47
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +20 -20
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -3
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +561 -259
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +53 -54
  42. data/lib/active_merchant/billing/gateways/cams.rb +31 -31
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +85 -33
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +187 -169
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +24 -25
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +9 -7
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +43 -27
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +62 -52
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +63 -62
  52. data/lib/active_merchant/billing/gateways/checkout.rb +21 -23
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +391 -113
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -3
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +40 -41
  56. data/lib/active_merchant/billing/gateways/commerce_hub.rb +361 -0
  57. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  58. data/lib/active_merchant/billing/gateways/conekta.rb +35 -30
  59. data/lib/active_merchant/billing/gateways/creditcall.rb +59 -59
  60. data/lib/active_merchant/billing/gateways/credorax.rb +326 -145
  61. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  62. data/lib/active_merchant/billing/gateways/culqi.rb +53 -53
  63. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  64. data/lib/active_merchant/billing/gateways/cyber_source.rb +566 -208
  65. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +456 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +342 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +40 -56
  68. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  69. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  70. data/lib/active_merchant/billing/gateways/dibs.rb +34 -40
  71. data/lib/active_merchant/billing/gateways/digitzs.rb +48 -45
  72. data/lib/active_merchant/billing/gateways/ebanx.rb +110 -60
  73. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  74. data/lib/active_merchant/billing/gateways/elavon.rb +351 -189
  75. data/lib/active_merchant/billing/gateways/element.rb +106 -56
  76. data/lib/active_merchant/billing/gateways/epay.rb +74 -64
  77. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  78. data/lib/active_merchant/billing/gateways/eway.rb +74 -73
  79. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  80. data/lib/active_merchant/billing/gateways/eway_rapid.rb +105 -60
  81. data/lib/active_merchant/billing/gateways/exact.rb +29 -37
  82. data/lib/active_merchant/billing/gateways/ezic.rb +21 -22
  83. data/lib/active_merchant/billing/gateways/fat_zebra.rb +70 -48
  84. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  85. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -4
  86. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  87. data/lib/active_merchant/billing/gateways/first_pay.rb +33 -13
  88. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +106 -105
  89. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash.rb +36 -36
  91. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +2 -2
  92. data/lib/active_merchant/billing/gateways/forte.rb +70 -40
  93. data/lib/active_merchant/billing/gateways/garanti.rb +24 -31
  94. data/lib/active_merchant/billing/gateways/global_collect.rb +378 -154
  95. data/lib/active_merchant/billing/gateways/global_transport.rb +12 -13
  96. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  97. data/lib/active_merchant/billing/gateways/hps.rb +236 -69
  98. data/lib/active_merchant/billing/gateways/iats_payments.rb +61 -39
  99. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  100. data/lib/active_merchant/billing/gateways/inspire.rb +41 -47
  101. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  102. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  103. data/lib/active_merchant/billing/gateways/ipp.rb +25 -24
  104. data/lib/active_merchant/billing/gateways/iridium.rb +243 -244
  105. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  106. data/lib/active_merchant/billing/gateways/iveri.rb +73 -34
  107. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  108. data/lib/active_merchant/billing/gateways/jetpay.rb +145 -152
  109. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +154 -159
  110. data/lib/active_merchant/billing/gateways/komoju.rb +16 -16
  111. data/lib/active_merchant/billing/gateways/kushki.rb +127 -57
  112. data/lib/active_merchant/billing/gateways/latitude19.rb +111 -115
  113. data/lib/active_merchant/billing/gateways/linkpoint.rb +82 -85
  114. data/lib/active_merchant/billing/gateways/litle.rb +247 -53
  115. data/lib/active_merchant/billing/gateways/mastercard.rb +41 -23
  116. data/lib/active_merchant/billing/gateways/maxipago.rb +5 -5
  117. data/lib/active_merchant/billing/gateways/mercado_pago.rb +135 -49
  118. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +62 -29
  119. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  120. data/lib/active_merchant/billing/gateways/merchant_partners.rb +40 -40
  121. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  122. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +42 -44
  123. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +52 -14
  124. data/lib/active_merchant/billing/gateways/mercury.rb +47 -51
  125. data/lib/active_merchant/billing/gateways/metrics_global.rb +32 -42
  126. data/lib/active_merchant/billing/gateways/micropayment.rb +42 -45
  127. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  128. data/lib/active_merchant/billing/gateways/migs.rb +45 -40
  129. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  130. data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -2
  131. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +29 -31
  132. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  133. data/lib/active_merchant/billing/gateways/monei.rb +255 -138
  134. data/lib/active_merchant/billing/gateways/moneris.rb +226 -88
  135. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  136. data/lib/active_merchant/billing/gateways/mundipagg.rb +117 -43
  137. data/lib/active_merchant/billing/gateways/nab_transact.rb +28 -31
  138. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +13 -15
  139. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  140. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  141. data/lib/active_merchant/billing/gateways/netbanx.rb +167 -80
  142. data/lib/active_merchant/billing/gateways/netbilling.rb +27 -30
  143. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  144. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  145. data/lib/active_merchant/billing/gateways/nmi.rb +134 -48
  146. data/lib/active_merchant/billing/gateways/ogone.rb +88 -58
  147. data/lib/active_merchant/billing/gateways/omise.rb +30 -31
  148. data/lib/active_merchant/billing/gateways/openpay.rb +45 -26
  149. data/lib/active_merchant/billing/gateways/opp.rb +166 -144
  150. data/lib/active_merchant/billing/gateways/optimal_payment.rb +67 -64
  151. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  152. data/lib/active_merchant/billing/gateways/orbital.rb +726 -382
  153. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +26 -27
  154. data/lib/active_merchant/billing/gateways/pagarme.rb +47 -56
  155. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  156. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  157. data/lib/active_merchant/billing/gateways/pay_conex.rb +39 -40
  158. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +65 -65
  159. data/lib/active_merchant/billing/gateways/pay_hub.rb +39 -39
  160. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  161. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +70 -54
  162. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  163. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  164. data/lib/active_merchant/billing/gateways/paybox_direct.rb +71 -47
  165. data/lib/active_merchant/billing/gateways/payeezy.rb +159 -32
  166. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  167. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +41 -36
  168. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  169. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  170. data/lib/active_merchant/billing/gateways/payflow.rb +178 -54
  171. data/lib/active_merchant/billing/gateways/payflow_express.rb +61 -65
  172. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +0 -1
  173. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -2
  174. data/lib/active_merchant/billing/gateways/payment_express.rb +66 -58
  175. data/lib/active_merchant/billing/gateways/paymentez.rb +114 -25
  176. data/lib/active_merchant/billing/gateways/paymill.rb +134 -133
  177. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  178. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  179. data/lib/active_merchant/billing/gateways/paypal.rb +27 -14
  180. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  181. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +2 -2
  182. data/lib/active_merchant/billing/gateways/paypal_express.rb +5 -2
  183. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  185. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  186. data/lib/active_merchant/billing/gateways/paystation.rb +79 -82
  187. data/lib/active_merchant/billing/gateways/payu_in.rb +59 -58
  188. data/lib/active_merchant/billing/gateways/payu_latam.rb +139 -97
  189. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  190. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  191. data/lib/active_merchant/billing/gateways/pin.rb +87 -34
  192. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  193. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  194. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  195. data/lib/active_merchant/billing/gateways/pro_pay.rb +139 -140
  196. data/lib/active_merchant/billing/gateways/psigate.rb +44 -44
  197. data/lib/active_merchant/billing/gateways/psl_card.rb +29 -37
  198. data/lib/active_merchant/billing/gateways/qbms.rb +75 -76
  199. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  200. data/lib/active_merchant/billing/gateways/quickbooks.rb +142 -55
  201. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +103 -107
  202. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +156 -158
  203. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +7 -8
  204. data/lib/active_merchant/billing/gateways/quickpay.rb +1 -3
  205. data/lib/active_merchant/billing/gateways/qvalent.rb +137 -68
  206. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  207. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  208. data/lib/active_merchant/billing/gateways/realex.rb +132 -50
  209. data/lib/active_merchant/billing/gateways/redsys.rb +382 -186
  210. data/lib/active_merchant/billing/gateways/s5.rb +16 -16
  211. data/lib/active_merchant/billing/gateways/safe_charge.rb +83 -47
  212. data/lib/active_merchant/billing/gateways/sage.rb +49 -48
  213. data/lib/active_merchant/billing/gateways/sage_pay.rb +76 -83
  214. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  215. data/lib/active_merchant/billing/gateways/secure_net.rb +32 -40
  216. data/lib/active_merchant/billing/gateways/secure_pay.rb +30 -40
  217. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +23 -26
  218. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  219. data/lib/active_merchant/billing/gateways/securion_pay.rb +69 -31
  220. data/lib/active_merchant/billing/gateways/shift4.rb +342 -0
  221. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  222. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -53
  223. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  224. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  225. data/lib/active_merchant/billing/gateways/spreedly_core.rb +66 -47
  226. data/lib/active_merchant/billing/gateways/stripe.rb +309 -148
  227. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +556 -0
  228. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +18 -23
  229. data/lib/active_merchant/billing/gateways/telr.rb +46 -48
  230. data/lib/active_merchant/billing/gateways/tns.rb +8 -7
  231. data/lib/active_merchant/billing/gateways/trans_first.rb +37 -37
  232. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +249 -245
  233. data/lib/active_merchant/billing/gateways/transact_pro.rb +25 -27
  234. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  235. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  236. data/lib/active_merchant/billing/gateways/trexle.rb +22 -18
  237. data/lib/active_merchant/billing/gateways/trust_commerce.rb +161 -88
  238. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  239. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +231 -238
  240. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +129 -55
  241. data/lib/active_merchant/billing/gateways/vanco.rb +42 -33
  242. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  243. data/lib/active_merchant/billing/gateways/viaklix.rb +18 -22
  244. data/lib/active_merchant/billing/gateways/visanet_peru.rb +115 -74
  245. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  246. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  247. data/lib/active_merchant/billing/gateways/wepay.rb +38 -41
  248. data/lib/active_merchant/billing/gateways/wirecard.rb +36 -37
  249. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  250. data/lib/active_merchant/billing/gateways/world_net.rb +39 -38
  251. data/lib/active_merchant/billing/gateways/worldpay.rb +756 -142
  252. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +73 -83
  253. data/lib/active_merchant/billing/gateways/worldpay_us.rb +31 -31
  254. data/lib/active_merchant/billing/model.rb +2 -2
  255. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +3 -3
  256. data/lib/active_merchant/billing/rails.rb +1 -1
  257. data/lib/active_merchant/billing/response.rb +32 -13
  258. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  259. data/lib/active_merchant/billing.rb +1 -0
  260. data/lib/active_merchant/connection.rb +24 -38
  261. data/lib/active_merchant/country.rb +9 -5
  262. data/lib/active_merchant/errors.rb +4 -1
  263. data/lib/active_merchant/net_http_ssl_connection.rb +2 -0
  264. data/lib/active_merchant/network_connection_retries.rb +28 -31
  265. data/lib/active_merchant/post_data.rb +5 -3
  266. data/lib/active_merchant/posts_data.rb +5 -7
  267. data/lib/active_merchant/version.rb +1 -1
  268. data/lib/active_merchant.rb +3 -3
  269. data/lib/activemerchant.rb +1 -1
  270. data/lib/certs/cacert.pem +1592 -2329
  271. data/lib/support/gateway_support.rb +8 -10
  272. data/lib/support/ssl_verify.rb +9 -14
  273. data/lib/support/ssl_version.rb +9 -10
  274. metadata +98 -37
  275. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  278. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  279. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -309
@@ -7,9 +7,9 @@ module ActiveMerchant #:nodoc:
7
7
  self.test_url = 'https://ccapi-stg.paymentez.com/v2/'
8
8
  self.live_url = 'https://ccapi.paymentez.com/v2/'
9
9
 
10
- self.supported_countries = %w[MX EC VE CO BR CL]
10
+ self.supported_countries = %w[MX EC CO BR CL PE]
11
11
  self.default_currency = 'USD'
12
- self.supported_cardtypes = %i[visa master american_express diners_club]
12
+ self.supported_cardtypes = %i[visa master american_express diners_club elo alia olimpica discover maestro sodexo carnet unionpay jcb]
13
13
 
14
14
  self.homepage_url = 'https://secure.paymentez.com/'
15
15
  self.display_name = 'Paymentez'
@@ -34,11 +34,21 @@ module ActiveMerchant #:nodoc:
34
34
  28 => :card_declined
35
35
  }.freeze
36
36
 
37
+ SUCCESS_STATUS = ['success', 'pending', 1, 0]
38
+
37
39
  CARD_MAPPING = {
38
40
  'visa' => 'vi',
39
41
  'master' => 'mc',
40
42
  'american_express' => 'ax',
41
- 'diners_club' => 'di'
43
+ 'diners_club' => 'di',
44
+ 'elo' => 'el',
45
+ 'discover' => 'dc',
46
+ 'maestro' => 'ms',
47
+ 'sodexo' => 'sx',
48
+ 'olimpica' => 'ol',
49
+ 'carnet' => 'ct',
50
+ 'unionpay' => 'up',
51
+ 'jcb' => 'jc'
42
52
  }.freeze
43
53
 
44
54
  def initialize(options = {})
@@ -52,29 +62,48 @@ module ActiveMerchant #:nodoc:
52
62
  add_invoice(post, money, options)
53
63
  add_payment(post, payment)
54
64
  add_customer_data(post, options)
65
+ add_extra_params(post, options)
55
66
  action = payment.is_a?(String) ? 'debit' : 'debit_cc'
56
67
 
57
68
  commit_transaction(action, post)
58
69
  end
59
70
 
60
71
  def authorize(money, payment, options = {})
72
+ return purchase(money, payment, options) if options[:otp_flow]
73
+
61
74
  post = {}
62
75
 
63
76
  add_invoice(post, money, options)
64
77
  add_payment(post, payment)
65
78
  add_customer_data(post, options)
79
+ add_extra_params(post, options)
66
80
 
67
81
  commit_transaction('authorize', post)
68
82
  end
69
83
 
70
- def capture(_money, authorization, _options = {})
71
- post = { transaction: { id: authorization } }
84
+ def capture(money, authorization, options = {})
85
+ post = {
86
+ transaction: { id: authorization }
87
+ }
88
+ verify_flow = options[:type] && options[:value]
72
89
 
73
- commit_transaction('capture', post)
90
+ if verify_flow
91
+ add_customer_data(post, options)
92
+ add_verify_value(post, options)
93
+ elsif money
94
+ post[:order] = { amount: amount(money).to_f }
95
+ end
96
+
97
+ action = verify_flow ? 'verify' : 'capture'
98
+ commit_transaction(action, post)
74
99
  end
75
100
 
76
- def refund(_money, authorization, options = {})
77
- void(authorization, options)
101
+ def refund(money, authorization, options = {})
102
+ post = { transaction: { id: authorization } }
103
+ post[:order] = { amount: amount(money).to_f } if money
104
+ add_more_info(post, options)
105
+
106
+ commit_transaction('refund', post)
78
107
  end
79
108
 
80
109
  def void(authorization, _options = {})
@@ -104,30 +133,37 @@ module ActiveMerchant #:nodoc:
104
133
  end
105
134
 
106
135
  def unstore(identification, options = {})
107
- post = { card: { token: identification }, user: { id: options[:user_id] }}
136
+ post = { card: { token: identification }, user: { id: options[:user_id] } }
108
137
  commit_card('delete', post)
109
138
  end
110
139
 
140
+ def inquire(authorization, options = {})
141
+ commit_transaction('inquire', authorization)
142
+ end
143
+
111
144
  def supports_scrubbing?
112
145
  true
113
146
  end
114
147
 
115
148
  def scrub(transcript)
116
- transcript
117
- .gsub(%r{(\\?"number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]')
118
- .gsub(%r{(\\?"cvc\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]')
119
- .gsub(%r{(Auth-Token: )([A-Za-z0-9=]+)}, '\1[FILTERED]')
149
+ transcript.
150
+ gsub(%r{(\\?"number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
151
+ gsub(%r{(\\?"cvc\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
152
+ gsub(%r{(Auth-Token: )([A-Za-z0-9=]+)}, '\1[FILTERED]')
120
153
  end
121
154
 
122
155
  private
123
156
 
124
157
  def add_customer_data(post, options)
125
- requires!(options, :user_id, :email)
158
+ requires!(options, :user_id)
126
159
  post[:user] ||= {}
127
160
  post[:user][:id] = options[:user_id]
128
- post[:user][:email] = options[:email]
161
+ post[:user][:email] = options[:email] if options[:email]
129
162
  post[:user][:ip_address] = options[:ip] if options[:ip]
130
163
  post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
164
+ if phone = options[:phone] || options.dig(:billing_address, :phone)
165
+ post[:user][:phone] = phone
166
+ end
131
167
  end
132
168
 
133
169
  def add_invoice(post, money, options)
@@ -159,19 +195,68 @@ module ActiveMerchant #:nodoc:
159
195
  end
160
196
  end
161
197
 
198
+ def add_verify_value(post, options)
199
+ post[:type] = options[:type] if options[:type]
200
+ post[:value] = options[:value] if options[:value]
201
+ end
202
+
203
+ def add_extra_params(post, options)
204
+ extra_params = {}
205
+ extra_params.merge!(options[:extra_params]) if options[:extra_params]
206
+
207
+ add_external_mpi_fields(extra_params, options)
208
+
209
+ post['extra_params'] = extra_params unless extra_params.empty?
210
+ end
211
+
212
+ def add_external_mpi_fields(extra_params, options)
213
+ three_d_secure_options = options[:three_d_secure]
214
+ return unless three_d_secure_options
215
+
216
+ auth_data = {
217
+ cavv: three_d_secure_options[:cavv],
218
+ xid: three_d_secure_options[:xid],
219
+ eci: three_d_secure_options[:eci],
220
+ version: three_d_secure_options[:version],
221
+ reference_id: three_d_secure_options[:three_ds_server_trans_id],
222
+ status: three_d_secure_options[:authentication_response_status] || three_d_secure_options[:directory_response_status]
223
+ }.compact
224
+
225
+ return if auth_data.empty?
226
+
227
+ extra_params[:auth_data] = auth_data
228
+ end
229
+
230
+ def add_more_info(post, options)
231
+ post[:more_info] = options[:more_info] if options[:more_info]
232
+ end
233
+
162
234
  def parse(body)
163
235
  JSON.parse(body)
164
236
  end
165
237
 
166
238
  def commit_raw(object, action, parameters)
167
- url = "#{(test? ? test_url : live_url)}#{object}/#{action}"
239
+ if action == 'inquire'
240
+ url = "#{(test? ? test_url : live_url)}#{object}/#{parameters}"
241
+ begin
242
+ raw_response = ssl_get(url, headers)
243
+ rescue ResponseError => e
244
+ raw_response = e.response.body
245
+ end
246
+ else
247
+ url = "#{(test? ? test_url : live_url)}#{object}/#{action}"
248
+ begin
249
+ raw_response = ssl_post(url, post_data(parameters), headers)
250
+ rescue ResponseError => e
251
+ raw_response = e.response.body
252
+ end
253
+ end
168
254
 
169
255
  begin
170
- raw_response = ssl_post(url, post_data(parameters), headers)
171
- rescue ResponseError => e
172
- raw_response = e.response.body
256
+ parse(raw_response)
257
+ rescue JSON::ParserError
258
+ { 'status' => 'Internal server error' }
173
259
  end
174
- parse(raw_response)
175
260
  end
176
261
 
177
262
  def commit_transaction(action, parameters)
@@ -206,20 +291,25 @@ module ActiveMerchant #:nodoc:
206
291
  end
207
292
 
208
293
  def success_from(response)
209
- !response.include?('error') && (response['status'] || response['transaction']['status']) == 'success'
294
+ return false if response.include?('error')
295
+
296
+ SUCCESS_STATUS.include?(response['status'] || response['transaction']['status'])
210
297
  end
211
298
 
212
299
  def card_success_from(response)
213
300
  return false if response.include?('error')
214
301
  return true if response['message'] == 'card deleted'
302
+
215
303
  response['card']['status'] == 'valid'
216
304
  end
217
305
 
218
306
  def message_from(response)
307
+ return response['detail'] if response['detail'].present?
308
+
219
309
  if !success_from(response) && response['error']
220
310
  response['error'] && response['error']['type']
221
311
  else
222
- response['transaction'] && response['transaction']['message']
312
+ (response['transaction'] && response['transaction']['message']) || (response['message'])
223
313
  end
224
314
  end
225
315
 
@@ -250,11 +340,10 @@ module ActiveMerchant #:nodoc:
250
340
 
251
341
  def error_code_from(response)
252
342
  return if success_from(response)
343
+
253
344
  if response['transaction']
254
345
  detail = response['transaction']['status_detail']
255
- if STANDARD_ERROR_CODE_MAPPING.include?(detail)
256
- return STANDARD_ERROR_CODE[STANDARD_ERROR_CODE_MAPPING[detail]]
257
- end
346
+ return STANDARD_ERROR_CODE[STANDARD_ERROR_CODE_MAPPING[detail]] if STANDARD_ERROR_CODE_MAPPING.include?(detail)
258
347
  elsif response['error']
259
348
  return STANDARD_ERROR_CODE[:config_error]
260
349
  end
@@ -5,19 +5,19 @@ module ActiveMerchant #:nodoc:
5
5
  GI GR HR HU IE IL IM IS IT LI LT LU LV MC MT
6
6
  NL NO PL PT RO SE SI SK TR VA)
7
7
 
8
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :union_pay, :jcb]
8
+ self.supported_cardtypes = %i[visa master american_express diners_club discover union_pay jcb]
9
9
  self.homepage_url = 'https://paymill.com'
10
10
  self.display_name = 'PAYMILL'
11
11
  self.money_format = :cents
12
12
  self.default_currency = 'EUR'
13
- self.live_url = "https://api.paymill.com/v2/"
13
+ self.live_url = 'https://api.paymill.com/v2/'
14
14
 
15
15
  def initialize(options = {})
16
16
  requires!(options, :public_key, :private_key)
17
17
  super
18
18
  end
19
19
 
20
- def purchase(money, payment_method, options={})
20
+ def purchase(money, payment_method, options = {})
21
21
  action_with_token(:purchase, money, payment_method, options)
22
22
  end
23
23
 
@@ -35,7 +35,7 @@ module ActiveMerchant #:nodoc:
35
35
  commit(:post, 'transactions', post)
36
36
  end
37
37
 
38
- def refund(money, authorization, options={})
38
+ def refund(money, authorization, options = {})
39
39
  post = {}
40
40
 
41
41
  post[:amount] = amount(money)
@@ -43,11 +43,16 @@ module ActiveMerchant #:nodoc:
43
43
  commit(:post, "refunds/#{transaction_id(authorization)}", post)
44
44
  end
45
45
 
46
- def void(authorization, options={})
46
+ def void(authorization, options = {})
47
47
  commit(:delete, "preauthorizations/#{preauth(authorization)}")
48
48
  end
49
49
 
50
- def store(credit_card, options={})
50
+ def store(credit_card, options = {})
51
+ # The store request requires a currency and amount of at least $1 USD.
52
+ # This is used for an authorization that is handled internally by Paymill.
53
+ options[:currency] = 'USD'
54
+ options[:money] = 100
55
+
51
56
  save_card(credit_card, options)
52
57
  end
53
58
 
@@ -64,7 +69,7 @@ module ActiveMerchant #:nodoc:
64
69
 
65
70
  def verify_credentials
66
71
  begin
67
- ssl_get(live_url + "transactions/nonexistent", headers)
72
+ ssl_get(live_url + 'transactions/nonexistent', headers)
68
73
  rescue ResponseError => e
69
74
  return false if e.response.code.to_i == 401
70
75
  end
@@ -75,21 +80,21 @@ module ActiveMerchant #:nodoc:
75
80
  private
76
81
 
77
82
  def add_credit_card(post, credit_card, options)
78
- post['account.holder'] = (credit_card.try(:name) || "")
83
+ post['account.holder'] = (credit_card.try(:name) || '')
79
84
  post['account.number'] = credit_card.number
80
- post['account.expiry.month'] = sprintf("%.2i", credit_card.month)
81
- post['account.expiry.year'] = sprintf("%.4i", credit_card.year)
85
+ post['account.expiry.month'] = sprintf('%.2i', credit_card.month)
86
+ post['account.expiry.year'] = sprintf('%.4i', credit_card.year)
82
87
  post['account.verification'] = credit_card.verification_value
83
88
  post['account.email'] = (options[:email] || nil)
84
- post['presentation.amount3D'] = (options[:money] || nil)
85
- post['presentation.currency3D'] = (options[:currency] || currency( options[:money]))
89
+ post['presentation.amount3D'] = (options[:money] || nil)
90
+ post['presentation.currency3D'] = (options[:currency] || currency(options[:money]))
86
91
  end
87
92
 
88
93
  def headers
89
94
  { 'Authorization' => ('Basic ' + Base64.strict_encode64("#{@options[:private_key]}:X").chomp) }
90
95
  end
91
96
 
92
- def commit(method, action, parameters=nil)
97
+ def commit(method, action, parameters = nil)
93
98
  begin
94
99
  raw_response = ssl_request(method, live_url + action, post_data(parameters), headers)
95
100
  rescue ResponseError => e
@@ -107,8 +112,8 @@ module ActiveMerchant #:nodoc:
107
112
  def response_from(raw_response)
108
113
  parsed = JSON.parse(raw_response)
109
114
  options = {
110
- :authorization => authorization_from(parsed),
111
- :test => (parsed['mode'] == 'test'),
115
+ authorization: authorization_from(parsed),
116
+ test: (parsed['mode'] == 'test')
112
117
  }
113
118
 
114
119
  succeeded = (parsed['data'] == []) || (parsed['data']['response_code'].to_i == 20000)
@@ -122,16 +127,16 @@ module ActiveMerchant #:nodoc:
122
127
  [
123
128
  parsed_data['id'],
124
129
  parsed_data['preauthorization'].try(:[], 'id')
125
- ].join(";")
130
+ ].join(';')
126
131
  end
127
132
 
128
133
  def action_with_token(action, money, payment_method, options)
129
134
  options[:money] = money
130
135
  case payment_method
131
- when String
132
- self.send("#{action}_with_token", money, payment_method, options)
133
- else
134
- MultiResponse.run do |r|
136
+ when String
137
+ self.send("#{action}_with_token", money, payment_method, options)
138
+ else
139
+ MultiResponse.run do |r|
135
140
  r.process { save_card(payment_method, options) }
136
141
  r.process { self.send("#{action}_with_token", money, r.authorization, options) }
137
142
  end
@@ -176,7 +181,7 @@ module ActiveMerchant #:nodoc:
176
181
  end
177
182
 
178
183
  def response_for_save_from(raw_response)
179
- options = { :test => test? }
184
+ options = { test: test? }
180
185
 
181
186
  parser = ResponseParser.new(raw_response, options)
182
187
  parser.generate_response
@@ -193,8 +198,8 @@ module ActiveMerchant #:nodoc:
193
198
  def post_data(params)
194
199
  return nil unless params
195
200
 
196
- no_blanks = params.reject { |key, value| value.blank? }
197
- no_blanks.map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
201
+ no_blanks = params.reject { |_key, value| value.blank? }
202
+ no_blanks.map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
198
203
  end
199
204
 
200
205
  def add_amount(post, money, options)
@@ -203,7 +208,7 @@ module ActiveMerchant #:nodoc:
203
208
  end
204
209
 
205
210
  def preauth(authorization)
206
- authorization.split(";").last
211
+ authorization.split(';').last
207
212
  end
208
213
 
209
214
  def transaction_id(authorization)
@@ -211,121 +216,119 @@ module ActiveMerchant #:nodoc:
211
216
  end
212
217
 
213
218
  RESPONSE_CODES = {
214
- 10001 => "Undefined response",
215
- 10002 => "Waiting for something",
216
- 11000 => "Retry request at a later time",
217
-
218
- 20000 => "Operation successful",
219
- 20100 => "Funds held by acquirer",
220
- 20101 => "Funds held by acquirer because merchant is new",
221
- 20200 => "Transaction reversed",
222
- 20201 => "Reversed due to chargeback",
223
- 20202 => "Reversed due to money-back guarantee",
224
- 20203 => "Reversed due to complaint by buyer",
225
- 20204 => "Payment has been refunded",
226
- 20300 => "Reversal has been canceled",
227
- 22000 => "Initiation of transaction successful",
228
-
229
- 30000 => "Transaction still in progress",
230
- 30100 => "Transaction has been accepted",
231
- 31000 => "Transaction pending",
232
- 31100 => "Pending due to address",
233
- 31101 => "Pending due to uncleared eCheck",
234
- 31102 => "Pending due to risk review",
235
- 31103 => "Pending due regulatory review",
236
- 31104 => "Pending due to unregistered/unconfirmed receiver",
237
- 31200 => "Pending due to unverified account",
238
- 31201 => "Pending due to non-captured funds",
239
- 31202 => "Pending due to international account (accept manually)",
240
- 31203 => "Pending due to currency conflict (accept manually)",
241
- 31204 => "Pending due to fraud filters (accept manually)",
242
-
243
-
244
- 40000 => "Problem with transaction data",
245
- 40001 => "Problem with payment data",
246
- 40002 => "Invalid checksum",
247
- 40100 => "Problem with credit card data",
248
- 40101 => "Problem with CVV",
249
- 40102 => "Card expired or not yet valid",
250
- 40103 => "Card limit exceeded",
251
- 40104 => "Card is not valid",
252
- 40105 => "Expiry date not valid",
253
- 40106 => "Credit card brand required",
254
- 40200 => "Problem with bank account data",
255
- 40201 => "Bank account data combination mismatch",
256
- 40202 => "User authentication failed",
257
- 40300 => "Problem with 3-D Secure data",
258
- 40301 => "Currency/amount mismatch",
259
- 40400 => "Problem with input data",
260
- 40401 => "Amount too low or zero",
261
- 40402 => "Usage field too long",
262
- 40403 => "Currency not allowed",
263
- 40410 => "Problem with shopping cart data",
264
- 40420 => "Problem with address data",
265
- 40500 => "Permission error with acquirer API",
266
- 40510 => "Rate limit reached for acquirer API",
267
- 42000 => "Initiation of transaction failed",
268
- 42410 => "Initiation of transaction expired",
269
-
270
- 50000 => "Problem with back end",
271
- 50001 => "Country blacklisted",
272
- 50002 => "IP address blacklisted",
273
- 50004 => "Live mode not allowed",
274
- 50005 => "Insufficient permissions (API key)",
275
- 50100 => "Technical error with credit card",
276
- 50101 => "Error limit exceeded",
277
- 50102 => "Card declined",
278
- 50103 => "Manipulation or stolen card",
279
- 50104 => "Card restricted",
280
- 50105 => "Invalid configuration data",
281
- 50200 => "Technical error with bank account",
282
- 50201 => "Account blacklisted",
283
- 50300 => "Technical error with 3-D Secure",
284
- 50400 => "Declined because of risk issues",
285
- 50401 => "Checksum was wrong",
286
- 50402 => "Bank account number was invalid (formal check)",
287
- 50403 => "Technical error with risk check",
288
- 50404 => "Unknown error with risk check",
289
- 50405 => "Unknown bank code",
290
- 50406 => "Open chargeback",
291
- 50407 => "Historical chargeback",
292
- 50408 => "Institution / public bank account (NCA)",
293
- 50409 => "KUNO/Fraud",
294
- 50410 => "Personal Account Protection (PAP)",
295
- 50420 => "Rejected due to acquirer fraud settings",
296
- 50430 => "Rejected due to acquirer risk settings",
297
- 50440 => "Failed due to restrictions with acquirer account",
298
- 50450 => "Failed due to restrictions with user account",
299
- 50500 => "General timeout",
300
- 50501 => "Timeout on side of the acquirer",
301
- 50502 => "Risk management transaction timeout",
302
- 50600 => "Duplicate operation",
303
- 50700 => "Cancelled by user",
304
- 50710 => "Failed due to funding source",
305
- 50711 => "Payment method not usable, use other payment method",
306
- 50712 => "Limit of funding source was exceeded",
307
- 50713 => "Means of payment not reusable (canceled by user)",
308
- 50714 => "Means of payment not reusable (expired)",
309
- 50720 => "Rejected by acquirer",
310
- 50730 => "Transaction denied by merchant",
311
- 50800 => "Preauthorisation failed",
312
- 50810 => "Authorisation has been voided",
313
- 50820 => "Authorisation period expired"
219
+ 10001 => 'Undefined response',
220
+ 10002 => 'Waiting for something',
221
+ 11000 => 'Retry request at a later time',
222
+
223
+ 20000 => 'Operation successful',
224
+ 20100 => 'Funds held by acquirer',
225
+ 20101 => 'Funds held by acquirer because merchant is new',
226
+ 20200 => 'Transaction reversed',
227
+ 20201 => 'Reversed due to chargeback',
228
+ 20202 => 'Reversed due to money-back guarantee',
229
+ 20203 => 'Reversed due to complaint by buyer',
230
+ 20204 => 'Payment has been refunded',
231
+ 20300 => 'Reversal has been canceled',
232
+ 22000 => 'Initiation of transaction successful',
233
+
234
+ 30000 => 'Transaction still in progress',
235
+ 30100 => 'Transaction has been accepted',
236
+ 31000 => 'Transaction pending',
237
+ 31100 => 'Pending due to address',
238
+ 31101 => 'Pending due to uncleared eCheck',
239
+ 31102 => 'Pending due to risk review',
240
+ 31103 => 'Pending due regulatory review',
241
+ 31104 => 'Pending due to unregistered/unconfirmed receiver',
242
+ 31200 => 'Pending due to unverified account',
243
+ 31201 => 'Pending due to non-captured funds',
244
+ 31202 => 'Pending due to international account (accept manually)',
245
+ 31203 => 'Pending due to currency conflict (accept manually)',
246
+ 31204 => 'Pending due to fraud filters (accept manually)',
247
+
248
+ 40000 => 'Problem with transaction data',
249
+ 40001 => 'Problem with payment data',
250
+ 40002 => 'Invalid checksum',
251
+ 40100 => 'Problem with credit card data',
252
+ 40101 => 'Problem with CVV',
253
+ 40102 => 'Card expired or not yet valid',
254
+ 40103 => 'Card limit exceeded',
255
+ 40104 => 'Card is not valid',
256
+ 40105 => 'Expiry date not valid',
257
+ 40106 => 'Credit card brand required',
258
+ 40200 => 'Problem with bank account data',
259
+ 40201 => 'Bank account data combination mismatch',
260
+ 40202 => 'User authentication failed',
261
+ 40300 => 'Problem with 3-D Secure data',
262
+ 40301 => 'Currency/amount mismatch',
263
+ 40400 => 'Problem with input data',
264
+ 40401 => 'Amount too low or zero',
265
+ 40402 => 'Usage field too long',
266
+ 40403 => 'Currency not allowed',
267
+ 40410 => 'Problem with shopping cart data',
268
+ 40420 => 'Problem with address data',
269
+ 40500 => 'Permission error with acquirer API',
270
+ 40510 => 'Rate limit reached for acquirer API',
271
+ 42000 => 'Initiation of transaction failed',
272
+ 42410 => 'Initiation of transaction expired',
273
+
274
+ 50000 => 'Problem with back end',
275
+ 50001 => 'Country blacklisted',
276
+ 50002 => 'IP address blacklisted',
277
+ 50004 => 'Live mode not allowed',
278
+ 50005 => 'Insufficient permissions (API key)',
279
+ 50100 => 'Technical error with credit card',
280
+ 50101 => 'Error limit exceeded',
281
+ 50102 => 'Card declined',
282
+ 50103 => 'Manipulation or stolen card',
283
+ 50104 => 'Card restricted',
284
+ 50105 => 'Invalid configuration data',
285
+ 50200 => 'Technical error with bank account',
286
+ 50201 => 'Account blacklisted',
287
+ 50300 => 'Technical error with 3-D Secure',
288
+ 50400 => 'Declined because of risk issues',
289
+ 50401 => 'Checksum was wrong',
290
+ 50402 => 'Bank account number was invalid (formal check)',
291
+ 50403 => 'Technical error with risk check',
292
+ 50404 => 'Unknown error with risk check',
293
+ 50405 => 'Unknown bank code',
294
+ 50406 => 'Open chargeback',
295
+ 50407 => 'Historical chargeback',
296
+ 50408 => 'Institution / public bank account (NCA)',
297
+ 50409 => 'KUNO/Fraud',
298
+ 50410 => 'Personal Account Protection (PAP)',
299
+ 50420 => 'Rejected due to acquirer fraud settings',
300
+ 50430 => 'Rejected due to acquirer risk settings',
301
+ 50440 => 'Failed due to restrictions with acquirer account',
302
+ 50450 => 'Failed due to restrictions with user account',
303
+ 50500 => 'General timeout',
304
+ 50501 => 'Timeout on side of the acquirer',
305
+ 50502 => 'Risk management transaction timeout',
306
+ 50600 => 'Duplicate operation',
307
+ 50700 => 'Cancelled by user',
308
+ 50710 => 'Failed due to funding source',
309
+ 50711 => 'Payment method not usable, use other payment method',
310
+ 50712 => 'Limit of funding source was exceeded',
311
+ 50713 => 'Means of payment not reusable (canceled by user)',
312
+ 50714 => 'Means of payment not reusable (expired)',
313
+ 50720 => 'Rejected by acquirer',
314
+ 50730 => 'Transaction denied by merchant',
315
+ 50800 => 'Preauthorisation failed',
316
+ 50810 => 'Authorisation has been voided',
317
+ 50820 => 'Authorisation period expired'
314
318
  }
315
319
 
316
320
  def response_message(parsed_response)
317
- return parsed_response["error"] if parsed_response["error"]
318
- return "Transaction approved." if (parsed_response['data'] == [])
321
+ return parsed_response['error'] if parsed_response['error']
322
+ return 'Transaction approved.' if parsed_response['data'] == []
319
323
 
320
- code = parsed_response["data"]["response_code"].to_i
324
+ code = parsed_response['data']['response_code'].to_i
321
325
  RESPONSE_CODES[code] || code.to_s
322
326
  end
323
327
 
324
-
325
328
  class ResponseParser
326
329
  attr_reader :raw_response, :parsed, :succeeded, :message, :options
327
330
 
328
- def initialize(raw_response="", options={})
331
+ def initialize(raw_response = '', options = {})
329
332
  @raw_response = raw_response
330
333
  @options = options
331
334
  end
@@ -354,12 +357,10 @@ module ActiveMerchant #:nodoc:
354
357
 
355
358
  def handle_response_correct_parsing
356
359
  @message = parsed['transaction']['processing']['return']['message']
357
- if @succeeded = is_ack?
358
- @options[:authorization] = parsed['transaction']['identification']['uniqueId']
359
- end
360
+ @options[:authorization] = parsed['transaction']['identification']['uniqueId'] if @succeeded = ack?
360
361
  end
361
362
 
362
- def is_ack?
363
+ def ack?
363
364
  parsed['transaction']['processing']['result'] == 'ACK'
364
365
  end
365
366
  end