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,194 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class GlobalTransportGateway < Gateway
6
+ self.test_url = 'https://certapia.globalpay.com/GlobalPay/transact.asmx/ProcessCreditCard'
7
+ self.live_url = 'https://api.globalpay.com/GlobalPay/transact.asmx/ProcessCreditCard'
8
+
9
+ self.supported_countries = %w(CA PR US)
10
+ self.default_currency = 'USD'
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
12
+
13
+ self.homepage_url = 'https://www.globalpaymentsinc.com'
14
+ self.display_name = 'Global Transport'
15
+
16
+ # Public: Create a new Global Transport gateway.
17
+ #
18
+ # options - A hash of options:
19
+ # :global_user_name - Your Global user name
20
+ # :global_password - Your Global password
21
+ # :term_type - 3 character field assigned by Global Transport after
22
+ # - your application is certified.
23
+ def initialize(options={})
24
+ requires!(options, :global_user_name, :global_password, :term_type)
25
+ super
26
+ end
27
+
28
+ def purchase(money, payment_method, options={})
29
+ post = {}
30
+ add_invoice(post, money, options)
31
+ add_payment_method(post, payment_method)
32
+ add_address(post, options)
33
+
34
+ commit('Sale', post, options)
35
+ end
36
+
37
+ def authorize(money, payment_method, options={})
38
+ post = {}
39
+ add_invoice(post, money, options)
40
+ add_payment_method(post, payment_method)
41
+ add_address(post, options)
42
+
43
+ commit('Auth', post, options)
44
+ end
45
+
46
+ def capture(money, authorization, options={})
47
+ post = {}
48
+ add_invoice(post, money, options)
49
+ add_auth(post, authorization)
50
+
51
+ commit('Force', post, options)
52
+ end
53
+
54
+ def refund(money, authorization, options={})
55
+ post = {}
56
+ add_invoice(post, money, options)
57
+ add_auth(post, authorization)
58
+
59
+ commit('Return', post, options)
60
+ end
61
+
62
+ def void(authorization, options={})
63
+ post = {}
64
+ add_auth(post, authorization)
65
+
66
+ commit('Void', post, options)
67
+ end
68
+
69
+ def verify(payment_method, options={})
70
+ post = {}
71
+ add_payment_method(post, payment_method)
72
+ add_address(post, options)
73
+
74
+ commit('CardVerify', post, options)
75
+ end
76
+
77
+ def supports_scrubbing?
78
+ true
79
+ end
80
+
81
+ def scrub(transcript)
82
+ transcript.
83
+ gsub(%r((&?CardNum=)[^&]*)i, '\1[FILTERED]').
84
+ gsub(%r((&?CVNum=)[^&]*)i, '\1[FILTERED]').
85
+ gsub(%r((&?GlobalPassword=)[^&]*)i, '\1[FILTERED]')
86
+ end
87
+
88
+ private
89
+
90
+ def add_address(post, options)
91
+ if address = (options[:billing_address] || options[:address])
92
+ post[:Street] = address[:address1]
93
+ post[:Zip] = address[:zip]
94
+ end
95
+ end
96
+
97
+ def add_auth(post, authorization)
98
+ post[:PNRef] = authorization
99
+ end
100
+
101
+ def add_invoice(post, money, options)
102
+ currency = (options[:currency] || currency(money))
103
+
104
+ post[:Amount] = localized_amount(money, currency)
105
+ post[:InvNum] = truncate(options[:order_id], 16)
106
+ end
107
+
108
+ def add_payment_method(post, payment_method)
109
+ post[:CardNum] = payment_method.number
110
+ post[:ExpDate] = expdate(payment_method)
111
+ post[:NameOnCard] = payment_method.name
112
+ post[:CVNum] = payment_method.verification_value
113
+ end
114
+
115
+ def parse(body)
116
+ response = {}
117
+
118
+ Nokogiri::XML(body).root.xpath('*').each do |node|
119
+ response[node.name.downcase.to_sym] = node.text
120
+ end
121
+
122
+ ext_data = Nokogiri::HTML.parse(response[:extdata])
123
+ response[:approved_amount] = ext_data.xpath('//approvedamount').text
124
+ response[:balance_due] = ext_data.xpath('//balancedue').text
125
+
126
+ response
127
+ end
128
+
129
+ def commit(action, parameters, options)
130
+ raw = parse(ssl_post(url, post_data(action, parameters, options)))
131
+ Response.new(
132
+ success_from(raw),
133
+ message_from(raw),
134
+ raw,
135
+ authorization: authorization_from(raw),
136
+ test: test?,
137
+ avs_result: avs_from(raw),
138
+ cvv_result: cvv_from(raw)
139
+ )
140
+ end
141
+
142
+ def post_data(action, params, options)
143
+ post = default_params
144
+ post[:GlobalUserName] = @options[:global_user_name]
145
+ post[:GlobalPassword] = @options[:global_password]
146
+ post[:TransType] = action
147
+ post[:ExtData] = "<TermType>#{@options[:term_type]}</TermType>"
148
+
149
+ post.merge(params).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
150
+ end
151
+
152
+ def url
153
+ (test? ? test_url : live_url)
154
+ end
155
+
156
+ def success_from(response)
157
+ response[:result] == '0' || response[:result] == '200'
158
+ end
159
+
160
+ def message_from(response)
161
+ response[:respmsg]
162
+ end
163
+
164
+ def authorization_from(response)
165
+ response[:pnref]
166
+ end
167
+
168
+ def avs_from(response)
169
+ { code: response[:getavsresult] }
170
+ end
171
+
172
+ def cvv_from(response)
173
+ response[:getcvresult]
174
+ end
175
+
176
+ def default_params
177
+ {
178
+ CardNum: '',
179
+ ExpDate: '',
180
+ NameOnCard: '',
181
+ Amount: '',
182
+ PNRef: '',
183
+ Zip: '',
184
+ Street: '',
185
+ CVNum: '',
186
+ MagData: '',
187
+ InvNum: '',
188
+ ExtData: ''
189
+ }
190
+ end
191
+
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,206 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class HdfcGateway < Gateway
6
+ self.display_name = 'HDFC'
7
+ self.homepage_url = 'http://www.hdfcbank.com/sme/sme-details/merchant-services/guzh6m0i'
8
+
9
+ self.test_url = 'https://securepgtest.fssnet.co.in/pgway/servlet/'
10
+ self.live_url = 'https://securepg.fssnet.co.in/pgway/servlet/'
11
+
12
+ self.supported_countries = ['IN']
13
+ self.default_currency = 'INR'
14
+ self.money_format = :dollars
15
+ self.supported_cardtypes = [:visa, :master, :discover, :diners_club]
16
+
17
+ def initialize(options={})
18
+ requires!(options, :login, :password)
19
+ super
20
+ end
21
+
22
+ def purchase(amount, payment_method, options={})
23
+ post = {}
24
+ add_invoice(post, amount, options)
25
+ add_payment_method(post, payment_method)
26
+ add_customer_data(post, options)
27
+
28
+ commit('purchase', post)
29
+ end
30
+
31
+ def authorize(amount, payment_method, options={})
32
+ post = {}
33
+ add_invoice(post, amount, options)
34
+ add_payment_method(post, payment_method)
35
+ add_customer_data(post, options)
36
+
37
+ commit('authorize', post)
38
+ end
39
+
40
+ def capture(amount, authorization, options={})
41
+ post = {}
42
+ add_invoice(post, amount, options)
43
+ add_reference(post, authorization)
44
+ add_customer_data(post, options)
45
+
46
+ commit('capture', post)
47
+ end
48
+
49
+ def refund(amount, authorization, options={})
50
+ post = {}
51
+ add_invoice(post, amount, options)
52
+ add_reference(post, authorization)
53
+ add_customer_data(post, options)
54
+
55
+ commit('refund', post)
56
+ end
57
+
58
+ private
59
+
60
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
61
+ CURRENCY_CODES['AED'] = '784'
62
+ CURRENCY_CODES['AUD'] = '036'
63
+ CURRENCY_CODES['CAD'] = '124'
64
+ CURRENCY_CODES['EUR'] = '978'
65
+ CURRENCY_CODES['GBP'] = '826'
66
+ CURRENCY_CODES['INR'] = '356'
67
+ CURRENCY_CODES['OMR'] = '512'
68
+ CURRENCY_CODES['QAR'] = '634'
69
+ CURRENCY_CODES['SGD'] = '702'
70
+ CURRENCY_CODES['USD'] = '840'
71
+
72
+ def add_invoice(post, amount, options)
73
+ post[:amt] = amount(amount)
74
+ post[:currencycode] = CURRENCY_CODES[options[:currency] || currency(amount)]
75
+ post[:trackid] = escape(options[:order_id], 40) if options[:order_id]
76
+ post[:udf1] = escape(options[:description]) if options[:description]
77
+ post[:eci] = options[:eci] if options[:eci]
78
+ end
79
+
80
+ def add_customer_data(post, options)
81
+ post[:udf2] = escape(options[:email]) if options[:email]
82
+ if address = (options[:billing_address] || options[:address])
83
+ post[:udf3] = escape(address[:phone]) if address[:phone]
84
+ post[:udf4] = escape(<<EOA)
85
+ #{address[:name]}
86
+ #{address[:company]}
87
+ #{address[:address1]}
88
+ #{address[:address2]}
89
+ #{address[:city]} #{address[:state]} #{address[:zip]}
90
+ #{address[:country]}
91
+ EOA
92
+ end
93
+ end
94
+
95
+ def add_payment_method(post, payment_method)
96
+ post[:member] = escape(payment_method.name, 30)
97
+ post[:card] = escape(payment_method.number)
98
+ post[:cvv2] = escape(payment_method.verification_value)
99
+ post[:expyear] = format(payment_method.year, :four_digits)
100
+ post[:expmonth] = format(payment_method.month, :two_digits)
101
+ end
102
+
103
+ def add_reference(post, authorization)
104
+ tranid, member = split_authorization(authorization)
105
+ post[:transid] = tranid
106
+ post[:member] = member
107
+ end
108
+
109
+ def parse(xml)
110
+ response = {}
111
+
112
+ doc = Nokogiri::XML.fragment(fix_xml(xml))
113
+ doc.children.each do |node|
114
+ if node.text?
115
+ next
116
+ elsif node.elements.size == 0
117
+ response[node.name.downcase.to_sym] = node.text
118
+ else
119
+ node.elements.each do |childnode|
120
+ name = "#{node.name.downcase}_#{childnode.name.downcase}"
121
+ response[name.to_sym] = childnode.text
122
+ end
123
+ end
124
+ end
125
+
126
+ response
127
+ end
128
+
129
+ def fix_xml(xml)
130
+ xml.gsub(/&(?!(?:amp|quot|apos|lt|gt);)/, '&amp;')
131
+ end
132
+
133
+ ACTIONS = {
134
+ 'purchase' => '1',
135
+ 'refund' => '2',
136
+ 'authorize' => '4',
137
+ 'capture' => '5',
138
+ }
139
+
140
+ def commit(action, post)
141
+ post[:id] = @options[:login]
142
+ post[:password] = @options[:password]
143
+ post[:action] = ACTIONS[action] if ACTIONS[action]
144
+
145
+ raw = parse(ssl_post(url(action), build_request(post)))
146
+
147
+ succeeded = success_from(raw[:result])
148
+ Response.new(
149
+ succeeded,
150
+ message_from(succeeded, raw),
151
+ raw,
152
+ :authorization => authorization_from(post, raw),
153
+ :test => test?
154
+ )
155
+ end
156
+
157
+ def build_request(post)
158
+ xml = Builder::XmlMarkup.new :indent => 2
159
+ xml.instruct!
160
+ post.each do |field, value|
161
+ xml.tag!(field, value)
162
+ end
163
+ xml.target!
164
+ end
165
+
166
+ def url(action)
167
+ endpoint = 'TranPortalXMLServlet'
168
+ (test? ? test_url : live_url) + endpoint
169
+ end
170
+
171
+ def success_from(result)
172
+ case result
173
+ when 'CAPTURED', 'APPROVED', 'NOT ENROLLED', 'ENROLLED'
174
+ true
175
+ else
176
+ false
177
+ end
178
+ end
179
+
180
+ def message_from(succeeded, response)
181
+ if succeeded
182
+ 'Succeeded'
183
+ else
184
+ (response[:error_text] || response[:result] || 'Unable to read error message').split('-').last
185
+ end
186
+ end
187
+
188
+ def authorization_from(request, response)
189
+ [response[:tranid], request[:member]].join('|')
190
+ end
191
+
192
+ def split_authorization(authorization)
193
+ tranid, member = authorization.split('|')
194
+ [tranid, member]
195
+ end
196
+
197
+ def escape(string, max_length=250)
198
+ return '' unless string
199
+ if max_length
200
+ string = string[0...max_length]
201
+ end
202
+ string.gsub(/[^A-Za-z0-9 \-_@\.\n]/, '')
203
+ end
204
+ end
205
+ end
206
+ end
@@ -0,0 +1,350 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class HpsGateway < Gateway
6
+ self.live_url = 'https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl'
7
+ self.test_url = 'https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl'
8
+
9
+ self.supported_countries = ['US']
10
+ self.default_currency = 'USD'
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jbc, :diners_club]
12
+
13
+ self.homepage_url = 'http://developer.heartlandpaymentsystems.com/SecureSubmit/'
14
+ self.display_name = 'Heartland Payment Systems'
15
+
16
+ self.money_format = :dollars
17
+
18
+ PAYMENT_DATA_SOURCE_MAPPING = {
19
+ apple_pay: 'ApplePay',
20
+ master: 'MasterCard 3DSecure',
21
+ visa: 'Visa 3DSecure',
22
+ american_express: 'AMEX 3DSecure',
23
+ discover: 'Discover 3DSecure',
24
+ }
25
+
26
+ def initialize(options={})
27
+ requires!(options, :secret_api_key)
28
+ super
29
+ end
30
+
31
+ def authorize(money, card_or_token, options={})
32
+ commit('CreditAuth') do |xml|
33
+ add_amount(xml, money)
34
+ add_allow_dup(xml)
35
+ add_customer_data(xml, card_or_token, options)
36
+ add_details(xml, options)
37
+ add_descriptor_name(xml, options)
38
+ add_payment(xml, card_or_token, options)
39
+ add_three_d_secure(xml, card_or_token, options)
40
+ end
41
+ end
42
+
43
+ def capture(money, transaction_id, options={})
44
+ commit('CreditAddToBatch') do |xml|
45
+ add_amount(xml, money)
46
+ add_reference(xml, transaction_id)
47
+ end
48
+ end
49
+
50
+ def purchase(money, card_or_token, options={})
51
+ commit('CreditSale') do |xml|
52
+ add_amount(xml, money)
53
+ add_allow_dup(xml)
54
+ add_customer_data(xml, card_or_token, options)
55
+ add_details(xml, options)
56
+ add_descriptor_name(xml, options)
57
+ add_payment(xml, card_or_token, options)
58
+ add_three_d_secure(xml, card_or_token, options)
59
+ end
60
+ end
61
+
62
+ def refund(money, transaction_id, options={})
63
+ commit('CreditReturn') do |xml|
64
+ add_amount(xml, money)
65
+ add_allow_dup(xml)
66
+ add_reference(xml, transaction_id)
67
+ add_customer_data(xml, transaction_id, options)
68
+ add_details(xml, options)
69
+ end
70
+ end
71
+
72
+ def verify(card_or_token, options={})
73
+ commit('CreditAccountVerify') do |xml|
74
+ add_customer_data(xml, card_or_token, options)
75
+ add_descriptor_name(xml, options)
76
+ add_payment(xml, card_or_token, options)
77
+ end
78
+ end
79
+
80
+ def void(transaction_id, options={})
81
+ commit('CreditVoid') do |xml|
82
+ add_reference(xml, transaction_id)
83
+ end
84
+ end
85
+
86
+ def supports_scrubbing?
87
+ true
88
+ end
89
+
90
+ def scrub(transcript)
91
+ transcript.
92
+ gsub(%r((<hps:CardNbr>)[^<]*(<\/hps:CardNbr>))i, '\1[FILTERED]\2').
93
+ gsub(%r((<hps:CVV2>)[^<]*(<\/hps:CVV2>))i, '\1[FILTERED]\2').
94
+ gsub(%r((<hps:SecretAPIKey>)[^<]*(<\/hps:SecretAPIKey>))i, '\1[FILTERED]\2').
95
+ gsub(%r((<hps:PaymentData>)[^<]*(<\/hps:PaymentData>))i, '\1[FILTERED]\2')
96
+ end
97
+
98
+ private
99
+
100
+ def add_reference(xml, transaction_id)
101
+ xml.hps :GatewayTxnId, transaction_id
102
+ end
103
+
104
+ def add_amount(xml, money)
105
+ xml.hps :Amt, amount(money) if money
106
+ end
107
+
108
+ def add_customer_data(xml, credit_card, options)
109
+ xml.hps :CardHolderData do
110
+ if credit_card.respond_to?(:number)
111
+ xml.hps :CardHolderFirstName, credit_card.first_name if credit_card.first_name
112
+ xml.hps :CardHolderLastName, credit_card.last_name if credit_card.last_name
113
+ end
114
+
115
+ xml.hps :CardHolderEmail, options[:email] if options[:email]
116
+ xml.hps :CardHolderPhone, options[:phone] if options[:phone]
117
+
118
+ if(billing_address = (options[:billing_address] || options[:address]))
119
+ xml.hps :CardHolderAddr, billing_address[:address1] if billing_address[:address1]
120
+ xml.hps :CardHolderCity, billing_address[:city] if billing_address[:city]
121
+ xml.hps :CardHolderState, billing_address[:state] if billing_address[:state]
122
+ xml.hps :CardHolderZip, billing_address[:zip] if billing_address[:zip]
123
+ end
124
+ end
125
+ end
126
+
127
+ def add_payment(xml, card_or_token, options)
128
+ xml.hps :CardData do
129
+ if card_or_token.respond_to?(:number)
130
+ if card_or_token.track_data
131
+ xml.tag!('hps:TrackData', 'method'=>'swipe') do
132
+ xml.text! card_or_token.track_data
133
+ end
134
+ if options[:encryption_type]
135
+ xml.hps :EncryptionData do
136
+ xml.hps :Version, options[:encryption_type]
137
+ if options[:encryption_type] == '02'
138
+ xml.hps :EncryptedTrackNumber, options[:encrypted_track_number]
139
+ xml.hps :KTB, options[:ktb]
140
+ end
141
+ end
142
+ end
143
+ else
144
+ xml.hps :ManualEntry do
145
+ xml.hps :CardNbr, card_or_token.number
146
+ xml.hps :ExpMonth, card_or_token.month
147
+ xml.hps :ExpYear, card_or_token.year
148
+ xml.hps :CVV2, card_or_token.verification_value if card_or_token.verification_value
149
+ xml.hps :CardPresent, 'N'
150
+ xml.hps :ReaderPresent, 'N'
151
+ end
152
+ end
153
+ else
154
+ xml.hps :TokenData do
155
+ xml.hps :TokenValue, card_or_token
156
+ end
157
+ end
158
+ xml.hps :TokenRequest, (options[:store] ? 'Y' : 'N')
159
+ end
160
+ end
161
+
162
+ def add_details(xml, options)
163
+ xml.hps :AdditionalTxnFields do
164
+ xml.hps :Description, options[:description] if options[:description]
165
+ xml.hps :InvoiceNbr, options[:order_id] if options[:order_id]
166
+ xml.hps :CustomerID, options[:customer_id] if options[:customer_id]
167
+ end
168
+ end
169
+
170
+ def add_allow_dup(xml)
171
+ xml.hps :AllowDup, 'Y'
172
+ end
173
+
174
+ def add_descriptor_name(xml, options)
175
+ xml.hps :TxnDescriptor, options[:descriptor_name] if options[:descriptor_name]
176
+ end
177
+
178
+ def add_three_d_secure(xml, card_or_token, options)
179
+ if card_or_token.is_a?(NetworkTokenizationCreditCard)
180
+ build_three_d_secure(xml, {
181
+ source: card_or_token.source,
182
+ cavv: card_or_token.payment_cryptogram,
183
+ eci: card_or_token.eci,
184
+ xid: card_or_token.transaction_id,
185
+ })
186
+ elsif options[:three_d_secure]
187
+ options[:three_d_secure][:source] ||= card_brand(card_or_token)
188
+ build_three_d_secure(xml, options[:three_d_secure])
189
+ end
190
+ end
191
+
192
+ def build_three_d_secure(xml, three_d_secure)
193
+ # PaymentDataSource is required when supplying the SecureECommerce data group,
194
+ # and the gateway currently only allows the values within the mapping
195
+ return unless PAYMENT_DATA_SOURCE_MAPPING[three_d_secure[:source].to_sym]
196
+
197
+ xml.hps :SecureECommerce do
198
+ xml.hps :PaymentDataSource, PAYMENT_DATA_SOURCE_MAPPING[three_d_secure[:source].to_sym]
199
+ xml.hps :TypeOfPaymentData, '3DSecure' # Only type currently supported
200
+ xml.hps :PaymentData, three_d_secure[:cavv] if three_d_secure[:cavv]
201
+ # the gateway only allows a single character for the ECI
202
+ xml.hps :ECommerceIndicator, strip_leading_zero(three_d_secure[:eci]) if three_d_secure[:eci]
203
+ xml.hps :XID, three_d_secure[:xid] if three_d_secure[:xid]
204
+ end
205
+ end
206
+
207
+ def strip_leading_zero(value)
208
+ return value unless value[0] == '0'
209
+ value[1, 1]
210
+ end
211
+
212
+ def build_request(action)
213
+ xml = Builder::XmlMarkup.new(encoding: 'UTF-8')
214
+ xml.instruct!(:xml, encoding: 'UTF-8')
215
+ xml.SOAP :Envelope, {
216
+ 'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/',
217
+ 'xmlns:hps' => 'http://Hps.Exchange.PosGateway' } do
218
+ xml.SOAP :Body do
219
+ xml.hps :PosRequest do
220
+ xml.hps 'Ver1.0'.to_sym do
221
+ xml.hps :Header do
222
+ xml.hps :SecretAPIKey, @options[:secret_api_key]
223
+ xml.hps :DeveloperID, @options[:developer_id] if @options[:developer_id]
224
+ xml.hps :VersionNbr, @options[:version_number] if @options[:version_number]
225
+ xml.hps :SiteTrace, @options[:site_trace] if @options[:site_trace]
226
+ end
227
+ xml.hps :Transaction do
228
+ xml.hps action.to_sym do
229
+ if %w(CreditVoid CreditAddToBatch).include?(action)
230
+ yield(xml)
231
+ else
232
+ xml.hps :Block1 do
233
+ yield(xml)
234
+ end
235
+ end
236
+ end
237
+ end
238
+ end
239
+ end
240
+ end
241
+ end
242
+ xml.target!
243
+ end
244
+
245
+ def parse(raw)
246
+ response = {}
247
+
248
+ doc = Nokogiri::XML(raw)
249
+ doc.remove_namespaces!
250
+ if(header = doc.xpath('//Header').first)
251
+ header.elements.each do |node|
252
+ if node.elements.size == 0
253
+ response[node.name] = node.text
254
+ else
255
+ node.elements.each do |childnode|
256
+ response[childnode.name] = childnode.text
257
+ end
258
+ end
259
+ end
260
+ end
261
+ if(transaction = doc.xpath('//Transaction/*[1]').first)
262
+ transaction.elements.each do |node|
263
+ response[node.name] = node.text
264
+ end
265
+ end
266
+ if(fault = doc.xpath('//Fault/Reason/Text').first)
267
+ response['Fault'] = fault.text
268
+ end
269
+
270
+ response
271
+ end
272
+
273
+ def commit(action, &request)
274
+ data = build_request(action, &request)
275
+
276
+ response = begin
277
+ parse(ssl_post((test? ? test_url : live_url), data, 'Content-Type' => 'text/xml'))
278
+ rescue ResponseError => e
279
+ parse(e.response.body)
280
+ end
281
+
282
+ ActiveMerchant::Billing::Response.new(
283
+ successful?(response),
284
+ message_from(response),
285
+ response,
286
+ test: test?,
287
+ authorization: authorization_from(response),
288
+ avs_result: {
289
+ code: response['AVSRsltCode'],
290
+ message: response['AVSRsltText']
291
+ },
292
+ cvv_result: response['CVVRsltCode']
293
+ )
294
+ end
295
+
296
+ def successful?(response)
297
+ (
298
+ (response['GatewayRspCode'] == '0') &&
299
+ ((response['RspCode'] || '00') == '00' || response['RspCode'] == '85')
300
+ )
301
+ end
302
+
303
+ def message_from(response)
304
+ if(response['Fault'])
305
+ response['Fault']
306
+ elsif(response['GatewayRspCode'] == '0')
307
+ if(response['RspCode'] != '00' && response['RspCode'] != '85')
308
+ issuer_message(response['RspCode'])
309
+ else
310
+ response['GatewayRspMsg']
311
+ end
312
+ else
313
+ (GATEWAY_MESSAGES[response['GatewayRspCode']] || response['GatewayRspMsg'])
314
+ end
315
+ end
316
+
317
+ def authorization_from(response)
318
+ response['GatewayTxnId']
319
+ end
320
+
321
+ def test?
322
+ @options[:secret_api_key]&.include?('_cert_')
323
+ end
324
+
325
+ ISSUER_MESSAGES = {
326
+ '13' => 'Must be greater than or equal 0.',
327
+ '14' => 'The card number is incorrect.',
328
+ '54' => 'The card has expired.',
329
+ '55' => 'The 4-digit pin is invalid.',
330
+ '75' => 'Maximum number of pin retries exceeded.',
331
+ '80' => 'Card expiration date is invalid.',
332
+ '86' => "Can't verify card pin number."
333
+ }
334
+ def issuer_message(code)
335
+ return 'The card was declined.' if %w(02 03 04 05 41 43 44 51 56 61 62 63 65 78).include?(code)
336
+ return 'An error occurred while processing the card.' if %w(06 07 12 15 19 12 52 53 57 58 76 77 91 96 EC).include?(code)
337
+ return "The card's security code is incorrect." if %w(EB N7).include?(code)
338
+ ISSUER_MESSAGES[code]
339
+ end
340
+
341
+ GATEWAY_MESSAGES = {
342
+ '-2' => 'Authentication error. Please double check your service configuration.',
343
+ '12' => 'Invalid CPC data.',
344
+ '13' => 'Invalid card data.',
345
+ '14' => 'The card number is not a valid credit card number.',
346
+ '30' => 'Gateway timed out.'
347
+ }
348
+ end
349
+ end
350
+ end