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
@@ -6,17 +6,14 @@ module ActiveMerchant #:nodoc:
6
6
 
7
7
  self.supported_countries = ['US']
8
8
  self.default_currency = 'USD'
9
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners]
9
+ self.supported_cardtypes = %i[visa master american_express discover diners]
10
10
 
11
11
  self.homepage_url = 'http://payments.intuit.com'
12
12
  self.display_name = 'QuickBooks Payments'
13
- ENDPOINT = "/quickbooks/v4/payments/charges"
14
- OAUTH_ENDPOINTS = {
15
- site: 'https://oauth.intuit.com',
16
- request_token_path: '/oauth/v1/get_request_token',
17
- authorize_url: 'https://appcenter.intuit.com/Connect/Begin',
18
- access_token_path: '/oauth/v1/get_access_token'
19
- }
13
+ BASE = '/quickbooks/v4/payments'
14
+ ENDPOINT = "#{BASE}/charges"
15
+ VOID_ENDPOINT = "#{BASE}/txn-requests"
16
+ REFRESH_URI = 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer'
20
17
 
21
18
  # https://developer.intuit.com/docs/0150_payments/0300_developer_guides/error_handling
22
19
 
@@ -45,13 +42,21 @@ module ActiveMerchant #:nodoc:
45
42
  'PMT-5001' => STANDARD_ERROR_CODE[:card_declined], # Merchant does not support given payment method
46
43
 
47
44
  # System Error
48
- 'PMT-6000' => STANDARD_ERROR_CODE[:processing_error], # A temporary Issue prevented this request from being processed.
45
+ 'PMT-6000' => STANDARD_ERROR_CODE[:processing_error], # A temporary Issue prevented this request from being processed.
49
46
  }
50
47
 
51
- FRAUD_WARNING_CODES = ['PMT-1000','PMT-1001','PMT-1002','PMT-1003']
48
+ FRAUD_WARNING_CODES = ['PMT-1000', 'PMT-1001', 'PMT-1002', 'PMT-1003']
52
49
 
53
50
  def initialize(options = {})
54
- requires!(options, :consumer_key, :consumer_secret, :access_token, :token_secret, :realm)
51
+ # Quickbooks is deprecating OAuth 1.0 on December 17, 2019.
52
+ # OAuth 2.0 requires a client_id, client_secret, access_token, and refresh_token
53
+ # To maintain backwards compatibility, check for the presence of a refresh_token (only specified for OAuth 2.0)
54
+ # When present, validate that all OAuth 2.0 options are present
55
+ if options[:refresh_token]
56
+ requires!(options, :client_id, :client_secret, :access_token, :refresh_token)
57
+ else
58
+ requires!(options, :consumer_key, :consumer_secret, :access_token, :token_secret, :realm)
59
+ end
55
60
  @options = options
56
61
  super
57
62
  end
@@ -60,41 +65,58 @@ module ActiveMerchant #:nodoc:
60
65
  post = {}
61
66
  add_amount(post, money, options)
62
67
  add_charge_data(post, payment, options)
63
- post[:capture] = "true"
68
+ post[:capture] = 'true'
64
69
 
65
- commit(ENDPOINT, post)
70
+ response = commit(ENDPOINT, post)
71
+ check_token_response(response, ENDPOINT, post, options)
66
72
  end
67
73
 
68
74
  def authorize(money, payment, options = {})
69
75
  post = {}
70
76
  add_amount(post, money, options)
71
77
  add_charge_data(post, payment, options)
72
- post[:capture] = "false"
78
+ post[:capture] = 'false'
73
79
 
74
- commit(ENDPOINT, post)
80
+ response = commit(ENDPOINT, post)
81
+ check_token_response(response, ENDPOINT, post, options)
75
82
  end
76
83
 
77
84
  def capture(money, authorization, options = {})
78
85
  post = {}
79
- capture_uri = "#{ENDPOINT}/#{CGI.escape(authorization)}/capture"
86
+ authorization, = split_authorization(authorization)
80
87
  post[:amount] = localized_amount(money, currency(money))
81
88
  add_context(post, options)
82
89
 
83
- commit(capture_uri, post)
90
+ response = commit(capture_uri(authorization), post)
91
+ check_token_response(response, capture_uri(authorization), post, options)
84
92
  end
85
93
 
86
94
  def refund(money, authorization, options = {})
87
95
  post = {}
88
96
  post[:amount] = localized_amount(money, currency(money))
89
97
  add_context(post, options)
98
+ authorization, = split_authorization(authorization)
90
99
 
91
- commit(refund_uri(authorization), post)
100
+ response = commit(refund_uri(authorization), post)
101
+ check_token_response(response, refund_uri(authorization), post, options)
102
+ end
103
+
104
+ def void(authorization, options = {})
105
+ _, request_id = split_authorization(authorization)
106
+
107
+ response = commit(void_uri(request_id))
108
+ check_token_response(response, void_uri(request_id), {}, options)
92
109
  end
93
110
 
94
111
  def verify(credit_card, options = {})
95
112
  authorize(1.00, credit_card, options)
96
113
  end
97
114
 
115
+ def refresh
116
+ response = refresh_access_token
117
+ response_object(response)
118
+ end
119
+
98
120
  def supports_scrubbing?
99
121
  true
100
122
  end
@@ -107,7 +129,12 @@ module ActiveMerchant #:nodoc:
107
129
  gsub(%r((oauth_signature=\")[a-zA-Z%0-9]+), '\1[FILTERED]').
108
130
  gsub(%r((oauth_token=\")\w+), '\1[FILTERED]').
109
131
  gsub(%r((number\D+)\d{16}), '\1[FILTERED]').
110
- gsub(%r((cvc\D+)\d{3}), '\1[FILTERED]')
132
+ gsub(%r((cvc\D+)\d{3}), '\1[FILTERED]').
133
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
134
+ gsub(%r((access_token\\?":\\?")[\w\-\.]+)i, '\1[FILTERED]').
135
+ gsub(%r((refresh_token\\?":\\?")\w+), '\1[FILTERED]').
136
+ gsub(%r((refresh_token=)\w+), '\1[FILTERED]').
137
+ gsub(%r((Authorization: Bearer )[\w\-\.]+)i, '\1[FILTERED]\2')
111
138
  end
112
139
 
113
140
  private
@@ -118,14 +145,15 @@ module ActiveMerchant #:nodoc:
118
145
  end
119
146
 
120
147
  def add_address(post, options)
121
- return unless post[:card] && post[:card].kind_of?(Hash)
148
+ return unless post[:card]&.kind_of?(Hash)
122
149
 
123
150
  card_address = {}
124
151
  if address = options[:billing_address] || options[:address]
125
152
  card_address[:streetAddress] = address[:address1]
126
153
  card_address[:city] = address[:city]
127
- card_address[:region] = address[:state] || address[:region]
128
- card_address[:country] = address[:country]
154
+ region = address[:state] || address[:region]
155
+ card_address[:region] = region if region.present?
156
+ card_address[:country] = address[:country] if address[:country].present?
129
157
  card_address[:postalCode] = address[:zip] if address[:zip]
130
158
  end
131
159
  post[:card][:address] = card_address
@@ -145,7 +173,7 @@ module ActiveMerchant #:nodoc:
145
173
  def add_creditcard(post, creditcard, options = {})
146
174
  card = {}
147
175
  card[:number] = creditcard.number
148
- card[:expMonth] = "%02d" % creditcard.month
176
+ card[:expMonth] = '%02d' % creditcard.month
149
177
  card[:expYear] = creditcard.year
150
178
  card[:cvc] = creditcard.verification_value if creditcard.verification_value?
151
179
  card[:name] = creditcard.name if creditcard.name
@@ -170,30 +198,30 @@ module ActiveMerchant #:nodoc:
170
198
  # The QuickBooks API returns HTTP 4xx on failed transactions, which causes a
171
199
  # ResponseError raise, so we have to inspect the response and discern between
172
200
  # a legitimate HTTP error and an actual gateway transactional error.
173
- response = begin
174
- case method
175
- when :post
176
- ssl_post(endpoint, post_data(body), headers(:post, endpoint))
177
- when :get
178
- ssl_request(:get, endpoint, nil, headers(:get, endpoint))
179
- else
180
- raise ArgumentError, "Invalid HTTP method: #{method}. Valid methods are :post and :get"
201
+ headers = {}
202
+ response =
203
+ begin
204
+ headers = headers(method, endpoint)
205
+ method == :post ? ssl_post(endpoint, post_data(body), headers) : ssl_request(:get, endpoint, nil, headers)
206
+ rescue ResponseError => e
207
+ extract_response_body_or_raise(e)
181
208
  end
182
- rescue ResponseError => e
183
- extract_response_body_or_raise(e)
184
- end
185
209
 
186
- response_object(response)
210
+ response_object(response, headers)
187
211
  end
188
212
 
189
- def response_object(raw_response)
213
+ def response_object(raw_response, headers = {})
190
214
  parsed_response = parse(raw_response)
191
215
 
216
+ # Include access_token and refresh_token in params for OAuth 2.0
217
+ parsed_response['access_token'] = @options[:access_token] if @options[:refresh_token]
218
+ parsed_response['refresh_token'] = @options[:refresh_token] if @options[:refresh_token]
219
+
192
220
  Response.new(
193
221
  success?(parsed_response),
194
222
  message_from(parsed_response),
195
223
  parsed_response,
196
- authorization: authorization_from(parsed_response),
224
+ authorization: authorization_from(parsed_response, headers),
197
225
  test: test?,
198
226
  cvv_result: cvv_code_from(parsed_response),
199
227
  error_code: errors_from(parsed_response),
@@ -210,7 +238,10 @@ module ActiveMerchant #:nodoc:
210
238
  end
211
239
 
212
240
  def headers(method, uri)
213
- raise ArgumentError, "Invalid HTTP method: #{method}. Valid methods are :post and :get" unless [:post, :get].include?(method)
241
+ return oauth_v2_headers if @options[:refresh_token]
242
+
243
+ raise ArgumentError, "Invalid HTTP method: #{method}. Valid methods are :post and :get" unless %i[post get].include?(method)
244
+
214
245
  request_uri = URI.parse(uri)
215
246
 
216
247
  # Following the guidelines from http://nouncer.com/oauth/authentication.html
@@ -218,31 +249,70 @@ module ActiveMerchant #:nodoc:
218
249
  oauth_nonce: generate_unique_id,
219
250
  oauth_timestamp: Time.now.to_i.to_s,
220
251
  oauth_signature_method: 'HMAC-SHA1',
221
- oauth_version: "1.0",
252
+ oauth_version: '1.0',
222
253
  oauth_consumer_key: @options[:consumer_key],
223
254
  oauth_token: @options[:access_token]
224
255
  }
225
256
 
226
257
  # prepare components for signature
227
- oauth_signature_base_string = [method.to_s.upcase, request_uri.to_s, oauth_parameters.to_param].map{|v| CGI.escape(v) }.join('&')
228
- oauth_signing_key = [@options[:consumer_secret], @options[:token_secret]].map{|v| CGI.escape(v)}.join('&')
258
+ oauth_signature_base_string = [method.to_s.upcase, request_uri.to_s, oauth_parameters.to_param].map { |v| CGI.escape(v) }.join('&')
259
+ oauth_signing_key = [@options[:consumer_secret], @options[:token_secret]].map { |v| CGI.escape(v) }.join('&')
229
260
  hmac_signature = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), oauth_signing_key, oauth_signature_base_string)
230
261
 
231
262
  # append signature to required OAuth parameters
232
- oauth_parameters[:oauth_signature] = CGI.escape(Base64.encode64(hmac_signature).chomp.gsub(/\n/, ''))
263
+ oauth_parameters[:oauth_signature] = CGI.escape(Base64.encode64(hmac_signature).chomp.delete("\n"))
233
264
 
234
265
  # prepare Authorization header string
235
- oauth_parameters = Hash[oauth_parameters.sort_by {|k, _| k}]
266
+ oauth_parameters = Hash[oauth_parameters.sort_by { |k, _| k }]
236
267
  oauth_headers = ["OAuth realm=\"#{@options[:realm]}\""]
237
- oauth_headers += oauth_parameters.map {|k, v| "#{k}=\"#{v}\""}
268
+ oauth_headers += oauth_parameters.map { |k, v| "#{k}=\"#{v}\"" }
269
+
270
+ {
271
+ 'Content-type' => 'application/json',
272
+ 'Request-Id' => generate_unique_id,
273
+ 'Authorization' => oauth_headers.join(', ')
274
+ }
275
+ end
238
276
 
277
+ def oauth_v2_headers
239
278
  {
240
- "Content-type" => "application/json",
241
- "Request-Id" => generate_unique_id,
242
- "Authorization" => oauth_headers.join(', ')
279
+ 'Content-Type' => 'application/json',
280
+ 'Request-Id' => generate_unique_id,
281
+ 'Accept' => 'application/json',
282
+ 'Authorization' => "Bearer #{@options[:access_token]}"
243
283
  }
244
284
  end
245
285
 
286
+ def check_token_response(response, endpoint, body = {}, options = {})
287
+ return response unless @options[:refresh_token]
288
+ return response unless options[:allow_refresh]
289
+ return response unless response.params['code'] == 'AuthenticationFailed'
290
+
291
+ refresh_access_token
292
+ commit(endpoint, body)
293
+ end
294
+
295
+ def refresh_access_token
296
+ post = {}
297
+ post[:grant_type] = 'refresh_token'
298
+ post[:refresh_token] = @options[:refresh_token]
299
+ data = post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
300
+
301
+ basic_auth = Base64.strict_encode64("#{@options[:client_id]}:#{@options[:client_secret]}")
302
+ headers = {
303
+ 'Content-Type' => 'application/x-www-form-urlencoded',
304
+ 'Accept' => 'application/json',
305
+ 'Authorization' => "Basic #{basic_auth}"
306
+ }
307
+
308
+ response = ssl_post(REFRESH_URI, data, headers)
309
+ json_response = JSON.parse(response)
310
+
311
+ @options[:access_token] = json_response['access_token'] if json_response['access_token']
312
+ @options[:refresh_token] = json_response['refresh_token'] if json_response['refresh_token']
313
+ response
314
+ end
315
+
246
316
  def cvv_code_from(response)
247
317
  if response['errors'].present?
248
318
  FRAUD_WARNING_CODES.include?(response['errors'].first['code']) ? 'I' : ''
@@ -252,21 +322,30 @@ module ActiveMerchant #:nodoc:
252
322
  end
253
323
 
254
324
  def success?(response)
255
- return FRAUD_WARNING_CODES.concat(['0']).include?(response['errors'].first['code']) if response['errors']
256
-
257
- !['DECLINED', 'CANCELLED'].include?(response['status'])
325
+ return FRAUD_WARNING_CODES.concat(['0']).include?(response['errors'].first['code']) if response['errors']
326
+
327
+ !%w[DECLINED CANCELLED].include?(response['status']) && !%w[AuthenticationFailed AuthorizationFailed].include?(response['code'])
258
328
  end
259
329
 
260
330
  def message_from(response)
261
- response['errors'].present? ? response["errors"].map {|error_hash| error_hash["message"] }.join(" ") : response['status']
331
+ response['errors'].present? ? response['errors'].map { |error_hash| error_hash['message'] }.join(' ') : response['status']
262
332
  end
263
333
 
264
334
  def errors_from(response)
265
- response['errors'].present? ? STANDARD_ERROR_CODE_MAPPING[response["errors"].first["code"]] : ""
335
+ if %w[AuthenticationFailed AuthorizationFailed].include?(response['code'])
336
+ response['code']
337
+ else
338
+ response['errors'].present? ? STANDARD_ERROR_CODE_MAPPING[response['errors'].first['code']] : ''
339
+ end
340
+ end
341
+
342
+ def authorization_from(response, headers = {})
343
+ [response['id'], headers['Request-Id']].join('|')
266
344
  end
267
345
 
268
- def authorization_from(response)
269
- response['id']
346
+ def split_authorization(authorization)
347
+ authorization, request_id = authorization.split('|')
348
+ [authorization, request_id]
270
349
  end
271
350
 
272
351
  def fraud_review_status_from(response)
@@ -283,7 +362,15 @@ module ActiveMerchant #:nodoc:
283
362
  end
284
363
 
285
364
  def refund_uri(authorization)
286
- "#{ENDPOINT}/#{CGI.escape(authorization)}/refunds"
365
+ "#{ENDPOINT}/#{CGI.escape(authorization.to_s)}/refunds"
366
+ end
367
+
368
+ def capture_uri(authorization)
369
+ "#{ENDPOINT}/#{CGI.escape(authorization.to_s)}/capture"
370
+ end
371
+
372
+ def void_uri(request_id)
373
+ "#{VOID_ENDPOINT}/#{CGI.escape(request_id.to_s)}/void"
287
374
  end
288
375
  end
289
376
  end
@@ -1,156 +1,154 @@
1
-
2
1
  module QuickpayCommon
3
-
4
2
  MD5_CHECK_FIELDS = {
5
3
  3 => {
6
- :authorize => %w(protocol msgtype merchant ordernumber amount
7
- currency autocapture cardnumber expirationdate
8
- cvd cardtypelock testmode),
4
+ authorize: %w(protocol msgtype merchant ordernumber amount
5
+ currency autocapture cardnumber expirationdate
6
+ cvd cardtypelock testmode),
9
7
 
10
- :capture => %w(protocol msgtype merchant amount finalize transaction),
8
+ capture: %w(protocol msgtype merchant amount finalize transaction),
11
9
 
12
- :cancel => %w(protocol msgtype merchant transaction),
10
+ cancel: %w(protocol msgtype merchant transaction),
13
11
 
14
- :refund => %w(protocol msgtype merchant amount transaction),
12
+ refund: %w(protocol msgtype merchant amount transaction),
15
13
 
16
- :subscribe => %w(protocol msgtype merchant ordernumber cardnumber
17
- expirationdate cvd cardtypelock description testmode),
14
+ subscribe: %w(protocol msgtype merchant ordernumber cardnumber
15
+ expirationdate cvd cardtypelock description testmode),
18
16
 
19
- :recurring => %w(protocol msgtype merchant ordernumber amount
20
- currency autocapture transaction),
17
+ recurring: %w(protocol msgtype merchant ordernumber amount
18
+ currency autocapture transaction),
21
19
 
22
- :status => %w(protocol msgtype merchant transaction),
20
+ status: %w(protocol msgtype merchant transaction),
23
21
 
24
- :chstatus => %w(protocol msgtype merchant)
22
+ chstatus: %w(protocol msgtype merchant)
25
23
  },
26
24
 
27
25
  4 => {
28
- :authorize => %w(protocol msgtype merchant ordernumber amount
29
- currency autocapture cardnumber expirationdate cvd
30
- cardtypelock testmode fraud_remote_addr
31
- fraud_http_accept fraud_http_accept_language
32
- fraud_http_accept_encoding fraud_http_accept_charset
33
- fraud_http_referer fraud_http_user_agent apikey),
26
+ authorize: %w(protocol msgtype merchant ordernumber amount
27
+ currency autocapture cardnumber expirationdate cvd
28
+ cardtypelock testmode fraud_remote_addr
29
+ fraud_http_accept fraud_http_accept_language
30
+ fraud_http_accept_encoding fraud_http_accept_charset
31
+ fraud_http_referer fraud_http_user_agent apikey),
34
32
 
35
- :capture => %w(protocol msgtype merchant amount finalize transaction apikey),
33
+ capture: %w(protocol msgtype merchant amount finalize transaction apikey),
36
34
 
37
- :cancel => %w(protocol msgtype merchant transaction apikey),
35
+ cancel: %w(protocol msgtype merchant transaction apikey),
38
36
 
39
- :refund => %w(protocol msgtype merchant amount transaction apikey),
37
+ refund: %w(protocol msgtype merchant amount transaction apikey),
40
38
 
41
- :subscribe => %w(protocol msgtype merchant ordernumber cardnumber
42
- expirationdate cvd cardtypelock description testmode
43
- fraud_remote_addr fraud_http_accept fraud_http_accept_language
44
- fraud_http_accept_encoding fraud_http_accept_charset
45
- fraud_http_referer fraud_http_user_agent apikey),
39
+ subscribe: %w(protocol msgtype merchant ordernumber cardnumber
40
+ expirationdate cvd cardtypelock description testmode
41
+ fraud_remote_addr fraud_http_accept fraud_http_accept_language
42
+ fraud_http_accept_encoding fraud_http_accept_charset
43
+ fraud_http_referer fraud_http_user_agent apikey),
46
44
 
47
- :recurring => %w(protocol msgtype merchant ordernumber amount currency
48
- autocapture transaction apikey),
45
+ recurring: %w(protocol msgtype merchant ordernumber amount currency
46
+ autocapture transaction apikey),
49
47
 
50
- :status => %w(protocol msgtype merchant transaction apikey),
48
+ status: %w(protocol msgtype merchant transaction apikey),
51
49
 
52
- :chstatus => %w(protocol msgtype merchant apikey)
50
+ chstatus: %w(protocol msgtype merchant apikey)
53
51
  },
54
52
 
55
53
  5 => {
56
- :authorize => %w(protocol msgtype merchant ordernumber amount
57
- currency autocapture cardnumber expirationdate cvd
58
- cardtypelock testmode fraud_remote_addr
59
- fraud_http_accept fraud_http_accept_language
60
- fraud_http_accept_encoding fraud_http_accept_charset
61
- fraud_http_referer fraud_http_user_agent apikey),
54
+ authorize: %w(protocol msgtype merchant ordernumber amount
55
+ currency autocapture cardnumber expirationdate cvd
56
+ cardtypelock testmode fraud_remote_addr
57
+ fraud_http_accept fraud_http_accept_language
58
+ fraud_http_accept_encoding fraud_http_accept_charset
59
+ fraud_http_referer fraud_http_user_agent apikey),
62
60
 
63
- :capture => %w(protocol msgtype merchant amount finalize transaction apikey),
61
+ capture: %w(protocol msgtype merchant amount finalize transaction apikey),
64
62
 
65
- :cancel => %w(protocol msgtype merchant transaction apikey),
63
+ cancel: %w(protocol msgtype merchant transaction apikey),
66
64
 
67
- :refund => %w(protocol msgtype merchant amount transaction apikey),
65
+ refund: %w(protocol msgtype merchant amount transaction apikey),
68
66
 
69
- :subscribe => %w(protocol msgtype merchant ordernumber cardnumber
70
- expirationdate cvd cardtypelock description testmode
71
- fraud_remote_addr fraud_http_accept fraud_http_accept_language
72
- fraud_http_accept_encoding fraud_http_accept_charset
73
- fraud_http_referer fraud_http_user_agent apikey),
67
+ subscribe: %w(protocol msgtype merchant ordernumber cardnumber
68
+ expirationdate cvd cardtypelock description testmode
69
+ fraud_remote_addr fraud_http_accept fraud_http_accept_language
70
+ fraud_http_accept_encoding fraud_http_accept_charset
71
+ fraud_http_referer fraud_http_user_agent apikey),
74
72
 
75
- :recurring => %w(protocol msgtype merchant ordernumber amount currency
76
- autocapture transaction apikey),
73
+ recurring: %w(protocol msgtype merchant ordernumber amount currency
74
+ autocapture transaction apikey),
77
75
 
78
- :status => %w(protocol msgtype merchant transaction apikey),
76
+ status: %w(protocol msgtype merchant transaction apikey),
79
77
 
80
- :chstatus => %w(protocol msgtype merchant apikey)
78
+ chstatus: %w(protocol msgtype merchant apikey)
81
79
  },
82
80
 
83
81
  6 => {
84
- :authorize => %w(protocol msgtype merchant ordernumber amount
85
- currency autocapture cardnumber expirationdate cvd
86
- cardtypelock testmode fraud_remote_addr
87
- fraud_http_accept fraud_http_accept_language
88
- fraud_http_accept_encoding fraud_http_accept_charset
89
- fraud_http_referer fraud_http_user_agent apikey),
82
+ authorize: %w(protocol msgtype merchant ordernumber amount
83
+ currency autocapture cardnumber expirationdate cvd
84
+ cardtypelock testmode fraud_remote_addr
85
+ fraud_http_accept fraud_http_accept_language
86
+ fraud_http_accept_encoding fraud_http_accept_charset
87
+ fraud_http_referer fraud_http_user_agent apikey),
90
88
 
91
- :capture => %w(protocol msgtype merchant amount finalize transaction
92
- apikey),
89
+ capture: %w(protocol msgtype merchant amount finalize transaction
90
+ apikey),
93
91
 
94
- :cancel => %w(protocol msgtype merchant transaction apikey),
92
+ cancel: %w(protocol msgtype merchant transaction apikey),
95
93
 
96
- :refund => %w(protocol msgtype merchant amount transaction apikey),
94
+ refund: %w(protocol msgtype merchant amount transaction apikey),
97
95
 
98
- :subscribe => %w(protocol msgtype merchant ordernumber cardnumber
99
- expirationdate cvd cardtypelock description testmode
100
- fraud_remote_addr fraud_http_accept fraud_http_accept_language
101
- fraud_http_accept_encoding fraud_http_accept_charset
102
- fraud_http_referer fraud_http_user_agent apikey),
96
+ subscribe: %w(protocol msgtype merchant ordernumber cardnumber
97
+ expirationdate cvd cardtypelock description testmode
98
+ fraud_remote_addr fraud_http_accept fraud_http_accept_language
99
+ fraud_http_accept_encoding fraud_http_accept_charset
100
+ fraud_http_referer fraud_http_user_agent apikey),
103
101
 
104
- :recurring => %w(protocol msgtype merchant ordernumber amount currency
105
- autocapture transaction apikey),
102
+ recurring: %w(protocol msgtype merchant ordernumber amount currency
103
+ autocapture transaction apikey),
106
104
 
107
- :status => %w(protocol msgtype merchant transaction apikey),
105
+ status: %w(protocol msgtype merchant transaction apikey),
108
106
 
109
- :chstatus => %w(protocol msgtype merchant apikey)
107
+ chstatus: %w(protocol msgtype merchant apikey)
110
108
  },
111
109
 
112
110
  7 => {
113
- :authorize => %w(protocol msgtype merchant ordernumber amount
114
- currency autocapture cardnumber expirationdate cvd
115
- acquirers cardtypelock testmode fraud_remote_addr
116
- fraud_http_accept fraud_http_accept_language
117
- fraud_http_accept_encoding fraud_http_accept_charset
118
- fraud_http_referer fraud_http_user_agent apikey),
111
+ authorize: %w(protocol msgtype merchant ordernumber amount
112
+ currency autocapture cardnumber expirationdate cvd
113
+ acquirers cardtypelock testmode fraud_remote_addr
114
+ fraud_http_accept fraud_http_accept_language
115
+ fraud_http_accept_encoding fraud_http_accept_charset
116
+ fraud_http_referer fraud_http_user_agent apikey),
119
117
 
120
- :capture => %w(protocol msgtype merchant amount finalize transaction
121
- apikey),
118
+ capture: %w(protocol msgtype merchant amount finalize transaction
119
+ apikey),
122
120
 
123
- :cancel => %w(protocol msgtype merchant transaction apikey),
121
+ cancel: %w(protocol msgtype merchant transaction apikey),
124
122
 
125
- :refund => %w(protocol msgtype merchant amount transaction apikey),
123
+ refund: %w(protocol msgtype merchant amount transaction apikey),
126
124
 
127
- :subscribe => %w(protocol msgtype merchant ordernumber amount currency
128
- cardnumber expirationdate cvd acquirers cardtypelock
129
- description testmode fraud_remote_addr fraud_http_accept
130
- fraud_http_accept_language fraud_http_accept_encoding
131
- fraud_http_accept_charset fraud_http_referer
132
- fraud_http_user_agent apikey),
125
+ subscribe: %w(protocol msgtype merchant ordernumber amount currency
126
+ cardnumber expirationdate cvd acquirers cardtypelock
127
+ description testmode fraud_remote_addr fraud_http_accept
128
+ fraud_http_accept_language fraud_http_accept_encoding
129
+ fraud_http_accept_charset fraud_http_referer
130
+ fraud_http_user_agent apikey),
133
131
 
134
- :recurring => %w(protocol msgtype merchant ordernumber amount currency
135
- autocapture transaction apikey),
132
+ recurring: %w(protocol msgtype merchant ordernumber amount currency
133
+ autocapture transaction apikey),
136
134
 
137
- :status => %w(protocol msgtype merchant transaction apikey),
135
+ status: %w(protocol msgtype merchant transaction apikey),
138
136
 
139
- :chstatus => %w(protocol msgtype merchant apikey)
137
+ chstatus: %w(protocol msgtype merchant apikey)
140
138
  },
141
-
139
+
142
140
  10 => {
143
- :authorize => %w(mobile_number acquirer autofee customer_id extras
144
- zero_auth customer_ip),
145
- :capture => %w( extras ),
146
- :cancel => %w( extras ),
147
- :refund => %w( extras ),
148
- :subscribe => %w( variables branding_id),
149
- :authorize_subscription => %w( mobile_number acquirer customer_ip),
150
- :recurring => %w(auto_capture autofee zero_auth)
141
+ authorize: %w(mobile_number acquirer autofee customer_id extras
142
+ zero_auth customer_ip),
143
+ capture: %w(extras),
144
+ cancel: %w(extras),
145
+ refund: %w(extras),
146
+ subscribe: %w(variables branding_id),
147
+ authorize_subscription: %w(mobile_number acquirer customer_ip),
148
+ recurring: %w(auto_capture autofee zero_auth)
151
149
  }
152
150
  }
153
-
151
+
154
152
  RESPONSE_CODES = {
155
153
  200 => 'OK',
156
154
  201 => 'Created',
@@ -165,24 +163,22 @@ module QuickpayCommon
165
163
  409 => 'Conflict',
166
164
  500 => 'Internal Server Error'
167
165
  }
168
-
166
+
169
167
  def self.included(base)
170
168
  base.default_currency = 'DKK'
171
169
  base.money_format = :cents
172
-
173
- base.supported_cardtypes = [:dankort, :forbrugsforeningen, :visa, :master,
174
- :american_express, :diners_club, :jcb, :maestro]
175
- base.supported_countries = ['DE', 'DK', 'ES', 'FI', 'FR', 'FO', 'GB', 'IS', 'NO', 'SE']
170
+
171
+ base.supported_countries = %w[DE DK ES FI FR FO GB IS NO SE]
172
+ base.supported_cardtypes = %i[dankort forbrugsforeningen visa master
173
+ american_express diners_club jcb maestro]
176
174
  base.homepage_url = 'http://quickpay.net/'
177
175
  base.display_name = 'QuickPay'
178
-
179
176
  end
180
-
177
+
181
178
  def expdate(credit_card)
182
179
  year = format(credit_card.year, :two_digits)
183
180
  month = format(credit_card.month, :two_digits)
184
181
 
185
182
  "#{year}#{month}"
186
183
  end
187
-
188
184
  end