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
@@ -0,0 +1,392 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class PayArcGateway < Gateway
4
+ self.test_url = 'https://testapi.payarc.net/v1'
5
+ self.live_url = 'https://api.payarc.net/v1'
6
+
7
+ self.supported_countries = ['US']
8
+ self.default_currency = 'usd'
9
+ self.supported_cardtypes = %i[visa master american_express discover jcb]
10
+
11
+ self.homepage_url = 'https://www.payarc.net/'
12
+ self.display_name = 'PAYARC Gateway'
13
+
14
+ STANDARD_ERROR_CODE_MAPPING = {}
15
+ STANDARD_ACTIONS = {
16
+ token:
17
+ { end_point: 'tokens',
18
+ allowed_fields: %i[card_source card_number exp_month exp_year cvv card_holder_name
19
+ address_line1 address_line2 city state zip country] },
20
+ capture:
21
+ { end_point: 'charges',
22
+ allowed_fields: %i[amount statement_description card_id currency customer_id token_id card_source tip_amount
23
+ card_level sales_tax purchase_order supplier_reference_number customer_ref_id ship_to_zip
24
+ amex_descriptor customer_vat_number summary_commodity_code shipping_charges duty_charges
25
+ ship_from_zip destination_country_code vat_invoice order_date tax_category tax_type
26
+ tax_amount tax_rate address_line1 zip terminal_id surcharge description email receipt_phone statement_descriptor ] },
27
+ void:
28
+ { end_point: 'charges/{{chargeID}}/void',
29
+ allowed_fields: %i[reason void_description] },
30
+ refund:
31
+ { end_point: 'charges/{{charge_id}}/refunds',
32
+ allowed_fields: %i[amount reason description] },
33
+ credit:
34
+ { end_point: 'refunds/wo_reference',
35
+ allowed_fields: %i[amount charge_description statement_description terminal_id card_source card_number
36
+ exp_month exp_year cvv card_holder_name address_line1 address_line2 city state zip
37
+ country currency reason receipt_phone receipt_email ] }
38
+ }
39
+
40
+ SUCCESS_STATUS = %w[
41
+ submitted_for_settlement authorized partially_submitted_for_settlement
42
+ credit partial_refund void refunded settled
43
+ ]
44
+
45
+ FAILURE_STATUS = %w[not_processed failed_by_gateway invalid_track_data authorization_expired]
46
+
47
+ # The gateway must be configured with Bearer token.
48
+ #
49
+ # <tt>:api_key</tt> PAYARC's Bearer token must be passsed to initialise the gateway.
50
+
51
+ def initialize(options = {})
52
+ requires!(options, :api_key)
53
+ super
54
+ end
55
+
56
+ #
57
+ # Purchase API through PAYARC.
58
+ #
59
+ # <tt>:money</tt> A positive integer in cents representing how much to charge. The minimum amount is 50c USD.
60
+ #
61
+ # <tt>:creditcard</tt> <tt>CreditCard</tt> object with card details.
62
+ #
63
+ # <tt>:options</tt> Other information like address, card source etc can be passed in options
64
+ #
65
+ # ==== Options
66
+ #
67
+ # * <tt>:card_source </tt> -- Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )
68
+ # * <tt>:currency </tt> -- Three-letter ISO currency code, in lowercase (REQUIRED)
69
+ # * <tt>:card_holder_name</tt> --Name of the Card Holder (OPTIONAL)
70
+ # * <tt>:address_line1</tt> -- Set in payment method's billing address (OPTIONAL)
71
+ # * <tt>:address_line2</tt> -- Set in payment method's billing address (OPTIONAL)
72
+ # * <tt>:state </tt> -- State (OPTIONAL)
73
+ # * <tt>:country </tt> -- Country (OPTIONAL)
74
+ # * <tt>:statement_description </tt> -- An arbitrary string to be displayed on your costomer's credit card statement. This may be up to 22 characters. (OPTIONAL)
75
+ # * <tt> :card_level </tt> -- Commercial card level - "LEVEL2" OR "LEVEL3" (OPTIONAL)
76
+ # * <tt> :sales_tax </tt> -- A positive integer in cents representing sales tax. (OPTIONAL)
77
+ # * <tt> :terminal_id </tt> -- Optional terminal id. (OPTIONAL)
78
+ # * <tt> :tip_amount </tt> -- A positive integer in cents representing tip amount. (OPTIONAL)
79
+ # * <tt> :sales_tax </tt> -- Applicable for LEVEL2 or LEVEL3 Charge. A positive integer in cents representing sales tax. (REQUIRED for LEVEL2 0r LEVEL3)
80
+ # * <tt> :purchase_order </tt> -- Applicable for Level2 or Level3 Charge. The value used by the customer to identify an order. Issued by the buyer to the seller. (REQUIRED for LEVEL2 0r LEVEL3)
81
+ # * <tt> :order_date </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The date the order was processed. Format: Alphanumeric and Special Character |Min Length=0 Max Length=10|Allowed format: MM/DD/YYYY For example: 12/01/2016
82
+ # * <tt> :customer_ref_id </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The reference identifier supplied by the Commercial Card cardholder. Format: Alphanumeric and Special Character |Min Length=0 Max Length=17| a-z A-Z 0-9 Space <>
83
+ # * <tt> :ship_to_zip </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10
84
+ # * <tt> :amex_descriptor </tt> -- Applicable for Level2 Charge for AMEX card only. The value of the Transaction Advice Addendum field, displays descriptive information about a transactions on a customer's AMEX card statement. Format: Alphanumeric and Special Character |Min Length=0 Max Length=40|a-z A-Z 0-9 Space <>
85
+ # * <tt> :supplier_reference_number </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 charge. The value used by the customer to identify an order. Issued by the buyer to the seller.
86
+ # * <tt> :tax_amount </tt> -- Applicable for Level3 Charge. The tax amount. Format: Numeric|Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
87
+ # * <tt> :tax_category </tt> -- Applicable for Level3 Charge. The type of tax. Formerly established through TaxCategory messages. Allowed values: SERVICE, DUTY, VAT, ALTERNATE, NATIONAL, TAX_EXEMPT
88
+ # * <tt> :customer_vat_number </tt> -- Applicable for Level3 Charge. Indicates the customer's government assigned tax identification number or the identification number assigned to their purchasing company by the tax authorities. Format: Alphanumeric and Special Character|Min Length=0 Max Length=13| a-z A-Z 0-9 Space <>
89
+ # * <tt> :summary_commodity_code </tt> -- Applicable for Level3 Charge. The international description code of the overall goods or services being supplied. Format: Alphanumeric and Special Character |Min Length=0 Max Length=4|Allowed character: a-z A-Z 0-9 Space <>
90
+ # * <tt> :shipping_charges </tt> -- Applicable for Level3 Charge. The dollar amount for shipping or freight charges applied to a product or transaction. Format: Numeric |Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
91
+ # * <tt> :duty_charges </tt> -- Applicable for Level3 Charge. Indicates the total charges for any import or export duties included in the order. Format: Numeric |Max Length=12|Allowed characters: 0-9 . (dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
92
+ # * <tt> :ship_from_zip </tt> -- Applicable for Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10
93
+ # * <tt> :destination_country_code </tt> -- Applicable for Level3 Charge. The destination country code indicator. Format: Alphanumeric.
94
+ # * <tt> :tax_type </tt> -- Applicable for Level3 Charge. The type of tax. For example, VAT, NATIONAL, Service Tax. Format: Alphanumeric and Special Character
95
+ # * <tt> :vat_invoice </tt> -- Applicable for Level3 Charge. The Value Added Tax (VAT) invoice number associated with the transaction. Format: Alphanumeric and Special Character |Min Length=0 Max Length=15|Allowed character: a-z A-Z 0-9 Space <>
96
+ # * <tt> :tax_rate </tt> -- Applicable for Level3 Charge. The type of tax rate. This field is used if taxCategory is not used. Default sale tax rate in percentage Must be between 0.1% - 22% ,Applicable only Level 2 AutoFill. Format: Decimal Number |Max Length=4|Allowed characters: 0-9 .(dot) Allowed range: 0.01 - 100
97
+ # * <tt> :email </tt> -- Customer's email address sent with payment method.
98
+
99
+ def purchase(money, creditcard, options = {})
100
+ options[:capture] = 1
101
+ MultiResponse.run do |r|
102
+ r.process { token(creditcard, options) }
103
+ r.process { charge(money, r.authorization, options) }
104
+ end
105
+ end
106
+
107
+ #
108
+ # Authorize the payment API through PAYARC.
109
+ #
110
+ # <tt>:money</tt> A positive integer in cents representing how much to charge. The minimum amount is 50c USD.
111
+ #
112
+ # <tt>:creditcard</tt> <tt>CreditCard</tt> object with card details.
113
+ #
114
+ # <tt>:options</tt> Other information like address, card source etc can be passed in options
115
+ #
116
+ # ==== Options
117
+ #
118
+ # * <tt>:card_source </tt> -- Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )
119
+ # * <tt>:currency </tt> -- Three-letter ISO currency code, in lowercase (REQUIRED)
120
+ # * <tt>:card_holder_name</tt> --Name of the Card Holder (OPTIONAL)
121
+ # * <tt>:address_line1</tt> -- Set in payment method's billing address (OPTIONAL)
122
+ # * <tt>:address_line2</tt> -- Set in payment method's billing address (OPTIONAL)
123
+ # * <tt>:state </tt> -- State (OPTIONAL)
124
+ # * <tt>:country </tt> -- Country (OPTIONAL)
125
+ # * <tt>:statement_description </tt> -- An arbitrary string to be displayed on your costomer's credit card statement. This may be up to 22 characters. (OPTIONAL)
126
+ # * <tt> :card_level </tt> -- Commercial card level - "LEVEL2" OR "LEVEL3" (OPTIONAL)
127
+ # * <tt> :sales_tax </tt> -- A positive integer in cents representing sales tax. (OPTIONAL)
128
+ # * <tt> :terminal_id </tt> -- Optional terminal id. (OPTIONAL)
129
+ # * <tt> :tip_amount </tt> -- A positive integer in cents representing tip amount. (OPTIONAL)
130
+ # * <tt> :sales_tax </tt> -- Applicable for LEVEL2 or LEVEL3 Charge. A positive integer in cents representing sales tax. (REQUIRED for LEVEL2 0r LEVEL3)
131
+ # * <tt> :purchase_order </tt> -- Applicable for Level2 or Level3 Charge. The value used by the customer to identify an order. Issued by the buyer to the seller. (REQUIRED for LEVEL2 0r LEVEL3)
132
+ # * <tt> :order_date </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The date the order was processed. Format: Alphanumeric and Special Character |Min Length=0 Max Length=10|Allowed format: MM/DD/YYYY For example: 12/01/2016
133
+ # * <tt> :customer_ref_id </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The reference identifier supplied by the Commercial Card cardholder. Format: Alphanumeric and Special Character |Min Length=0 Max Length=17| a-z A-Z 0-9 Space <>
134
+ # * <tt> :ship_to_zip </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10
135
+ # * <tt> :amex_descriptor </tt> -- Applicable for Level2 Charge for AMEX card only. The value of the Transaction Advice Addendum field, displays descriptive information about a transactions on a customer's AMEX card statement. Format: Alphanumeric and Special Character |Min Length=0 Max Length=40|a-z A-Z 0-9 Space <>
136
+ # * <tt> :supplier_reference_number </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 charge. The value used by the customer to identify an order. Issued by the buyer to the seller.
137
+ # * <tt> :tax_amount </tt> -- Applicable for Level3 Charge. The tax amount. Format: Numeric|Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
138
+ # * <tt> :tax_category </tt> -- Applicable for Level3 Charge. The type of tax. Formerly established through TaxCategory messages. Allowed values: SERVICE, DUTY, VAT, ALTERNATE, NATIONAL, TAX_EXEMPT
139
+ # * <tt> :customer_vat_number </tt> -- Applicable for Level3 Charge. Indicates the customer's government assigned tax identification number or the identification number assigned to their purchasing company by the tax authorities. Format: Alphanumeric and Special Character|Min Length=0 Max Length=13| a-z A-Z 0-9 Space <>
140
+ # * <tt> :summary_commodity_code </tt> -- Applicable for Level3 Charge. The international description code of the overall goods or services being supplied. Format: Alphanumeric and Special Character |Min Length=0 Max Length=4|Allowed character: a-z A-Z 0-9 Space <>
141
+ # * <tt> :shipping_charges </tt> -- Applicable for Level3 Charge. The dollar amount for shipping or freight charges applied to a product or transaction. Format: Numeric |Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
142
+ # * <tt> :duty_charges </tt> -- Applicable for Level3 Charge. Indicates the total charges for any import or export duties included in the order. Format: Numeric |Max Length=12|Allowed characters: 0-9 . (dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
143
+ # * <tt> :ship_from_zip </tt> -- Applicable for Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10
144
+ # * <tt> :destination_country_code </tt> -- Applicable for Level3 Charge. The destination country code indicator. Format: Alphanumeric.
145
+ # * <tt> :tax_type </tt> -- Applicable for Level3 Charge. The type of tax. For example, VAT, NATIONAL, Service Tax. Format: Alphanumeric and Special Character
146
+ # * <tt> :vat_invoice </tt> -- Applicable for Level3 Charge. The Value Added Tax (VAT) invoice number associated with the transaction. Format: Alphanumeric and Special Character |Min Length=0 Max Length=15|Allowed character: a-z A-Z 0-9 Space <>
147
+ # * <tt> :tax_rate </tt> -- Applicable for Level3 Charge. The type of tax rate. This field is used if taxCategory is not used. Default sale tax rate in percentage Must be between 0.1% - 22% ,Applicable only Level 2 AutoFill. Format: Decimal Number |Max Length=4|Allowed characters: 0-9 .(dot) Allowed range: 0.01 - 100
148
+ # * <tt> :email </tt> -- Customer's email address.
149
+
150
+ def authorize(money, creditcard, options = {})
151
+ options[:capture] = '0'
152
+ MultiResponse.run do |r|
153
+ r.process { token(creditcard, options) }
154
+ r.process { charge(money, r.authorization, options) }
155
+ end
156
+ end
157
+
158
+ #
159
+ # Capture the payment of an existing, uncaptured, charge.
160
+ # This is the second half of the two-step payment flow, where first you created / authorized a charge
161
+ # with the capture option set to false.
162
+ #
163
+ # <tt>:money</tt> A positive integer in cents representing how much to charge. The minimum amount is 50c USD.
164
+ #
165
+ # <tt>:tx_reference</tt> charge_id from previously created / authorized a charge
166
+ #
167
+ # <tt>:options</tt> Other information like address, card source etc can be passed in options
168
+
169
+ def capture(money, tx_reference, options = {})
170
+ post = {}
171
+ add_money(post, money, options)
172
+ action = "#{STANDARD_ACTIONS[:capture][:end_point]}/#{tx_reference}/capture"
173
+ post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:capture][:allowed_fields])
174
+ commit(action, post)
175
+ end
176
+
177
+ #
178
+ # Voids the transaction / charge.
179
+ #
180
+ # <tt>:tx_reference</tt> charge_id from previously created charge
181
+ #
182
+ # <tt>:options</tt> Other information like address, card source etc can be passed in options
183
+ #
184
+ # ==== Options
185
+ #
186
+ # * <tt> :reason </tt> -- Reason for voiding transaction (REQUIRED) ( requested_by_customer, duplicate, fraudulent, other )
187
+
188
+ def void(tx_reference, options = {})
189
+ post = {}
190
+ post['reason'] = options[:reason]
191
+ action = STANDARD_ACTIONS[:void][:end_point].gsub(/{{chargeID}}/, tx_reference)
192
+ post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:void][:allowed_fields])
193
+ commit(action, post)
194
+ end
195
+
196
+ #
197
+ # Refund full / partial payment of an successful charge / capture / purchase.
198
+ #
199
+ # <tt>:money</tt> A positive integer in cents representing how much to charge. The minimum amount is 50c USD.
200
+ #
201
+ # <tt>:tx_reference</tt> charge_id from previously created / authorized a charge
202
+ #
203
+ # <tt>:options</tt> Other information like address, card source etc can be passed in options
204
+
205
+ def refund(money, tx_reference, options = {})
206
+ post = {}
207
+ add_money(post, money, options)
208
+ action = STANDARD_ACTIONS[:refund][:end_point].gsub(/{{charge_id}}/, tx_reference)
209
+ post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:refund][:allowed_fields])
210
+ commit(action, post)
211
+ end
212
+
213
+ def credit(money, creditcard, options = {})
214
+ post = {}
215
+ add_money(post, money, options)
216
+ add_creditcard(post, creditcard, options)
217
+ add_address(post, options)
218
+ add_phone(post, options)
219
+ post['receipt_email'] = options[:email] if options[:email]
220
+ action = STANDARD_ACTIONS[:credit][:end_point]
221
+ post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:credit][:allowed_fields])
222
+ commit(action, post)
223
+ end
224
+
225
+ #
226
+ # Verify the creditcard API through PAYARC.
227
+ #
228
+ # <tt>:creditcard</tt> <tt>CreditCard</tt> object with card details.
229
+ #
230
+ # <tt>:options</tt> Other information like address, card source etc can be passed in options
231
+ #
232
+ # ==== Options
233
+ #
234
+ # * <tt>:card_source </tt> -- Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )
235
+ # * <tt>:card_holder_name</tt> --Name of the Card Holder (OPTIONAL)
236
+ # * <tt>:address_line1</tt> -- Set in payment method's billing address (OPTIONAL)
237
+ # * <tt>:address_line2</tt> -- Set in payment method's billing address (OPTIONAL)
238
+ # * <tt>:state </tt> -- State (OPTIONAL)
239
+ # * <tt>:country </tt> -- Country (OPTIONAL)
240
+
241
+ def verify(creditcard, options = {})
242
+ token(creditcard, options)
243
+ end
244
+
245
+ #:nodoc:
246
+ def token(creditcard, options = {})
247
+ post = {}
248
+ post['authorize_card'] = 1
249
+ post['card_source'] = options[:card_source]
250
+ add_creditcard(post, creditcard, options)
251
+ add_address(post, options)
252
+ post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:token][:allowed_fields])
253
+ commit(STANDARD_ACTIONS[:token][:end_point], post)
254
+ end
255
+
256
+ def supports_scrubbing? #:nodoc:
257
+ true
258
+ end
259
+
260
+ def scrub(transcript)
261
+ #:nodoc:
262
+ transcript.
263
+ gsub(%r((Authorization: Bearer )[^\s]+\s)i, '\1[FILTERED]\2').
264
+ gsub(%r((&?card_number=)[^&]*)i, '\1[FILTERED]').
265
+ gsub(%r((&?cvv=)[^&]*)i, '\1[BLANK]')
266
+ end
267
+
268
+ private
269
+
270
+ def charge(money, authorization, options = {})
271
+ post = {}
272
+ post['token_id'] = authorization
273
+ post['capture'] = options[:capture] || 1
274
+ add_money(post, money, options)
275
+ add_phone(post, options)
276
+ post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:capture][:allowed_fields])
277
+ commit(STANDARD_ACTIONS[:capture][:end_point], post)
278
+ end
279
+
280
+ def add_creditcard(post, creditcard, options)
281
+ post['card_number'] = creditcard.number
282
+ post['exp_month'] = format(creditcard.month, :two_digits)
283
+ post['exp_year'] = creditcard.year
284
+ post['cvv'] = creditcard.verification_value unless creditcard.verification_value.nil?
285
+ post['card_holder_name'] = options[:card_holder_name] || "#{creditcard.first_name} #{creditcard.last_name}"
286
+ end
287
+
288
+ def add_address(post, options)
289
+ return unless billing_address = options[:billing_address]
290
+
291
+ post['address_line1'] = billing_address[:address1]
292
+ post['address_line2'] = billing_address[:address2]
293
+ post['city'] = billing_address[:city]
294
+ post['state'] = billing_address[:state]
295
+ post['zip'] = billing_address[:zip]
296
+ post['country'] = billing_address[:country]
297
+ end
298
+
299
+ def add_phone(post, options)
300
+ post['phone_number'] = options[:billing_address][:phone] if options.dig(:billing_address, :phone)
301
+ end
302
+
303
+ def add_money(post, money, options)
304
+ post['amount'] = money
305
+ post['currency'] = currency(money) unless options[:currency]
306
+ post['statement_description'] = options[:statement_description]
307
+ end
308
+
309
+ def headers(api_key)
310
+ {
311
+ 'Authorization' => 'Bearer ' + api_key.strip,
312
+ 'Accept' => 'application/json',
313
+ 'User-Agent' => "PayArc ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
314
+ }
315
+ end
316
+
317
+ def parse(body)
318
+ JSON.parse(body)
319
+ rescue JSON::ParserError
320
+ body
321
+ end
322
+
323
+ def filter_gateway_fields(post, options, gateway_fields)
324
+ filtered_options = options.slice(*gateway_fields).compact
325
+ post.update(filtered_options)
326
+ post
327
+ end
328
+
329
+ def commit(action, parameters)
330
+ url = (test? ? test_url : live_url)
331
+ headers = headers(@options[:api_key])
332
+ end_point = "#{url}/#{action}"
333
+ begin
334
+ response = ssl_post(end_point, post_data(parameters), headers)
335
+ parsed_response = parse(response)
336
+
337
+ Response.new(
338
+ success_from(parsed_response, action),
339
+ message_from(parsed_response, action),
340
+ parsed_response,
341
+ test: test?,
342
+ authorization: parse_response_id(parsed_response),
343
+ error_code: error_code_from(parsed_response, action)
344
+ )
345
+ rescue ResponseError => e
346
+ parsed_response = parse(e.response.body)
347
+ Response.new(
348
+ false,
349
+ message_from(parsed_response, action),
350
+ parsed_response,
351
+ test: test?,
352
+ authorization: nil,
353
+ error_code: error_code_from(parsed_response, action)
354
+ )
355
+ end
356
+ end
357
+
358
+ def success_from(response, action)
359
+ if action == STANDARD_ACTIONS[:token][:end_point]
360
+ token = parse_response_id(response)
361
+ (!token.nil? && !token.empty?)
362
+ elsif response
363
+ return SUCCESS_STATUS.include? response['data']['status'] if response['data']
364
+ end
365
+ end
366
+
367
+ def message_from(response, action)
368
+ if success_from(response, action)
369
+ if action == STANDARD_ACTIONS[:token][:end_point]
370
+ return response['data']['id']
371
+ else
372
+ return response['data']['status']
373
+ end
374
+ else
375
+ return response['message']
376
+ end
377
+ end
378
+
379
+ def parse_response_id(response)
380
+ response['data']['id'] if response && response['data']
381
+ end
382
+
383
+ def post_data(params)
384
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
385
+ end
386
+
387
+ def error_code_from(response, action)
388
+ response['status_code'] unless success_from(response, action)
389
+ end
390
+ end
391
+ end
392
+ end
@@ -3,74 +3,72 @@ module ActiveMerchant #:nodoc:
3
3
  class PayConexGateway < Gateway
4
4
  include Empty
5
5
 
6
- self.test_url = "https://cert.payconex.net/api/qsapi/3.8/"
7
- self.live_url = "https://secure.payconex.net/api/qsapi/3.8/"
6
+ self.test_url = 'https://cert.payconex.net/api/qsapi/3.8/'
7
+ self.live_url = 'https://secure.payconex.net/api/qsapi/3.8/'
8
8
 
9
9
  self.supported_countries = %w(US CA)
10
- self.default_currency = "USD"
11
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
10
+ self.default_currency = 'USD'
11
+ self.supported_cardtypes = %i[visa master american_express discover jcb diners_club]
12
12
 
13
- self.homepage_url = "http://www.bluefincommerce.com/"
14
- self.display_name = "PayConex"
13
+ self.homepage_url = 'http://www.bluefincommerce.com/'
14
+ self.display_name = 'PayConex'
15
15
 
16
- def initialize(options={})
16
+ def initialize(options = {})
17
17
  requires!(options, :account_id, :api_accesskey)
18
18
  super
19
19
  end
20
20
 
21
- def purchase(money, payment_method, options={})
21
+ def purchase(money, payment_method, options = {})
22
22
  post = {}
23
23
  add_auth_purchase_params(post, money, payment_method, options)
24
- commit("SALE", post)
24
+ commit('SALE', post)
25
25
  end
26
26
 
27
- def authorize(money, payment_method, options={})
27
+ def authorize(money, payment_method, options = {})
28
28
  post = {}
29
29
  add_auth_purchase_params(post, money, payment_method, options)
30
- commit("AUTHORIZATION", post)
30
+ commit('AUTHORIZATION', post)
31
31
  end
32
32
 
33
- def capture(money, authorization, options={})
33
+ def capture(money, authorization, options = {})
34
34
  post = {}
35
35
  add_reference_params(post, authorization, options)
36
36
  add_amount(post, money, options)
37
- commit("CAPTURE", post)
37
+ commit('CAPTURE', post)
38
38
  end
39
39
 
40
- def refund(money, authorization, options={})
40
+ def refund(money, authorization, options = {})
41
41
  post = {}
42
42
  add_reference_params(post, authorization, options)
43
43
  add_amount(post, money, options)
44
- commit("REFUND", post)
44
+ commit('REFUND', post)
45
45
  end
46
46
 
47
47
  def void(authorization, options = {})
48
48
  post = {}
49
49
  add_reference_params(post, authorization, options)
50
- commit("REVERSAL", post)
50
+ commit('REVERSAL', post)
51
51
  end
52
52
 
53
- def credit(money, payment_method, options={})
54
- if payment_method.is_a?(String)
55
- raise ArgumentError, "Reference credits are not supported. Please supply the original credit card or use the #refund method."
56
- end
53
+ def credit(money, payment_method, options = {})
54
+ raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' if payment_method.is_a?(String)
57
55
 
58
56
  post = {}
59
57
  add_auth_purchase_params(post, money, payment_method, options)
60
- commit("CREDIT", post)
58
+ commit('CREDIT', post)
61
59
  end
62
60
 
63
- def verify(payment_method, options={})
61
+ def verify(payment_method, options = {})
64
62
  authorize(0, payment_method, options)
65
63
  end
66
64
 
67
- def store(payment_method, options={})
65
+ def store(payment_method, options = {})
68
66
  post = {}
69
67
  add_credentials(post)
70
68
  add_payment_method(post, payment_method)
71
69
  add_address(post, options)
72
70
  add_common_options(post, options)
73
- commit("STORE", post)
71
+ commit('STORE', post)
74
72
  end
75
73
 
76
74
  def supports_scrubbing?
@@ -81,15 +79,18 @@ module ActiveMerchant #:nodoc:
81
79
  force_utf8(transcript).
82
80
  gsub(%r((api_accesskey=)\w+), '\1[FILTERED]').
83
81
  gsub(%r((card_number=)\w+), '\1[FILTERED]').
84
- gsub(%r((card_verification=)\w+), '\1[FILTERED]')
82
+ gsub(%r((card_verification=)\w+), '\1[FILTERED]').
83
+ gsub(%r((bank_account_number=)\w+), '\1[FILTERED]').
84
+ gsub(%r((bank_routing_number=)\w+), '\1[FILTERED]')
85
85
  end
86
86
 
87
87
  private
88
88
 
89
89
  def force_utf8(string)
90
90
  return nil unless string
91
- binary = string.encode("BINARY", invalid: :replace, undef: :replace, replace: "?") # Needed for Ruby 2.0 since #encode is a no-op if the string is already UTF-8. It's not needed for Ruby 2.1 and up since it's not a no-op there.
92
- binary.encode("UTF-8", invalid: :replace, undef: :replace, replace: "?")
91
+
92
+ binary = string.encode('BINARY', invalid: :replace, undef: :replace, replace: '?') # Needed for Ruby 2.0 since #encode is a no-op if the string is already UTF-8. It's not needed for Ruby 2.1 and up since it's not a no-op there.
93
+ binary.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?')
93
94
  end
94
95
 
95
96
  def add_credentials(post)
@@ -134,7 +135,7 @@ module ActiveMerchant #:nodoc:
134
135
  end
135
136
 
136
137
  def add_credit_card(post, payment_method)
137
- post[:tender_type] = "CARD"
138
+ post[:tender_type] = 'CARD'
138
139
  post[:card_number] = payment_method.number
139
140
  post[:card_expiration] = expdate(payment_method)
140
141
  post[:card_verification] = payment_method.verification_value
@@ -143,18 +144,18 @@ module ActiveMerchant #:nodoc:
143
144
  end
144
145
 
145
146
  def add_token_payment_method(post, payment_method)
146
- post[:tender_type] = "CARD"
147
+ post[:tender_type] = 'CARD'
147
148
  post[:token_id] = payment_method
148
149
  post[:reissue] = true
149
150
  end
150
151
 
151
152
  def add_card_present_payment_method(post, payment_method)
152
- post[:tender_type] = "CARD"
153
+ post[:tender_type] = 'CARD'
153
154
  post[:card_tracks] = payment_method.track_data
154
155
  end
155
156
 
156
157
  def add_check(post, payment_method)
157
- post[:tender_type] = "ACH"
158
+ post[:tender_type] = 'ACH'
158
159
  post[:first_name] = payment_method.first_name
159
160
  post[:last_name] = payment_method.last_name
160
161
  post[:bank_account_number] = payment_method.account_number
@@ -208,12 +209,11 @@ module ActiveMerchant #:nodoc:
208
209
  success_from(response),
209
210
  message_from(response),
210
211
  response,
211
- authorization: response["transaction_id"],
212
- :avs_result => AVSResult.new(code: response["avs_response"]),
213
- :cvv_result => CVVResult.new(response["cvv2_response"]),
212
+ authorization: response['transaction_id'],
213
+ avs_result: AVSResult.new(code: response['avs_response']),
214
+ cvv_result: CVVResult.new(response['cvv2_response']),
214
215
  test: test?
215
216
  )
216
-
217
217
  rescue JSON::ParserError
218
218
  unparsable_response(raw_response)
219
219
  end
@@ -223,24 +223,23 @@ module ActiveMerchant #:nodoc:
223
223
  end
224
224
 
225
225
  def success_from(response)
226
- response["transaction_approved"] || !response["error"]
226
+ response['transaction_approved'] || !response['error']
227
227
  end
228
228
 
229
229
  def message_from(response)
230
- success_from(response) ? response["authorization_message"] : response["error_message"]
230
+ success_from(response) ? response['authorization_message'] : response['error_message']
231
231
  end
232
232
 
233
233
  def post_data(action, params)
234
234
  params[:transaction_type] = action
235
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
235
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
236
236
  end
237
237
 
238
238
  def unparsable_response(raw_response)
239
- message = "Invalid JSON response received from PayConex. Please contact PayConex if you continue to receive this message."
239
+ message = 'Invalid JSON response received from PayConex. Please contact PayConex if you continue to receive this message.'
240
240
  message += " (The raw response returned by the API was #{raw_response.inspect})"
241
241
  return Response.new(false, message)
242
242
  end
243
-
244
243
  end
245
244
  end
246
245
  end