swiss-crm-activemerchant 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +4033 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +252 -0
  6. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  7. data/lib/active_merchant/billing/avs_result.rb +95 -0
  8. data/lib/active_merchant/billing/base.rb +48 -0
  9. data/lib/active_merchant/billing/check.rb +112 -0
  10. data/lib/active_merchant/billing/compatibility.rb +118 -0
  11. data/lib/active_merchant/billing/credit_card.rb +451 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +37 -0
  15. data/lib/active_merchant/billing/gateway.rb +332 -0
  16. data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
  17. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  18. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  19. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
  23. data/lib/active_merchant/billing/gateways/axcessms.rb +242 -0
  24. data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
  25. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  26. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  27. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  28. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  29. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  30. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  31. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
  33. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  34. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
  35. data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
  36. data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
  37. data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
  38. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  39. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
  40. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  41. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
  43. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  44. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  45. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  46. data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +235 -0
  52. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  53. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  54. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  59. data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
  60. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  61. data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
  62. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  63. data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
  64. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  65. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  66. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  67. data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
  68. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  69. data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
  70. data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
  71. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  72. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  73. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  74. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  75. data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
  76. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
  78. data/lib/active_merchant/billing/gateways/element.rb +406 -0
  79. data/lib/active_merchant/billing/gateways/epay.rb +296 -0
  80. data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
  81. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  82. data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
  83. data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
  84. data/lib/active_merchant/billing/gateways/exact.rb +219 -0
  85. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  86. data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
  87. data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
  88. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  89. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  90. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  91. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  92. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  93. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  94. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  95. data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
  96. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  97. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  98. data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
  99. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  100. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  101. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  102. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  103. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  104. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  105. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  106. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  107. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  108. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  109. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  110. data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
  111. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  112. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  113. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  114. data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
  115. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  116. data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
  117. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  118. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  119. data/lib/active_merchant/billing/gateways/litle.rb +643 -0
  120. data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
  121. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  122. data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
  123. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
  124. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  125. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  126. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  127. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  128. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  129. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  130. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  131. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  132. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  133. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  134. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  135. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  136. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  137. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  138. data/lib/active_merchant/billing/gateways/monei.rb +424 -0
  139. data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
  140. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  141. data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
  142. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  143. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  144. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  145. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  146. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  147. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  148. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  149. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  150. data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
  151. data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
  152. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  153. data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
  154. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  155. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  156. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  157. data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
  158. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  160. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  161. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  162. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  163. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  164. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  165. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  166. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  167. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  168. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  169. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  170. data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
  171. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  172. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  173. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  174. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  175. data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
  176. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  177. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  178. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  179. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  180. data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
  181. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  182. data/lib/active_merchant/billing/gateways/paynetworx.rb +228 -0
  183. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  184. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
  185. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  186. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  187. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  188. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  189. data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
  190. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  191. data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
  192. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  193. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  194. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  195. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  196. data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
  197. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  198. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  199. data/lib/active_merchant/billing/gateways/pin.rb +273 -0
  200. data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
  201. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  202. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  203. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  204. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  205. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  206. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  207. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  208. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  209. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  210. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  211. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  212. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  213. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  214. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  215. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  216. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  217. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  218. data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
  219. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  220. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  221. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  222. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  223. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  224. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  225. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  226. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  227. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  228. data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
  229. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  230. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  231. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  232. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  233. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  234. data/lib/active_merchant/billing/gateways/spreedly_core.rb +354 -0
  235. data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
  236. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
  237. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  238. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  239. data/lib/active_merchant/billing/gateways/tns.rb +23 -0
  240. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  241. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  242. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  243. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  244. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  245. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  246. data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
  247. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  248. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  249. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
  250. data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
  251. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  252. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  253. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  254. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  255. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  256. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  257. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  258. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  259. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  260. data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
  261. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  262. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  263. data/lib/active_merchant/billing/gateways.rb +14 -0
  264. data/lib/active_merchant/billing/model.rb +30 -0
  265. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  266. data/lib/active_merchant/billing/payment_token.rb +21 -0
  267. data/lib/active_merchant/billing/rails.rb +3 -0
  268. data/lib/active_merchant/billing/response.rb +121 -0
  269. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  270. data/lib/active_merchant/billing.rb +16 -0
  271. data/lib/active_merchant/connection.rb +194 -0
  272. data/lib/active_merchant/country.rb +338 -0
  273. data/lib/active_merchant/empty.rb +20 -0
  274. data/lib/active_merchant/errors.rb +38 -0
  275. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  276. data/lib/active_merchant/network_connection_retries.rb +78 -0
  277. data/lib/active_merchant/post_data.rb +26 -0
  278. data/lib/active_merchant/posts_data.rb +92 -0
  279. data/lib/active_merchant/version.rb +3 -0
  280. data/lib/active_merchant.rb +63 -0
  281. data/lib/activemerchant.rb +1 -0
  282. data/lib/certs/cacert.pem +3214 -0
  283. data/lib/support/gateway_support.rb +69 -0
  284. data/lib/support/outbound_hosts.rb +28 -0
  285. data/lib/support/ssl_verify.rb +88 -0
  286. data/lib/support/ssl_version.rb +86 -0
  287. metadata +506 -0
@@ -0,0 +1,253 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class PaywayDotComGateway < Gateway
4
+ self.test_url = 'https://paywaywsdev.com/PaywayWS/Payment/CreditCard'
5
+ self.live_url = 'https://paywayws.com/PaywayWS/Payment/CreditCard'
6
+
7
+ self.supported_countries = %w[US CA]
8
+ self.default_currency = 'USD'
9
+ self.supported_cardtypes = %i[visa master american_express discover]
10
+
11
+ self.money_format = :cents
12
+
13
+ self.homepage_url = 'http://www.payway.com'
14
+ self.display_name = 'Payway Gateway'
15
+
16
+ STANDARD_ERROR_CODE_MAPPING = {
17
+ '5012' => STANDARD_ERROR_CODE[:card_declined],
18
+ '5035' => STANDARD_ERROR_CODE[:invalid_number],
19
+ '5037' => STANDARD_ERROR_CODE[:invalid_expiry_date],
20
+ '5045' => STANDARD_ERROR_CODE[:incorrect_zip]
21
+ }
22
+
23
+ # Payway to standard AVSResult codes.
24
+ AVS_MAPPING = {
25
+ 'N1' => 'I', # No address given with order
26
+ 'N2' => 'I', # Bill-to address did not pass
27
+ '““' => 'R', # AVS not performed (Blanks returned)
28
+ 'IU' => 'G', # AVS not performed by Issuer
29
+ 'ID' => 'S', # Issuer does not participate in AVS
30
+ 'IE' => 'E', # Edit Error - AVS data is invalid
31
+ 'IS' => 'R', # System unavailable or time-out
32
+ 'IB' => 'B', # Street address match. Postal code not verified due to incompatible formats (both were sent).
33
+ 'IC' => 'C', # Street address and postal code not verified due to incompatible format (both were sent).
34
+ 'IP' => 'P', # Postal code match. Street address not verified due to incompatible formats (both were sent).
35
+ 'A1' => 'K', # Accountholder name matches
36
+ 'A3' => 'V', # Accountholder name, billing address and postal code.
37
+ 'A4' => 'L', # Accountholder name and billing postal code match
38
+ 'A7' => 'O', # Accountholder name and billing address match
39
+ 'B3' => 'H', # Accountholder name incorrect, billing address and postal code match
40
+ 'B4' => 'F', # Accountholder name incorrect, billing postal code matches
41
+ 'B7' => 'T', # Accountholder name incorrect, billing address matches
42
+ 'B8' => 'N', # Accountholder name, billing address and postal code are all incorrect
43
+ '??' => 'R', # A double question mark symbol indicates an unrecognized response from association
44
+ 'I1' => 'X', # Zip code +4 and Address Match
45
+ 'I2' => 'W', # Zip code +4 Match
46
+ 'I3' => 'Y', # Zip code and Address Match
47
+ 'I4' => 'Z', # Zip code Match
48
+ 'I5' => 'M', # +4 and Address Match
49
+ 'I6' => 'W', # +4 Match
50
+ 'I7' => 'A', # Address Match
51
+ 'I8' => 'C', # No Match
52
+ }
53
+
54
+ PAYWAY_WS_SUCCESS = '5000'
55
+
56
+ SCRUB_PATTERNS = [
57
+ %r(("password\\?":\\?")[^\\]+),
58
+ %r(("fsv\\?":\\?")\d+),
59
+ %r(("fsv\\?": \\?")\d+),
60
+ %r(("accountNumber\\?":\\?")\d+),
61
+ %r(("accountNumber\\?": \\?")[^\\]+),
62
+ %r(("Invalid account number: )\d+)
63
+ ].freeze
64
+
65
+ SCRUB_REPLACEMENT = '\1[FILTERED]'
66
+
67
+ def initialize(options = {})
68
+ requires!(options, :login, :password, :company_id, :source_id)
69
+ super
70
+ end
71
+
72
+ def purchase(money, payment, options = {})
73
+ post = {}
74
+ add_common(post, options)
75
+ add_card_payment(post, payment, options)
76
+ add_card_transaction_details(post, money, options)
77
+ add_address(post, payment, options)
78
+
79
+ commit('sale', post)
80
+ end
81
+
82
+ def authorize(money, payment, options = {})
83
+ post = {}
84
+ add_common(post, options)
85
+ add_card_payment(post, payment, options)
86
+ add_card_transaction_details(post, money, options)
87
+ add_address(post, payment, options)
88
+
89
+ commit('authorize', post)
90
+ end
91
+
92
+ def capture(money, authorization, options = {})
93
+ post = {}
94
+ add_common(post, options)
95
+ add_card_transaction_name(post, authorization, options)
96
+
97
+ commit('capture', post)
98
+ end
99
+
100
+ def credit(money, payment, options = {})
101
+ post = {}
102
+ add_common(post, options)
103
+ add_card_payment(post, payment, options)
104
+ add_card_transaction_details(post, money, options)
105
+ add_address(post, payment, options)
106
+
107
+ commit('credit', post)
108
+ end
109
+
110
+ def void(authorization, options = {})
111
+ post = {}
112
+ add_common(post, options)
113
+ add_card_transaction_name(post, authorization, options)
114
+
115
+ commit('void', post)
116
+ end
117
+
118
+ def supports_scrubbing?
119
+ true
120
+ end
121
+
122
+ def scrub(transcript)
123
+ SCRUB_PATTERNS.inject(transcript) do |text, pattern|
124
+ text.gsub(pattern, SCRUB_REPLACEMENT)
125
+ end
126
+ end
127
+
128
+ private
129
+
130
+ def add_common(post, options)
131
+ post[:userName] = @options[:login]
132
+ post[:password] = @options[:password]
133
+ post[:companyId] = @options[:company_id]
134
+ post[:cardTransaction] = {}
135
+ post[:cardTransaction][:sourceId] = @options[:source_id]
136
+ end
137
+
138
+ def add_address(post, payment, options)
139
+ post[:cardAccount] ||= {}
140
+ address = options[:billing_address] || options[:address] || {}
141
+ first_name, last_name = split_names(address[:name])
142
+ full_address = "#{address[:address1]} #{address[:address2]}".strip
143
+ phone = address[:phone] || address[:phone_number]
144
+
145
+ post[:cardAccount][:firstName] = first_name if first_name
146
+ post[:cardAccount][:lastName] = last_name if last_name
147
+ post[:cardAccount][:address] = full_address if full_address
148
+ post[:cardAccount][:city] = address[:city] if address[:city]
149
+ post[:cardAccount][:state] = address[:state] if address[:state]
150
+ post[:cardAccount][:zip] = address[:zip] if address[:zip]
151
+ post[:cardAccount][:phone] = phone if phone
152
+ end
153
+
154
+ def add_card_transaction_details(post, money, options)
155
+ post[:cardTransaction][:amount] = amount(money)
156
+ eci_type = options[:eci_type].nil? ? '1' : options[:eci_type]
157
+ post[:cardTransaction][:eciType] = eci_type
158
+ post[:cardTransaction][:processorSoftDescriptor] = options[:processor_soft_descriptor] if options[:processor_soft_descriptor]
159
+ post[:cardTransaction][:tax] = options[:tax] if options[:tax]
160
+ end
161
+
162
+ def add_card_transaction_name(post, identifier, options)
163
+ post[:cardTransaction][:name] = identifier
164
+ end
165
+
166
+ def add_card_payment(post, payment, options)
167
+ # credit_card
168
+ post[:accountInputMode] = 'primaryAccountNumber'
169
+
170
+ post[:cardAccount] ||= {}
171
+ post[:cardAccount][:accountNumber] = payment.number
172
+ post[:cardAccount][:fsv] = payment.verification_value
173
+ post[:cardAccount][:expirationDate] = expdate(payment)
174
+ post[:cardAccount][:email] = options[:email] if options[:email]
175
+ end
176
+
177
+ def expdate(credit_card)
178
+ year = format(credit_card.year, :four_digits)
179
+ month = format(credit_card.month, :two_digits)
180
+
181
+ month + year
182
+ end
183
+
184
+ def parse(body)
185
+ body.blank? ? {} : JSON.parse(body)
186
+ end
187
+
188
+ def commit(action, parameters)
189
+ parameters[:request] = action
190
+
191
+ url = (test? ? test_url : live_url)
192
+ payload = parameters.to_json unless parameters.nil?
193
+
194
+ response =
195
+ begin
196
+ parse(ssl_request(:post, url, payload, headers))
197
+ rescue ResponseError => e
198
+ return Response.new(false, 'Invalid Login') if e.response.code == '401'
199
+
200
+ parse(e.response.body)
201
+ end
202
+
203
+ success = success_from(response)
204
+ avs_result_code = response['cardTransaction'].nil? || response['cardTransaction']['addressVerificationResults'].nil? ? '' : response['cardTransaction']['addressVerificationResults']
205
+ avs_result = AVSResult.new(code: AVS_MAPPING[avs_result_code])
206
+ cvv_result = CVVResult.new(response['cardTransaction']['fraudSecurityResults']) if response['cardTransaction'] && response['cardTransaction']['fraudSecurityResults']
207
+
208
+ Response.new(
209
+ success,
210
+ message_from(success, response),
211
+ response,
212
+ test: test?,
213
+ error_code: error_code_from(response),
214
+ authorization: authorization_from(response),
215
+ avs_result: avs_result,
216
+ cvv_result: cvv_result
217
+ )
218
+ end
219
+
220
+ def success_from(response)
221
+ response['paywayCode'] == PAYWAY_WS_SUCCESS
222
+ end
223
+
224
+ def error_code_from(response)
225
+ return '' if success_from(response)
226
+
227
+ error = !STANDARD_ERROR_CODE_MAPPING[response['paywayCode']].nil? ? STANDARD_ERROR_CODE_MAPPING[response['paywayCode']] : STANDARD_ERROR_CODE[:processing_error]
228
+ return error
229
+ end
230
+
231
+ def message_from(success, response)
232
+ return '' if response['paywayCode'].nil?
233
+
234
+ return response['paywayCode'] + '-' + 'success' if success
235
+
236
+ response['paywayCode']
237
+ end
238
+
239
+ def authorization_from(response)
240
+ return '' if !success_from(response) || response['cardTransaction'].nil?
241
+
242
+ response['cardTransaction']['name']
243
+ end
244
+
245
+ def headers
246
+ {
247
+ 'Accept' => 'application/json',
248
+ 'Content-type' => 'application/json'
249
+ }
250
+ end
251
+ end
252
+ end
253
+ end
@@ -0,0 +1,273 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class PinGateway < Gateway
4
+ self.test_url = 'https://test-api.pinpayments.com/1'
5
+ self.live_url = 'https://api.pinpayments.com/1'
6
+
7
+ self.default_currency = 'AUD'
8
+ self.money_format = :cents
9
+ self.supported_countries = %w(AU NZ)
10
+ self.supported_cardtypes = %i[visa master american_express diners_club discover jcb]
11
+ self.homepage_url = 'http://www.pinpayments.com/'
12
+ self.display_name = 'Pin Payments'
13
+
14
+ def initialize(options = {})
15
+ requires!(options, :api_key)
16
+ super
17
+ end
18
+
19
+ # Create a charge using a credit card, card token or customer token
20
+ #
21
+ # To charge a credit card: purchase([money], [creditcard hash], ...)
22
+ # To charge a customer: purchase([money], [token], ...)
23
+ def purchase(money, creditcard, options = {})
24
+ post = {}
25
+
26
+ add_amount(post, money, options)
27
+ add_customer_data(post, options)
28
+ add_invoice(post, options)
29
+ add_creditcard(post, creditcard)
30
+ add_address(post, creditcard, options)
31
+ add_capture(post, options)
32
+ add_metadata(post, options)
33
+ add_3ds(post, options)
34
+
35
+ commit(:post, 'charges', post, options)
36
+ end
37
+
38
+ # Create a customer and associated credit card. The token that is returned
39
+ # can be used instead of a credit card parameter in the purchase method
40
+ def store(creditcard, options = {})
41
+ post = {}
42
+
43
+ add_creditcard(post, creditcard)
44
+ add_customer_data(post, options)
45
+ add_address(post, creditcard, options)
46
+ commit(:post, 'customers', post, options)
47
+ end
48
+
49
+ # Unstore a customer and associated credit card.
50
+ def unstore(token)
51
+ customer_token =
52
+ if /cus_/.match?(token)
53
+ get_customer_token(token)
54
+ else
55
+ token
56
+ end
57
+ commit(:delete, "customers/#{CGI.escape(customer_token)}", {}, {})
58
+ end
59
+
60
+ # Refund a transaction
61
+ def refund(money, token, options = {})
62
+ commit(:post, "charges/#{CGI.escape(token)}/refunds", { amount: amount(money) }, options)
63
+ end
64
+
65
+ # Authorize an amount on a credit card. Once authorized, you can later
66
+ # capture this charge using the charge token that is returned.
67
+ def authorize(money, creditcard, options = {})
68
+ options[:capture] = false
69
+
70
+ purchase(money, creditcard, options)
71
+ end
72
+
73
+ # Captures a previously authorized charge. Capturing only part of the original
74
+ # authorization is currently not supported.
75
+ def capture(money, token, options = {})
76
+ commit(:put, "charges/#{CGI.escape(token)}/capture", { amount: amount(money) }, options)
77
+ end
78
+
79
+ # Voids a previously authorized charge.
80
+ def void(token, options = {})
81
+ commit(:put, "charges/#{CGI.escape(token)}/void", {}, options)
82
+ end
83
+
84
+ # Updates the credit card for the customer.
85
+ def update(token, creditcard, options = {})
86
+ post = {}
87
+ token = get_customer_token(token)
88
+
89
+ add_creditcard(post, creditcard)
90
+ add_customer_data(post, options)
91
+ add_address(post, creditcard, options)
92
+ commit(:put, "customers/#{CGI.escape(token)}", post, options)
93
+ end
94
+
95
+ def supports_scrubbing
96
+ true
97
+ end
98
+
99
+ def scrub(transcript)
100
+ transcript.
101
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
102
+ gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]').
103
+ gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]')
104
+ end
105
+
106
+ private
107
+
108
+ def add_amount(post, money, options)
109
+ post[:amount] = amount(money)
110
+ post[:currency] = (options[:currency] || currency(money))
111
+ post[:currency] = post[:currency].upcase if post[:currency]
112
+ end
113
+
114
+ def add_customer_data(post, options)
115
+ post[:email] = options[:email] if options[:email]
116
+ post[:ip_address] = options[:ip] if options[:ip]
117
+ end
118
+
119
+ def add_address(post, creditcard, options)
120
+ return if creditcard.kind_of?(String)
121
+
122
+ address = (options[:billing_address] || options[:address])
123
+ return unless address
124
+
125
+ post[:card] ||= {}
126
+ post[:card].merge!(
127
+ address_line1: address[:address1],
128
+ address_city: address[:city],
129
+ address_postcode: address[:zip],
130
+ address_state: address[:state],
131
+ address_country: address[:country]
132
+ )
133
+ end
134
+
135
+ def add_invoice(post, options)
136
+ post[:description] = options[:description] || 'Active Merchant Purchase'
137
+ post[:reference] = options[:reference] if options[:reference]
138
+ end
139
+
140
+ def add_capture(post, options)
141
+ capture = options[:capture]
142
+
143
+ post[:capture] = capture != false
144
+ end
145
+
146
+ def add_creditcard(post, creditcard)
147
+ if creditcard.respond_to?(:number)
148
+ post[:card] ||= {}
149
+
150
+ post[:card].merge!(
151
+ number: creditcard.number,
152
+ expiry_month: creditcard.month,
153
+ expiry_year: creditcard.year,
154
+ cvc: creditcard.verification_value,
155
+ name: creditcard.name
156
+ )
157
+ elsif creditcard.kind_of?(String)
158
+ if /^card_/.match?(creditcard)
159
+ post[:card_token] = get_card_token(creditcard)
160
+ else
161
+ post[:customer_token] = creditcard
162
+ end
163
+ end
164
+ end
165
+
166
+ def get_customer_token(token)
167
+ token.split(/;(?=cus)/).last
168
+ end
169
+
170
+ def get_card_token(token)
171
+ token.split(/;(?=cus)/).first
172
+ end
173
+
174
+ def add_metadata(post, options)
175
+ post[:metadata] = options[:metadata] if options[:metadata]
176
+ end
177
+
178
+ def add_3ds(post, options)
179
+ if options[:three_d_secure]
180
+ post[:three_d_secure] = {}
181
+ post[:three_d_secure][:version] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
182
+ post[:three_d_secure][:eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
183
+ post[:three_d_secure][:cavv] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
184
+ post[:three_d_secure][:transaction_id] = options[:three_d_secure][:ds_transaction_id] || options[:three_d_secure][:xid]
185
+ end
186
+ end
187
+
188
+ def headers(params = {})
189
+ result = {
190
+ 'Content-Type' => 'application/json',
191
+ 'Authorization' => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}"
192
+ }
193
+
194
+ result['X-Partner-Key'] = params[:partner_key] if params[:partner_key]
195
+ result['X-Safe-Card'] = params[:safe_card] if params[:safe_card]
196
+ result
197
+ end
198
+
199
+ def commit(method, action, params, options)
200
+ url = "#{test? ? test_url : live_url}/#{action}"
201
+
202
+ begin
203
+ raw_response = ssl_request(method, url, post_data(params), headers(options))
204
+ body = parse(raw_response)
205
+ rescue ResponseError => e
206
+ body = parse(e.response.body)
207
+ end
208
+
209
+ if body.nil?
210
+ no_content_response
211
+ elsif body['response']
212
+ success_response(body)
213
+ elsif body['error']
214
+ error_response(body)
215
+ end
216
+ rescue JSON::ParserError
217
+ return unparsable_response(raw_response)
218
+ end
219
+
220
+ def success_response(body)
221
+ response = body['response']
222
+ Response.new(
223
+ true,
224
+ response['status_message'],
225
+ body,
226
+ authorization: token(response),
227
+ test: test?
228
+ )
229
+ end
230
+
231
+ def error_response(body)
232
+ Response.new(
233
+ false,
234
+ body['error_description'],
235
+ body,
236
+ authorization: nil,
237
+ test: test?
238
+ )
239
+ end
240
+
241
+ def no_content_response
242
+ Response.new(
243
+ true,
244
+ nil,
245
+ {},
246
+ test: test?
247
+ )
248
+ end
249
+
250
+ def unparsable_response(raw_response)
251
+ message = 'Invalid JSON response received from Pin Payments. Please contact support@pinpayments.com if you continue to receive this message.'
252
+ message += " (The raw response returned by the API was #{raw_response.inspect})"
253
+ return Response.new(false, message)
254
+ end
255
+
256
+ def token(response)
257
+ if response['token'].start_with?('cus')
258
+ "#{response.dig('card', 'token')};#{response['token']}"
259
+ else
260
+ response['token']
261
+ end
262
+ end
263
+
264
+ def parse(body)
265
+ JSON.parse(body) unless body.nil? || body.length == 0
266
+ end
267
+
268
+ def post_data(parameters = {})
269
+ parameters.to_json
270
+ end
271
+ end
272
+ end
273
+ end