swiss-activemerchant 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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 +249 -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 +243 -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 +227 -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 +312 -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 +120 -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,290 @@
1
+ require 'rexml/document'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class SecurePayAuGateway < Gateway
6
+ API_VERSION = 'xml-4.2'
7
+ PERIODIC_API_VERSION = 'spxml-3.0'
8
+
9
+ class_attribute :test_periodic_url, :live_periodic_url
10
+
11
+ self.test_url = 'https://test.api.securepay.com.au/xmlapi/payment'
12
+ self.live_url = 'https://api.securepay.com.au/xmlapi/payment'
13
+
14
+ self.test_periodic_url = 'https://test.securepay.com.au/xmlapi/periodic'
15
+ self.live_periodic_url = 'https://api.securepay.com.au/xmlapi/periodic'
16
+
17
+ self.supported_countries = ['AU']
18
+ self.supported_cardtypes = %i[visa master american_express diners_club jcb]
19
+
20
+ # The homepage URL of the gateway
21
+ self.homepage_url = 'http://securepay.com.au'
22
+
23
+ # The name of the gateway
24
+ self.display_name = 'SecurePay'
25
+
26
+ class_attribute :request_timeout
27
+ self.request_timeout = 60
28
+
29
+ self.money_format = :cents
30
+ self.default_currency = 'AUD'
31
+
32
+ # 0 Standard Payment
33
+ # 4 Refund
34
+ # 6 Client Reversal (Void)
35
+ # 10 Preauthorise
36
+ # 11 Preauth Complete (Advice)
37
+ TRANSACTIONS = {
38
+ purchase: 0,
39
+ authorization: 10,
40
+ capture: 11,
41
+ void: 6,
42
+ refund: 4
43
+ }
44
+
45
+ PERIODIC_ACTIONS = {
46
+ add_triggered: 'add',
47
+ remove_triggered: 'delete',
48
+ trigger: 'trigger'
49
+ }
50
+
51
+ PERIODIC_TYPES = {
52
+ add_triggered: 4,
53
+ remove_triggered: nil,
54
+ trigger: nil
55
+ }
56
+
57
+ SUCCESS_CODES = %w[00 08 11 16 77]
58
+
59
+ def initialize(options = {})
60
+ requires!(options, :login, :password)
61
+ super
62
+ end
63
+
64
+ def purchase(money, credit_card_or_stored_id, options = {})
65
+ if credit_card_or_stored_id.respond_to?(:number)
66
+ requires!(options, :order_id)
67
+ commit :purchase, build_purchase_request(money, credit_card_or_stored_id, options)
68
+ else
69
+ options[:billing_id] = credit_card_or_stored_id.to_s
70
+ commit_periodic(build_periodic_item(:trigger, money, nil, options))
71
+ end
72
+ end
73
+
74
+ def authorize(money, credit_card, options = {})
75
+ requires!(options, :order_id)
76
+ commit :authorization, build_purchase_request(money, credit_card, options)
77
+ end
78
+
79
+ def capture(money, reference, options = {})
80
+ commit :capture, build_reference_request(money, reference)
81
+ end
82
+
83
+ def refund(money, reference, options = {})
84
+ commit :refund, build_reference_request(money, reference)
85
+ end
86
+
87
+ def credit(money, reference, options = {})
88
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
89
+ refund(money, reference)
90
+ end
91
+
92
+ def void(reference, options = {})
93
+ commit :void, build_reference_request(nil, reference)
94
+ end
95
+
96
+ def store(creditcard, options = {})
97
+ requires!(options, :billing_id, :amount)
98
+ commit_periodic(build_periodic_item(:add_triggered, options[:amount], creditcard, options))
99
+ end
100
+
101
+ def unstore(identification, options = {})
102
+ options[:billing_id] = identification
103
+ commit_periodic(build_periodic_item(:remove_triggered, options[:amount], nil, options))
104
+ end
105
+
106
+ def supports_scrubbing?
107
+ true
108
+ end
109
+
110
+ def scrub(transcript)
111
+ transcript.
112
+ gsub(%r((<merchantID>).+(</merchantID>)), '\1[FILTERED]\2').
113
+ gsub(%r((<password>).+(</password>)), '\1[FILTERED]\2').
114
+ gsub(%r((<cardNumber>).+(</cardNumber>)), '\1[FILTERED]\2').
115
+ gsub(%r((<cvv>).+(</cvv>)), '\1[FILTERED]\2')
116
+ end
117
+
118
+ private
119
+
120
+ def build_purchase_request(money, credit_card, options)
121
+ xml = Builder::XmlMarkup.new
122
+
123
+ currency = options[:currency] || currency(money)
124
+
125
+ xml.tag! 'amount', localized_amount(money, currency)
126
+ xml.tag! 'currency', currency
127
+ xml.tag! 'purchaseOrderNo', options[:order_id].to_s.gsub(/[ ']/, '')
128
+
129
+ xml.tag! 'CreditCardInfo' do
130
+ xml.tag! 'cardNumber', credit_card.number
131
+ xml.tag! 'expiryDate', expdate(credit_card)
132
+ xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
133
+ end
134
+
135
+ xml.target!
136
+ end
137
+
138
+ def build_reference_request(money, reference)
139
+ xml = Builder::XmlMarkup.new
140
+
141
+ transaction_id, order_id, preauth_id, original_amount = reference.split('*')
142
+
143
+ xml.tag! 'amount', (money ? amount(money) : original_amount)
144
+ xml.tag! 'currency', options[:currency] || currency(money)
145
+ xml.tag! 'txnID', transaction_id
146
+ xml.tag! 'purchaseOrderNo', order_id
147
+ xml.tag! 'preauthID', preauth_id
148
+
149
+ xml.target!
150
+ end
151
+
152
+ def build_request(action, body)
153
+ xml = Builder::XmlMarkup.new
154
+ xml.instruct!
155
+ xml.tag! 'SecurePayMessage' do
156
+ xml.tag! 'MessageInfo' do
157
+ xml.tag! 'messageID', SecureRandom.hex(15)
158
+ xml.tag! 'messageTimestamp', generate_timestamp
159
+ xml.tag! 'timeoutValue', request_timeout
160
+ xml.tag! 'apiVersion', API_VERSION
161
+ end
162
+
163
+ xml.tag! 'MerchantInfo' do
164
+ xml.tag! 'merchantID', @options[:login]
165
+ xml.tag! 'password', @options[:password]
166
+ end
167
+
168
+ xml.tag! 'RequestType', 'Payment'
169
+ xml.tag! 'Payment' do
170
+ xml.tag! 'TxnList', 'count' => 1 do
171
+ xml.tag! 'Txn', 'ID' => 1 do
172
+ xml.tag! 'txnType', TRANSACTIONS[action]
173
+ xml.tag! 'txnSource', 23
174
+ xml << body
175
+ end
176
+ end
177
+ end
178
+ end
179
+
180
+ xml.target!
181
+ end
182
+
183
+ def commit(action, request)
184
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(action, request)))
185
+
186
+ Response.new(success?(response), message_from(response), response,
187
+ test: test?,
188
+ authorization: authorization_from(response))
189
+ end
190
+
191
+ def build_periodic_item(action, money, credit_card, options)
192
+ xml = Builder::XmlMarkup.new
193
+
194
+ xml.tag! 'actionType', PERIODIC_ACTIONS[action]
195
+ xml.tag! 'clientID', options[:billing_id].to_s
196
+
197
+ if credit_card
198
+ xml.tag! 'CreditCardInfo' do
199
+ xml.tag! 'cardNumber', credit_card.number
200
+ xml.tag! 'expiryDate', expdate(credit_card)
201
+ xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
202
+ end
203
+ end
204
+ xml.tag! 'amount', amount(money)
205
+ xml.tag! 'periodicType', PERIODIC_TYPES[action] if PERIODIC_TYPES[action]
206
+
207
+ xml.target!
208
+ end
209
+
210
+ def build_periodic_request(body)
211
+ xml = Builder::XmlMarkup.new
212
+ xml.instruct!
213
+ xml.tag! 'SecurePayMessage' do
214
+ xml.tag! 'MessageInfo' do
215
+ xml.tag! 'messageID', SecureRandom.hex(15)
216
+ xml.tag! 'messageTimestamp', generate_timestamp
217
+ xml.tag! 'timeoutValue', request_timeout
218
+ xml.tag! 'apiVersion', PERIODIC_API_VERSION
219
+ end
220
+
221
+ xml.tag! 'MerchantInfo' do
222
+ xml.tag! 'merchantID', @options[:login]
223
+ xml.tag! 'password', @options[:password]
224
+ end
225
+
226
+ xml.tag! 'RequestType', 'Periodic'
227
+ xml.tag! 'Periodic' do
228
+ xml.tag! 'PeriodicList', 'count' => 1 do
229
+ xml.tag! 'PeriodicItem', 'ID' => 1 do
230
+ xml << body
231
+ end
232
+ end
233
+ end
234
+ end
235
+ xml.target!
236
+ end
237
+
238
+ def commit_periodic(request)
239
+ my_request = build_periodic_request(request)
240
+ response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, my_request))
241
+
242
+ Response.new(success?(response), message_from(response), response,
243
+ test: test?,
244
+ authorization: authorization_from(response))
245
+ end
246
+
247
+ def success?(response)
248
+ SUCCESS_CODES.include?(response[:response_code])
249
+ end
250
+
251
+ def authorization_from(response)
252
+ [response[:txn_id], response[:purchase_order_no], response[:preauth_id], response[:amount]].join('*')
253
+ end
254
+
255
+ def message_from(response)
256
+ response[:response_text] || response[:status_description]
257
+ end
258
+
259
+ def expdate(credit_card)
260
+ "#{format(credit_card.month, :two_digits)}/#{format(credit_card.year, :two_digits)}"
261
+ end
262
+
263
+ def parse(body)
264
+ xml = REXML::Document.new(body)
265
+
266
+ response = {}
267
+
268
+ xml.root.elements.to_a.each do |node|
269
+ parse_element(response, node)
270
+ end
271
+
272
+ response
273
+ end
274
+
275
+ def parse_element(response, node)
276
+ if node.has_elements?
277
+ node.elements.each { |element| parse_element(response, element) }
278
+ else
279
+ response[node.name.underscore.to_sym] = node.text
280
+ end
281
+ end
282
+
283
+ # YYYYDDMMHHNNSSKKK000sOOO
284
+ def generate_timestamp
285
+ time = Time.now.utc
286
+ time.strftime("%Y%d%m%H%M%S#{time.usec}+000")
287
+ end
288
+ end
289
+ end
290
+ end
@@ -0,0 +1,103 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class SecurePayTechGateway < Gateway
4
+ class SecurePayTechPostData < PostData
5
+ self.required_fields = %i[OrderReference CardNumber CardExpiry CardHolderName CardType MerchantID MerchantKey Amount Currency]
6
+ end
7
+
8
+ self.live_url = self.test_url = 'https://tx.securepaytech.com/web/HttpPostPurchase'
9
+
10
+ PAYMENT_GATEWAY_RESPONSES = {
11
+ 1 => 'Transaction OK',
12
+ 2 => 'Insufficient funds',
13
+ 3 => 'Card expired',
14
+ 4 => 'Card declined',
15
+ 5 => 'Server error',
16
+ 6 => 'Communications error',
17
+ 7 => 'Unsupported transaction type',
18
+ 8 => 'Bad or malformed request',
19
+ 9 => 'Invalid card number'
20
+ }
21
+
22
+ self.default_currency = 'NZD'
23
+ self.supported_countries = ['NZ']
24
+ self.supported_cardtypes = %i[visa master american_express diners_club]
25
+ self.homepage_url = 'http://www.securepaytech.com/'
26
+ self.display_name = 'SecurePayTech'
27
+
28
+ def initialize(options = {})
29
+ requires!(options, :login, :password)
30
+ super
31
+ end
32
+
33
+ def purchase(money, creditcard, options = {})
34
+ post = SecurePayTechPostData.new
35
+
36
+ add_invoice(post, money, options)
37
+ add_creditcard(post, creditcard)
38
+
39
+ commit(:purchase, post)
40
+ end
41
+
42
+ private
43
+
44
+ def add_invoice(post, money, options)
45
+ post[:Amount] = amount(money)
46
+ post[:Currency] = options[:currency] || currency(money)
47
+
48
+ post[:OrderReference] = options[:order_id]
49
+ end
50
+
51
+ def add_creditcard(post, creditcard)
52
+ post[:CardNumber] = creditcard.number
53
+ post[:CardExpiry] = expdate(creditcard)
54
+ post[:CardHolderName] = creditcard.name
55
+
56
+ if creditcard.verification_value?
57
+ post[:EnableCSC] = true
58
+ post[:CSC] = creditcard.verification_value
59
+ end
60
+
61
+ # SPT will autodetect this
62
+ post[:CardType] = 0
63
+ end
64
+
65
+ def parse(body)
66
+ response = CGI.unescape(body).split(',')
67
+
68
+ result = {}
69
+ result[:result_code] = response[0].to_i
70
+
71
+ if response.length == 2
72
+ result[:fail_reason] = response[1]
73
+ else
74
+ result[:merchant_transaction_reference] = response[1]
75
+ result[:receipt_number] = response[2]
76
+ result[:transaction_number] = response[3]
77
+ result[:authorisation_id] = response[4]
78
+ result[:batch_number] = response[5]
79
+ end
80
+
81
+ result
82
+ end
83
+
84
+ def commit(action, post)
85
+ response = parse(ssl_post(self.live_url, post_data(action, post)))
86
+
87
+ Response.new(response[:result_code] == 1, message_from(response), response,
88
+ test: test?,
89
+ authorization: response[:merchant_transaction_reference])
90
+ end
91
+
92
+ def message_from(result)
93
+ PAYMENT_GATEWAY_RESPONSES[result[:result_code]]
94
+ end
95
+
96
+ def post_data(action, post)
97
+ post[:MerchantID] = @options[:login]
98
+ post[:MerchantKey] = @options[:password]
99
+ post.to_s
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,305 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class SecurionPayGateway < Gateway
4
+ self.test_url = 'https://api.securionpay.com/'
5
+ self.live_url = 'https://api.securionpay.com/'
6
+
7
+ self.supported_countries = %w(AD BE BG CH CY CZ DE DK EE ES FI FO FR GI GL GR GS GT HR HU IE IS IT LI LR LT
8
+ LU LV MC MT MU MV MW NL NO PL RO SE SI)
9
+
10
+ self.default_currency = 'USD'
11
+ self.money_format = :cents
12
+ self.supported_cardtypes = %i[visa master american_express discover jcb diners_club]
13
+
14
+ self.homepage_url = 'https://securionpay.com/'
15
+ self.display_name = 'SecurionPay'
16
+
17
+ STANDARD_ERROR_CODE_MAPPING = {
18
+ 'incorrect_number' => STANDARD_ERROR_CODE[:incorrect_number],
19
+ 'invalid_number' => STANDARD_ERROR_CODE[:invalid_number],
20
+ 'invalid_expiry_month' => STANDARD_ERROR_CODE[:invalid_expiry_date],
21
+ 'invalid_expiry_year' => STANDARD_ERROR_CODE[:invalid_expiry_date],
22
+ 'invalid_cvc' => STANDARD_ERROR_CODE[:invalid_cvc],
23
+ 'expired_card' => STANDARD_ERROR_CODE[:expired_card],
24
+ 'insufficient_funds' => STANDARD_ERROR_CODE[:card_declined],
25
+ 'incorrect_cvc' => STANDARD_ERROR_CODE[:incorrect_cvc],
26
+ 'incorrect_zip' => STANDARD_ERROR_CODE[:incorrect_zip],
27
+ 'card_declined' => STANDARD_ERROR_CODE[:card_declined],
28
+ 'processing_error' => STANDARD_ERROR_CODE[:processing_error],
29
+ 'lost_or_stolen' => STANDARD_ERROR_CODE[:card_declined],
30
+ 'suspected_fraud' => STANDARD_ERROR_CODE[:card_declined],
31
+ 'expired_token' => STANDARD_ERROR_CODE[:card_declined]
32
+ }
33
+
34
+ def initialize(options = {})
35
+ requires!(options, :secret_key)
36
+ super
37
+ end
38
+
39
+ def purchase(money, payment, options = {})
40
+ post = create_post_for_auth_or_purchase(money, payment, options)
41
+ commit('charges', post, options)
42
+ end
43
+
44
+ def authorize(money, payment, options = {})
45
+ post = create_post_for_auth_or_purchase(money, payment, options)
46
+ post[:captured] = 'false'
47
+ commit('charges', post, options)
48
+ end
49
+
50
+ def capture(money, authorization, options = {})
51
+ post = {}
52
+ add_amount(post, money, options)
53
+ commit("charges/#{CGI.escape(authorization)}/capture", post, options)
54
+ end
55
+
56
+ def refund(money, authorization, options = {})
57
+ post = {}
58
+ add_amount(post, money, options)
59
+ commit("charges/#{CGI.escape(authorization)}/refund", post, options)
60
+ end
61
+
62
+ def void(authorization, options = {})
63
+ commit("charges/#{CGI.escape(authorization)}/refund", {}, options)
64
+ end
65
+
66
+ def verify(credit_card, options = {})
67
+ MultiResponse.run(:use_first_response) do |r|
68
+ r.process { authorize(100, credit_card, options) }
69
+ r.process(:ignore_result) { void(r.authorization, options) }
70
+ end
71
+ end
72
+
73
+ def store(credit_card, options = {})
74
+ if options[:customer_id].blank?
75
+ MultiResponse.run() do |r|
76
+ # create charge object
77
+ r.process { authorize(100, credit_card, options) }
78
+ # create customer and save card
79
+ r.process { create_customer_add_card(r.authorization, options) }
80
+ # void the charge
81
+ r.process(:ignore_result) { void(r.params['metadata']['chargeId'], options) }
82
+ end
83
+ else
84
+ verify(credit_card, options)
85
+ end
86
+ end
87
+
88
+ def customer(options = {})
89
+ if options[:customer_id].blank?
90
+ return nil
91
+ else
92
+ commit("customers/#{CGI.escape(options[:customer_id])}", nil, options, :get)
93
+ end
94
+ end
95
+
96
+ def supports_scrubbing?
97
+ true
98
+ end
99
+
100
+ def scrub(transcript)
101
+ transcript.
102
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
103
+ gsub(%r((card\[number\]=)\d+), '\1[FILTERED]').
104
+ gsub(%r((card\[cvc\]=)\d+), '\1[FILTERED]')
105
+ end
106
+
107
+ private
108
+
109
+ def create_customer_add_card(authorization, options)
110
+ post = {}
111
+ post[:email] = options[:email]
112
+ post[:description] = options[:description]
113
+ post[:card] = authorization
114
+ post[:metadata] = {}
115
+ post[:metadata][:chargeId] = authorization
116
+ commit('customers', post, options)
117
+ end
118
+
119
+ def add_customer(post, payment, options)
120
+ post[:customerId] = options[:customer_id] if options[:customer_id]
121
+ end
122
+
123
+ def add_customer_data(post, options)
124
+ post[:description] = options[:description]
125
+ post[:ip] = options[:ip]
126
+ post[:user_agent] = options[:user_agent]
127
+ post[:referrer] = options[:referrer]
128
+ end
129
+
130
+ def create_post_for_auth_or_purchase(money, payment, options)
131
+ post = {}
132
+ add_amount(post, money, options, true)
133
+ add_creditcard(post, payment, options)
134
+ add_customer(post, payment, options)
135
+ add_customer_data(post, options)
136
+ add_external_three_ds(post, options)
137
+ if options[:email]
138
+ post[:metadata] = {}
139
+ post[:metadata][:email] = options[:email]
140
+ end
141
+ post
142
+ end
143
+
144
+ def add_external_three_ds(post, options)
145
+ return if options[:three_d_secure].blank?
146
+
147
+ post[:threeDSecure] = {
148
+ external: {
149
+ version: options[:three_d_secure][:version],
150
+ authenticationValue: options[:three_d_secure][:cavv],
151
+ acsTransactionId: options[:three_d_secure][:acs_transaction_id],
152
+ status: options[:three_d_secure][:authentication_response_status],
153
+ eci: options[:three_d_secure][:eci]
154
+ }.merge(xid_or_ds_trans_id(options[:three_d_secure]))
155
+ }
156
+ end
157
+
158
+ def xid_or_ds_trans_id(three_ds)
159
+ if three_ds[:version].to_f >= 2.0
160
+ { dsTransactionId: three_ds[:ds_transaction_id] }
161
+ else
162
+ { xid: three_ds[:xid] }
163
+ end
164
+ end
165
+
166
+ def validate_three_ds_params(three_ds)
167
+ errors = {}
168
+ supported_version = %w{1.0.2 2.1.0 2.2.0}.include?(three_ds[:version])
169
+ supported_auth_response = ['Y', 'N', 'U', 'R', 'E', 'A', nil].include?(three_ds[:status])
170
+
171
+ errors[:three_ds_version] = 'ThreeDs version not supported' unless supported_version
172
+ errors[:auth_response] = 'Authentication response value not supported' unless supported_auth_response
173
+ errors.compact!
174
+
175
+ errors.present? ? Response.new(false, 'ThreeDs data is invalid', errors) : nil
176
+ end
177
+
178
+ def add_amount(post, money, options, include_currency = false)
179
+ currency = (options[:currency] || default_currency)
180
+ post[:amount] = localized_amount(money, currency)
181
+ post[:currency] = currency.downcase if include_currency
182
+ end
183
+
184
+ def add_creditcard(post, creditcard, options)
185
+ card = {}
186
+ if creditcard.respond_to?(:number)
187
+ card[:number] = creditcard.number
188
+ card[:expMonth] = creditcard.month
189
+ card[:expYear] = creditcard.year
190
+ card[:cvc] = creditcard.verification_value if creditcard.verification_value?
191
+ card[:cardholderName] = creditcard.name if creditcard.name
192
+
193
+ post[:card] = card
194
+ add_address(post, options)
195
+ elsif creditcard.kind_of?(String)
196
+ post[:card] = creditcard
197
+ else
198
+ raise ArgumentError.new("Unhandled payment method #{creditcard.class}.")
199
+ end
200
+ end
201
+
202
+ def add_address(post, options)
203
+ return unless post[:card]&.kind_of?(Hash)
204
+
205
+ if address = options[:billing_address]
206
+ post[:card][:addressLine1] = address[:address1] if address[:address1]
207
+ post[:card][:addressLine2] = address[:address2] if address[:address2]
208
+ post[:card][:addressCountry] = address[:country] if address[:country]
209
+ post[:card][:addressZip] = address[:zip] if address[:zip]
210
+ post[:card][:addressState] = address[:state] if address[:state]
211
+ post[:card][:addressCity] = address[:city] if address[:city]
212
+ end
213
+ end
214
+
215
+ def parse(body)
216
+ JSON.parse(body)
217
+ end
218
+
219
+ def commit(url, parameters = nil, options = {}, method = nil)
220
+ if parameters.present? && parameters[:threeDSecure].present?
221
+ three_ds_errors = validate_three_ds_params(parameters[:threeDSecure][:external])
222
+ return three_ds_errors if three_ds_errors
223
+ end
224
+
225
+ response = api_request(url, parameters, options, method)
226
+ success = !response.key?('error')
227
+
228
+ Response.new(success,
229
+ (success ? 'Transaction approved' : response['error']['message']),
230
+ response,
231
+ test: test?,
232
+ authorization: (success ? response['id'] : response['error']['charge']),
233
+ error_code: (success ? nil : STANDARD_ERROR_CODE_MAPPING[response['error']['code']]))
234
+ end
235
+
236
+ def headers(options = {})
237
+ secret_key = options[:secret_key] || @options[:secret_key]
238
+
239
+ headers = {
240
+ 'Authorization' => 'Basic ' + Base64.encode64(secret_key.to_s + ':').strip,
241
+ 'User-Agent' => "SecurionPay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
242
+ }
243
+ headers
244
+ end
245
+
246
+ def response_error(raw_response)
247
+ parse(raw_response)
248
+ rescue JSON::ParserError
249
+ json_error(raw_response)
250
+ end
251
+
252
+ def post_data(params)
253
+ return nil unless params
254
+
255
+ params.map do |key, value|
256
+ next if value.blank?
257
+
258
+ if value.is_a?(Hash)
259
+ h = {}
260
+ value.each do |k, v|
261
+ h["#{key}[#{k}]"] = v unless v.blank?
262
+ end
263
+ post_data(h)
264
+ elsif value.is_a?(Array)
265
+ value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join('&')
266
+ else
267
+ "#{key}=#{CGI.escape(value.to_s)}"
268
+ end
269
+ end.compact.join('&')
270
+ end
271
+
272
+ def api_request(endpoint, parameters = nil, options = {}, method = nil)
273
+ raw_response = response = nil
274
+ begin
275
+ if method.blank?
276
+ raw_response = ssl_post(self.live_url + endpoint, post_data(parameters), headers(options))
277
+ else
278
+ raw_response = ssl_request(method, self.live_url + endpoint, post_data(parameters), headers(options))
279
+ end
280
+ response = parse(raw_response)
281
+ rescue ResponseError => e
282
+ raw_response = e.response.body
283
+ response = response_error(raw_response)
284
+ rescue JSON::ParserError
285
+ response = json_error(raw_response)
286
+ end
287
+ response
288
+ end
289
+
290
+ def json_error(raw_response)
291
+ msg = 'Invalid response received from the SecurionPay API.'
292
+ msg += " (The raw response returned by the API was #{raw_response.inspect})"
293
+ {
294
+ 'error' => {
295
+ 'message' => msg
296
+ }
297
+ }
298
+ end
299
+
300
+ def test?
301
+ (@options[:secret_key]&.include?('_test_'))
302
+ end
303
+ end
304
+ end
305
+ end