active_accountability_merchant 1.97.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +2948 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +246 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +15 -0
  8. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  9. data/lib/active_merchant/billing/avs_result.rb +96 -0
  10. data/lib/active_merchant/billing/base.rb +61 -0
  11. data/lib/active_merchant/billing/check.rb +80 -0
  12. data/lib/active_merchant/billing/compatibility.rb +117 -0
  13. data/lib/active_merchant/billing/credit_card.rb +406 -0
  14. data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
  15. data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
  16. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  17. data/lib/active_merchant/billing/gateway.rb +330 -0
  18. data/lib/active_merchant/billing/gateways.rb +14 -0
  19. data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
  20. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  23. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -0
  24. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  25. data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
  26. data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -0
  27. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  28. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  29. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +384 -0
  30. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  31. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +217 -0
  33. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
  34. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  35. data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
  36. data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
  37. data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
  38. data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
  39. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  40. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  41. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +22 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -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 +316 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -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 +327 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  59. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  60. data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
  61. data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
  62. data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
  63. data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
  64. data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
  65. data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
  68. data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  73. data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
  74. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  75. data/lib/active_merchant/billing/gateways/epay.rb +285 -0
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  77. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
  80. data/lib/active_merchant/billing/gateways/exact.rb +224 -0
  81. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -0
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  91. data/lib/active_merchant/billing/gateways/forte.rb +270 -0
  92. data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
  96. data/lib/active_merchant/billing/gateways/hps.rb +350 -0
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  99. data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
  100. data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
  101. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  102. data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
  103. data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
  104. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
  111. data/lib/active_merchant/billing/gateways/litle.rb +507 -0
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -0
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +286 -0
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
  121. data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
  124. data/lib/active_merchant/billing/gateways/migs.rb +332 -0
  125. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  126. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +217 -0
  128. data/lib/active_merchant/billing/gateways/monei.rb +338 -0
  129. data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
  130. data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
  131. data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
  132. data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
  133. data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
  134. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  135. data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
  136. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  137. data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
  138. data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
  139. data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
  140. data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
  141. data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
  142. data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
  143. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  144. data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
  145. data/lib/active_merchant/billing/gateways/opp.rb +388 -0
  146. data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
  147. data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
  149. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  150. data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
  151. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  152. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  153. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -0
  154. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  155. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  156. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +188 -0
  157. data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
  158. data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
  159. data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
  160. data/lib/active_merchant/billing/gateways/payex.rb +410 -0
  161. data/lib/active_merchant/billing/gateways/payflow.rb +383 -0
  162. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  163. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +43 -0
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  165. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  166. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  167. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  168. data/lib/active_merchant/billing/gateways/payment_express.rb +369 -0
  169. data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
  170. data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
  171. data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
  172. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -0
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  175. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  176. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  177. data/lib/active_merchant/billing/gateways/paypal_express.rb +269 -0
  178. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  179. data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
  180. data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
  181. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  182. data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
  183. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  184. data/lib/active_merchant/billing/gateways/pin.rb +234 -0
  185. data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
  186. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  187. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  188. data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
  189. data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
  190. data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
  191. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  192. data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
  193. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  194. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
  195. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  196. data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
  197. data/lib/active_merchant/billing/gateways/realex.rb +374 -0
  198. data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
  199. data/lib/active_merchant/billing/gateways/s5.rb +246 -0
  200. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  201. data/lib/active_merchant/billing/gateways/sage.rb +448 -0
  202. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  203. data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
  204. data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
  205. data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
  206. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
  207. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
  208. data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
  209. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  210. data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
  211. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  212. data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
  213. data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
  214. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
  215. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
  216. data/lib/active_merchant/billing/gateways/telr.rb +274 -0
  217. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  218. data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
  219. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  220. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  221. data/lib/active_merchant/billing/gateways/transax.rb +22 -0
  222. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  223. data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
  224. data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
  225. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  226. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
  227. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
  228. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  229. data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
  230. data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
  231. data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
  232. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  233. data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
  234. data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
  235. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  236. data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
  237. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
  238. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  239. data/lib/active_merchant/billing/model.rb +30 -0
  240. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  241. data/lib/active_merchant/billing/payment_token.rb +21 -0
  242. data/lib/active_merchant/billing/rails.rb +3 -0
  243. data/lib/active_merchant/billing/response.rb +92 -0
  244. data/lib/active_merchant/connection.rb +195 -0
  245. data/lib/active_merchant/country.rb +336 -0
  246. data/lib/active_merchant/empty.rb +20 -0
  247. data/lib/active_merchant/errors.rb +35 -0
  248. data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
  249. data/lib/active_merchant/network_connection_retries.rb +80 -0
  250. data/lib/active_merchant/post_data.rb +25 -0
  251. data/lib/active_merchant/posts_data.rb +92 -0
  252. data/lib/active_merchant/version.rb +3 -0
  253. data/lib/activemerchant.rb +1 -0
  254. data/lib/certs/cacert.pem +3988 -0
  255. data/lib/support/gateway_support.rb +69 -0
  256. data/lib/support/outbound_hosts.rb +28 -0
  257. data/lib/support/ssl_verify.rb +92 -0
  258. data/lib/support/ssl_version.rb +87 -0
  259. metadata +435 -0
@@ -0,0 +1,186 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # Bogus Gateway
4
+ class BogusGateway < Gateway
5
+ AUTHORIZATION = '53433'
6
+
7
+ AUTHORIZATION_EMV_SUCCESS = '8A023030'
8
+ AUTHORIZATION_EMV_DECLINE = '8A023035'
9
+
10
+ SUCCESS_MESSAGE = 'Bogus Gateway: Forced success'
11
+ FAILURE_MESSAGE = 'Bogus Gateway: Forced failure'
12
+ NUMBER_ERROR_MESSAGE = 'Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error'
13
+ AMOUNT_ERROR_MESSAGE = 'Bogus Gateway: Use amount ending in 00 for success, 05 for failure and anything else for exception'
14
+ UNSTORE_ERROR_MESSAGE = 'Bogus Gateway: Use trans_id ending in 1 for success, 2 for exception and anything else for error'
15
+ CAPTURE_ERROR_MESSAGE = 'Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success'
16
+ VOID_ERROR_MESSAGE = 'Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success'
17
+ REFUND_ERROR_MESSAGE = 'Bogus Gateway: Use trans_id number ending in 1 for exception, 2 for error and anything else for success'
18
+ CHECK_ERROR_MESSAGE = 'Bogus Gateway: Use bank account number ending in 1 for success, 2 for exception and anything else for error'
19
+
20
+ self.supported_countries = []
21
+ self.supported_cardtypes = [:bogus]
22
+ self.homepage_url = 'http://example.com'
23
+ self.display_name = 'Bogus'
24
+
25
+ def authorize(money, paysource, options = {})
26
+ if paysource.respond_to?(:emv?) && paysource.emv?
27
+ authorize_emv(money, paysource, options)
28
+ else
29
+ authorize_swipe(money, paysource, options)
30
+ end
31
+ end
32
+
33
+ def purchase(money, paysource, options = {})
34
+ if paysource.respond_to?(:emv?) && paysource.emv?
35
+ purchase_emv(money, paysource, options)
36
+ else
37
+ purchase_swipe(money, paysource, options)
38
+ end
39
+ end
40
+
41
+ def credit(money, paysource, options = {})
42
+ if paysource.is_a?(String)
43
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
44
+ return refund(money, paysource, options)
45
+ end
46
+
47
+ money = amount(money)
48
+ case normalize(paysource)
49
+ when /1$/
50
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
51
+ when /2$/
52
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
53
+ else
54
+ raise Error, error_message(paysource)
55
+ end
56
+ end
57
+
58
+ def refund(money, reference, options = {})
59
+ money = amount(money)
60
+ case reference
61
+ when /1$/
62
+ raise Error, REFUND_ERROR_MESSAGE
63
+ when /2$/
64
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
65
+ else
66
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
67
+ end
68
+ end
69
+
70
+ def capture(money, reference, options = {})
71
+ money = amount(money)
72
+ case reference
73
+ when /1$/
74
+ raise Error, CAPTURE_ERROR_MESSAGE
75
+ when /2$/
76
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
77
+ else
78
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
79
+ end
80
+ end
81
+
82
+ def void(reference, options = {})
83
+ case reference
84
+ when /1$/
85
+ raise Error, VOID_ERROR_MESSAGE
86
+ when /2$/
87
+ Response.new(false, FAILURE_MESSAGE, {:authorization => reference, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
88
+ else
89
+ Response.new(true, SUCCESS_MESSAGE, {:authorization => reference}, :test => true)
90
+ end
91
+ end
92
+
93
+ def store(paysource, options = {})
94
+ case normalize(paysource)
95
+ when /1$/
96
+ Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION)
97
+ when /2$/
98
+ Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
99
+ else
100
+ raise Error, error_message(paysource)
101
+ end
102
+ end
103
+
104
+ def unstore(reference, options = {})
105
+ case reference
106
+ when /1$/
107
+ Response.new(true, SUCCESS_MESSAGE, {}, :test => true)
108
+ when /2$/
109
+ Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
110
+ else
111
+ raise Error, UNSTORE_ERROR_MESSAGE
112
+ end
113
+ end
114
+
115
+ private
116
+
117
+ def authorize_emv(money, paysource, options = {})
118
+ money = amount(money)
119
+ case money
120
+ when /00$/
121
+ Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION, :emv_authorization => AUTHORIZATION_EMV_SUCCESS)
122
+ when /05$/
123
+ Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error], :emv_authorization => AUTHORIZATION_EMV_DECLINE)
124
+ else
125
+ raise Error, error_message(paysource)
126
+ end
127
+ end
128
+
129
+ def authorize_swipe(money, paysource, options = {})
130
+ money = amount(money)
131
+ case normalize(paysource)
132
+ when /1$/, AUTHORIZATION
133
+ Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION)
134
+ when /2$/
135
+ Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
136
+ else
137
+ raise Error, error_message(paysource)
138
+ end
139
+ end
140
+
141
+ def purchase_emv(money, paysource, options = {})
142
+ money = amount(money)
143
+ case money
144
+ when /00$/
145
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true, :authorization => AUTHORIZATION, :emv_authorization => AUTHORIZATION_EMV_SUCCESS)
146
+ when /05$/
147
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error], :emv_authorization => AUTHORIZATION_EMV_DECLINE)
148
+ else
149
+ raise Error, error_message(paysource)
150
+ end
151
+ end
152
+
153
+ def purchase_swipe(money, paysource, options = {})
154
+ money = amount(money)
155
+ case normalize(paysource)
156
+ when /1$/, AUTHORIZATION
157
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true, :authorization => AUTHORIZATION)
158
+ when /2$/
159
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
160
+ else
161
+ raise Error, error_message(paysource)
162
+ end
163
+ end
164
+
165
+ def normalize(paysource)
166
+ if paysource.respond_to?(:account_number) && (paysource.try(:number).blank? || paysource.number.blank?)
167
+ paysource.account_number
168
+ elsif paysource.respond_to?(:number)
169
+ paysource.number
170
+ else
171
+ paysource.to_s
172
+ end
173
+ end
174
+
175
+ def error_message(paysource)
176
+ if paysource.respond_to?(:emv?) && paysource.emv?
177
+ AMOUNT_ERROR_MESSAGE
178
+ elsif paysource.respond_to?(:account_number)
179
+ CHECK_ERROR_MESSAGE
180
+ elsif paysource.respond_to?(:number)
181
+ NUMBER_ERROR_MESSAGE
182
+ end
183
+ end
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,220 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class BorgunGateway < Gateway
6
+ self.display_name = 'Borgun'
7
+ self.homepage_url = 'http://www.borgun.com'
8
+
9
+ self.test_url = 'https://gatewaytest.borgun.is/ws/Heimir.pub.ws:Authorization'
10
+ self.live_url = 'https://gateway01.borgun.is/ws/Heimir.pub.ws:Authorization'
11
+
12
+ self.supported_countries = ['IS', 'GB', 'HU', 'CZ', 'DE', 'DK', 'SE' ]
13
+ self.default_currency = 'ISK'
14
+ self.money_format = :cents
15
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb]
16
+
17
+ self.homepage_url = 'https://www.borgun.is/'
18
+
19
+ def initialize(options={})
20
+ requires!(options, :processor, :merchant_id, :username, :password)
21
+ super
22
+ end
23
+
24
+ def purchase(money, payment, options={})
25
+ post = {}
26
+ post[:TransType] = '1'
27
+ add_invoice(post, money, options)
28
+ add_payment_method(post, payment)
29
+ commit('sale', post)
30
+ end
31
+
32
+ def authorize(money, payment, options={})
33
+ post = {}
34
+ post[:TransType] = '5'
35
+ add_invoice(post, money, options)
36
+ add_payment_method(post, payment)
37
+ commit('authonly', post)
38
+ end
39
+
40
+ def capture(money, authorization, options={})
41
+ post = {}
42
+ post[:TransType] = '1'
43
+ add_invoice(post, money, options)
44
+ add_reference(post, authorization)
45
+ commit('capture', post)
46
+ end
47
+
48
+ def refund(money, authorization, options={})
49
+ post = {}
50
+ post[:TransType] = '3'
51
+ add_invoice(post, money, options)
52
+ add_reference(post, authorization)
53
+ commit('refund', post)
54
+ end
55
+
56
+ def void(authorization, options={})
57
+ post = {}
58
+ # TransType, TrAmount, and currency must match original values from auth or purchase.
59
+ _, _, _, _, _, transtype, tramount, currency = split_authorization(authorization)
60
+ post[:TransType] = transtype
61
+ options[:currency] = options[:currency] || CURRENCY_CODES.key(currency)
62
+ add_invoice(post, tramount.to_i, options)
63
+ add_reference(post, authorization)
64
+ commit('void', post)
65
+ end
66
+
67
+ def supports_scrubbing
68
+ true
69
+ end
70
+
71
+ def scrub(transcript)
72
+ transcript.gsub(%r((&lt;PAN&gt;)[^&]*(&lt;/PAN&gt;))i, '\1[FILTERED]\2').
73
+ gsub(%r((&lt;CVC2&gt;)[^&]*(&lt;/CVC2&gt;))i, '\1[FILTERED]\2').
74
+ gsub(%r(((?:\r\n)?Authorization: Basic )[^\r\n]+(\r\n)?), '\1[FILTERED]\2')
75
+ end
76
+
77
+ private
78
+
79
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
80
+ CURRENCY_CODES['ISK'] = '352'
81
+ CURRENCY_CODES['EUR'] = '978'
82
+ CURRENCY_CODES['USD'] = '840'
83
+
84
+ def add_invoice(post, money, options)
85
+ post[:TrAmount] = amount(money)
86
+ post[:TrCurrency] = CURRENCY_CODES[options[:currency] || currency(money)]
87
+ post[:TerminalID] = options[:terminal_id] || '1'
88
+ end
89
+
90
+ def add_payment_method(post, payment_method)
91
+ post[:PAN] = payment_method.number
92
+ post[:ExpDate] = format(payment_method.year, :two_digits) + format(payment_method.month, :two_digits)
93
+ post[:CVC2] = payment_method.verification_value
94
+ post[:DateAndTime] = Time.now.strftime('%y%m%d%H%M%S')
95
+ post[:RRN] = 'AMRCNT' + six_random_digits
96
+ end
97
+
98
+ def add_reference(post, authorization)
99
+ dateandtime, _batch, transaction, rrn, authcode, _, _, _ = split_authorization(authorization)
100
+ post[:DateAndTime] = dateandtime
101
+ post[:Transaction] = transaction
102
+ post[:RRN] = rrn
103
+ post[:AuthCode] = authcode
104
+ end
105
+
106
+ def parse(xml)
107
+ response = {}
108
+
109
+ doc = Nokogiri::XML(CGI.unescapeHTML(xml))
110
+ body = doc.xpath('//getAuthorizationReply')
111
+ body = doc.xpath('//cancelAuthorizationReply') if body.length == 0
112
+ body.children.each do |node|
113
+ if node.text?
114
+ next
115
+ elsif node.elements.size == 0
116
+ response[node.name.downcase.to_sym] = node.text
117
+ else
118
+ node.elements.each do |childnode|
119
+ name = "#{node.name.downcase}_#{childnode.name.downcase}"
120
+ response[name.to_sym] = childnode.text
121
+ end
122
+ end
123
+ end
124
+
125
+ response
126
+ end
127
+
128
+ def commit(action, post)
129
+ post[:Version] = '1000'
130
+ post[:Processor] = @options[:processor]
131
+ post[:MerchantID] = @options[:merchant_id]
132
+
133
+ request = build_request(action, post)
134
+ raw = ssl_post(url(action), request, headers)
135
+ pairs = parse(raw)
136
+ success = success_from(pairs)
137
+
138
+ Response.new(
139
+ success,
140
+ message_from(success, pairs),
141
+ pairs,
142
+ authorization: authorization_from(pairs),
143
+ test: test?
144
+ )
145
+ end
146
+
147
+ def success_from(response)
148
+ (response[:actioncode] == '000')
149
+ end
150
+
151
+ def message_from(succeeded, response)
152
+ if succeeded
153
+ 'Succeeded'
154
+ else
155
+ response[:message] || "Error with ActionCode=#{response[:actioncode]}"
156
+ end
157
+ end
158
+
159
+ def authorization_from(response)
160
+ [
161
+ response[:dateandtime],
162
+ response[:batch],
163
+ response[:transaction],
164
+ response[:rrn],
165
+ response[:authcode],
166
+ response[:transtype],
167
+ response[:tramount],
168
+ response[:trcurrency]
169
+ ].join('|')
170
+ end
171
+
172
+ def split_authorization(authorization)
173
+ dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency = authorization.split('|')
174
+ [dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency]
175
+ end
176
+
177
+ def headers
178
+ {
179
+ 'Authorization' => 'Basic ' + Base64.strict_encode64(@options[:username].to_s + ':' + @options[:password].to_s),
180
+ }
181
+ end
182
+
183
+ def build_request(action, post)
184
+ mode = action == 'void' ? 'cancel' : 'get'
185
+ xml = Builder::XmlMarkup.new :indent => 18
186
+ xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
187
+ xml.tag!("#{mode}Authorization") do
188
+ post.each do |field, value|
189
+ xml.tag!(field, value)
190
+ end
191
+ end
192
+ inner = CGI.escapeHTML(xml.target!)
193
+ envelope(mode).sub(/{{ :body }}/, inner)
194
+ end
195
+
196
+ def envelope(mode)
197
+ <<-EOS
198
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aut="http://Borgun/Heimir/pub/ws/Authorization">
199
+ <soapenv:Header/>
200
+ <soapenv:Body>
201
+ <aut:#{mode}AuthorizationInput>
202
+ <#{mode}AuthReqXml>
203
+ {{ :body }}
204
+ </#{mode}AuthReqXml>
205
+ </aut:#{mode}AuthorizationInput>
206
+ </soapenv:Body>
207
+ </soapenv:Envelope>
208
+ EOS
209
+ end
210
+
211
+ def url(action)
212
+ (test? ? test_url : live_url)
213
+ end
214
+
215
+ def six_random_digits
216
+ (0...6).map { rand(48..57).chr }.join
217
+ end
218
+ end
219
+ end
220
+ end
@@ -0,0 +1,277 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class BpointGateway < Gateway
6
+ self.live_url = 'https://www.bpoint.com.au/evolve/service_1_4_4.asmx'
7
+
8
+ self.supported_countries = ['AU']
9
+ self.default_currency = 'AUD'
10
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
11
+
12
+ self.homepage_url = 'https://www.bpoint.com.au/bpoint'
13
+ self.display_name = 'BPoint'
14
+
15
+ def initialize(options={})
16
+ requires!(options, :username, :password, :merchant_number)
17
+ super
18
+ end
19
+
20
+ def store(credit_card, options={})
21
+ options[:crn1] ||= 'DEFAULT'
22
+ request_body = soap_request do |xml|
23
+ add_token(xml, credit_card, options)
24
+ end
25
+ commit(request_body)
26
+ end
27
+
28
+ def purchase(amount, credit_card, options={})
29
+ request_body = soap_request do |xml|
30
+ process_payment(xml) do |payment_xml|
31
+ add_purchase(payment_xml, amount, credit_card, options)
32
+ end
33
+ end
34
+ commit(request_body)
35
+ end
36
+
37
+ def authorize(amount, credit_card, options={})
38
+ request_body = soap_request do |xml|
39
+ process_payment(xml) do |payment_xml|
40
+ add_authorize(payment_xml, amount, credit_card, options)
41
+ end
42
+ end
43
+ commit(request_body)
44
+ end
45
+
46
+ def capture(amount, authorization, options={})
47
+ request_body = soap_request do |xml|
48
+ process_payment(xml) do |payment_xml|
49
+ add_capture(payment_xml, amount, authorization, options)
50
+ end
51
+ end
52
+ commit(request_body)
53
+ end
54
+
55
+ def refund(amount, authorization, options={})
56
+ request_body = soap_request do |xml|
57
+ process_payment(xml) do |payment_xml|
58
+ add_refund(payment_xml, amount, authorization, options)
59
+ end
60
+ end
61
+ commit(request_body)
62
+ end
63
+
64
+ def void(amount, authorization, options={})
65
+ request_body = soap_request do |xml|
66
+ process_payment(xml) do |payment_xml|
67
+ add_void(payment_xml, amount, authorization, options)
68
+ end
69
+ end
70
+ commit(request_body)
71
+ end
72
+
73
+ def verify(credit_card, options={})
74
+ MultiResponse.run(:use_first_response) do |r|
75
+ r.process { authorize(100, credit_card, options) }
76
+ r.process(:ignore_result) { void(100, r.authorization, options) }
77
+ end
78
+ end
79
+
80
+ def supports_scrubbing?
81
+ true
82
+ end
83
+
84
+ def scrub(transcript)
85
+ transcript.
86
+ gsub(%r((<password>).+(</password>)), '\1[FILTERED]\2').
87
+ gsub(%r((<CardNumber>).+(</CardNumber>)), '\1[FILTERED]\2').
88
+ gsub(%r((<CVC>).+(</CVC>)), '\1[FILTERED]\2')
89
+ end
90
+
91
+ private
92
+
93
+ def soap_request
94
+ Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
95
+ xml.send('soap12:Envelope', soap_envelope_attributes) {
96
+ xml.send('soap12:Body') {
97
+ yield(xml) if block_given?
98
+ }
99
+ }
100
+ end.to_xml
101
+ end
102
+
103
+ def soap_envelope_attributes
104
+ { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
105
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
106
+ 'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope' }
107
+ end
108
+
109
+ def process_payment(xml)
110
+ xml.send('ProcessPayment', { 'xmlns' => 'urn:Eve_1_4_4' }) {
111
+ credentials_xml(xml)
112
+ xml.send('txnReq') {
113
+ yield(xml) if block_given?
114
+ }
115
+ }
116
+ end
117
+
118
+ def add_token(xml, credit_card, options)
119
+ xml.send('AddToken', { 'xmlns' => 'urn:Eve_1_4_4' }) {
120
+ credentials_xml(xml)
121
+ xml.send('tokenRequest') {
122
+ xml.send('CRN1', options[:crn1])
123
+ xml.send('CRN2', '')
124
+ xml.send('CRN3', '')
125
+ xml.send('CardNumber', credit_card.number)
126
+ xml.send('ExpiryDate', expdate(credit_card))
127
+ }
128
+ }
129
+ end
130
+
131
+ def credentials_xml(xml)
132
+ xml.send('username', @options[:username])
133
+ xml.send('password', @options[:password])
134
+ xml.send('merchantNumber', @options[:merchant_number])
135
+ end
136
+
137
+ def add_purchase(xml, amount, credit_card, options)
138
+ payment_xml(xml, 'PAYMENT', amount, options)
139
+ credit_card_xml(xml, credit_card)
140
+ end
141
+
142
+ def add_authorize(xml, amount, credit_card, options)
143
+ payment_xml(xml, 'PREAUTH', amount, options)
144
+ credit_card_xml(xml, credit_card)
145
+ end
146
+
147
+ def add_capture(xml, amount, transaction_number, options)
148
+ payment_xml(xml, 'CAPTURE', amount, options)
149
+ transaction_number_xml(xml, transaction_number)
150
+ end
151
+
152
+ def add_refund(xml, amount, transaction_number, options)
153
+ payment_xml(xml, 'REFUND', amount, options)
154
+ transaction_number_xml(xml, transaction_number)
155
+ end
156
+
157
+ def add_void(xml, amount, transaction_number, options)
158
+ payment_xml(xml, 'REVERSAL', amount, options)
159
+ transaction_number_xml(xml, transaction_number)
160
+ end
161
+
162
+ def payment_xml(xml, payment_type, amount, options)
163
+ xml.send('PaymentType', payment_type)
164
+ xml.send('TxnType', 'WEB_SHOP')
165
+ xml.send('BillerCode', options.fetch(:biller_code, ''))
166
+ xml.send('MerchantReference', options[:order_id]) if options[:order_id]
167
+ xml.send('CRN1', options[:crn1]) if options[:crn1]
168
+ xml.send('CRN2', options[:crn2]) if options[:crn2]
169
+ xml.send('CRN3', options[:crn3]) if options[:crn3]
170
+ xml.send('Amount', amount)
171
+ end
172
+
173
+ def credit_card_xml(xml, credit_card)
174
+ xml.send('CardNumber', credit_card.number)
175
+ xml.send('ExpiryDate', expdate(credit_card))
176
+ xml.send('CVC', credit_card.verification_value)
177
+ end
178
+
179
+ def transaction_number_xml(xml, transaction_number)
180
+ xml.send('OriginalTransactionNumber', transaction_number)
181
+ end
182
+
183
+ def commit(request_body)
184
+ parse(ssl_post(live_url, request_body, request_headers))
185
+ end
186
+
187
+ def request_headers
188
+ { 'Content-Type' => 'application/soap+xml; charset=utf-8' }
189
+ end
190
+
191
+ def parse(body)
192
+ response_for(Nokogiri::XML(body).remove_namespaces!)
193
+ end
194
+
195
+ def response_for(xml_doc)
196
+ if xml_doc.xpath('//ProcessPaymentResponse').any?
197
+ ProcessPaymentResponse.new(xml_doc, self).to_response
198
+ elsif xml_doc.xpath('//AddTokenResponse').any?
199
+ AddTokenResponse.new(xml_doc, self).to_response
200
+ end
201
+ end
202
+
203
+ class BPointResponse
204
+ attr_reader :xml_doc, :gateway, :params
205
+
206
+ def initialize(xml_doc, gateway)
207
+ @xml_doc = xml_doc
208
+ @gateway = gateway
209
+ @params = init_params
210
+ end
211
+
212
+ def to_response
213
+ Response.new(success?, message, params, options)
214
+ end
215
+
216
+ private
217
+
218
+ def init_params
219
+ {}.tap do |h|
220
+ xml_doc.xpath(response_node).each do |node|
221
+ if node.elements.empty?
222
+ h[node.name.to_sym] = node.text
223
+ else
224
+ node.elements.each do |childnode|
225
+ name = "#{node.name}_#{childnode.name}"
226
+ h[name.to_sym] = childnode.text
227
+ end
228
+ end
229
+ end
230
+ end
231
+ end
232
+
233
+ def response_node
234
+ "//#{self.class.name.split('::').last}/*"
235
+ end
236
+
237
+ def options
238
+ { authorization: params[authorization_key], test: gateway.test? }
239
+ end
240
+ end
241
+
242
+ class ProcessPaymentResponse < BPointResponse
243
+
244
+ private
245
+
246
+ def authorization_key
247
+ :ProcessPaymentResult_TransactionNumber
248
+ end
249
+
250
+ def success?
251
+ params[:ProcessPaymentResult_ResponseCode] == '0'
252
+ end
253
+
254
+ def message
255
+ params[:ProcessPaymentResult_AuthorisationResult] || params[:response_ResponseMessage]
256
+ end
257
+ end
258
+
259
+ class AddTokenResponse < BPointResponse
260
+
261
+ private
262
+
263
+ def authorization_key
264
+ :AddTokenResult_Token
265
+ end
266
+
267
+ def success?
268
+ params[:response_ResponseCode] == 'SUCCESS'
269
+ end
270
+
271
+ def message
272
+ params[:response_ResponseCode].capitalize
273
+ end
274
+ end
275
+ end
276
+ end
277
+ end