activemerchant-nsp 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/CHANGELOG +952 -0
  2. data/CONTRIBUTORS +347 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +204 -0
  5. data/gem-public_cert.pem +20 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +9 -0
  8. data/lib/active_merchant/billing/avs_result.rb +98 -0
  9. data/lib/active_merchant/billing/base.rb +56 -0
  10. data/lib/active_merchant/billing/check.rb +68 -0
  11. data/lib/active_merchant/billing/credit_card.rb +274 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +143 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  15. data/lib/active_merchant/billing/expiry_date.rb +34 -0
  16. data/lib/active_merchant/billing/gateway.rb +176 -0
  17. data/lib/active_merchant/billing/gateways.rb +18 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +695 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +943 -0
  20. data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
  21. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
  22. data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
  23. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
  24. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  25. data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -0
  26. data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
  27. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  28. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +389 -0
  30. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  31. data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
  32. data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
  33. data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
  34. data/lib/active_merchant/billing/gateways/cyber_source.rb +576 -0
  35. data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
  36. data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
  37. data/lib/active_merchant/billing/gateways/elavon.rb +137 -0
  38. data/lib/active_merchant/billing/gateways/epay.rb +276 -0
  39. data/lib/active_merchant/billing/gateways/eway.rb +287 -0
  40. data/lib/active_merchant/billing/gateways/eway_managed.rb +265 -0
  41. data/lib/active_merchant/billing/gateways/exact.rb +227 -0
  42. data/lib/active_merchant/billing/gateways/fat_zebra.rb +152 -0
  43. data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
  44. data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
  45. data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
  46. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +252 -0
  47. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
  48. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
  49. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
  50. data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
  51. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  52. data/lib/active_merchant/billing/gateways/iridium.rb +257 -0
  53. data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
  54. data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
  55. data/lib/active_merchant/billing/gateways/linkpoint.rb +451 -0
  56. data/lib/active_merchant/billing/gateways/litle.rb +290 -0
  57. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +157 -0
  58. data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
  59. data/lib/active_merchant/billing/gateways/metrics_global.rb +323 -0
  60. data/lib/active_merchant/billing/gateways/migs.rb +263 -0
  61. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  62. data/lib/active_merchant/billing/gateways/modern_payments.rb +38 -0
  63. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
  64. data/lib/active_merchant/billing/gateways/moneris.rb +250 -0
  65. data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
  66. data/lib/active_merchant/billing/gateways/nab_transact.rb +257 -0
  67. data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
  68. data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
  69. data/lib/active_merchant/billing/gateways/netbilling.rb +196 -0
  70. data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
  71. data/lib/active_merchant/billing/gateways/ogone.rb +427 -0
  72. data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
  73. data/lib/active_merchant/billing/gateways/orbital.rb +351 -0
  74. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
  75. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +266 -0
  76. data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -0
  77. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  78. data/lib/active_merchant/billing/gateways/paybox_direct.rb +201 -0
  79. data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
  80. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +212 -0
  81. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  82. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  83. data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
  84. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  85. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  86. data/lib/active_merchant/billing/gateways/payment_express.rb +282 -0
  87. data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
  88. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +653 -0
  89. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
  90. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
  91. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  92. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
  93. data/lib/active_merchant/billing/gateways/paypal_express.rb +178 -0
  94. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  95. data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
  96. data/lib/active_merchant/billing/gateways/payway.rb +214 -0
  97. data/lib/active_merchant/billing/gateways/plugnpay.rb +295 -0
  98. data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
  99. data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
  100. data/lib/active_merchant/billing/gateways/qbms.rb +297 -0
  101. data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
  102. data/lib/active_merchant/billing/gateways/quickpay.rb +298 -0
  103. data/lib/active_merchant/billing/gateways/realex.rb +313 -0
  104. data/lib/active_merchant/billing/gateways/sage.rb +148 -0
  105. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  106. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
  107. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  108. data/lib/active_merchant/billing/gateways/sage_pay.rb +322 -0
  109. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  110. data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
  111. data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
  112. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  113. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +284 -0
  114. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  115. data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
  116. data/lib/active_merchant/billing/gateways/smart_ps.rb +273 -0
  117. data/lib/active_merchant/billing/gateways/stripe.rb +236 -0
  118. data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
  119. data/lib/active_merchant/billing/gateways/transax.rb +23 -0
  120. data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
  121. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  122. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1497 -0
  123. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
  124. data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
  125. data/lib/active_merchant/billing/gateways/viaklix.rb +194 -0
  126. data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
  127. data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
  128. data/lib/active_merchant/billing/gateways/worldpay.rb +271 -0
  129. data/lib/active_merchant/billing/integrations.rb +17 -0
  130. data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
  131. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
  132. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
  133. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
  134. data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
  135. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  136. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  137. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  138. data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
  139. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
  140. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
  141. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  142. data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
  143. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
  144. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
  145. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
  146. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
  147. data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
  148. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
  149. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
  150. data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
  151. data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
  152. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
  153. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
  154. data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
  155. data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
  156. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
  157. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
  158. data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
  159. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
  160. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
  161. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
  162. data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
  163. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
  164. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +40 -0
  165. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +51 -0
  166. data/lib/active_merchant/billing/integrations/epay.rb +21 -0
  167. data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
  168. data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
  169. data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
  170. data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
  171. data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
  172. data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
  173. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  174. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  175. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
  176. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  177. data/lib/active_merchant/billing/integrations/helper.rb +117 -0
  178. data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
  179. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  180. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  181. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  182. data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
  183. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
  184. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
  185. data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
  186. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
  187. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
  188. data/lib/active_merchant/billing/integrations/nelnet.rb +40 -0
  189. data/lib/active_merchant/billing/integrations/nelnet/helper.rb +34 -0
  190. data/lib/active_merchant/billing/integrations/nelnet/notification.rb +100 -0
  191. data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
  192. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  193. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  194. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  195. data/lib/active_merchant/billing/integrations/notification.rb +62 -0
  196. data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
  197. data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
  198. data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
  199. data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
  200. data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
  201. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
  202. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
  203. data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
  204. data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
  205. data/lib/active_merchant/billing/integrations/paypal/notification.rb +155 -0
  206. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  207. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
  208. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
  209. data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
  210. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
  211. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
  212. data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
  213. data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
  214. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +71 -0
  215. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  216. data/lib/active_merchant/billing/integrations/return.rb +42 -0
  217. data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
  218. data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
  219. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
  220. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
  221. data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
  222. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
  223. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
  224. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +129 -0
  225. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
  226. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
  227. data/lib/active_merchant/billing/integrations/two_checkout.rb +44 -0
  228. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
  229. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
  230. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  231. data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
  232. data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
  233. data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
  234. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
  235. data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
  236. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
  237. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
  238. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
  239. data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
  240. data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
  241. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
  242. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
  243. data/lib/active_merchant/billing/integrations/world_pay.rb +27 -0
  244. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
  245. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
  246. data/lib/active_merchant/billing/response.rb +64 -0
  247. data/lib/active_merchant/version.rb +3 -0
  248. data/lib/activemerchant.rb +1 -0
  249. data/lib/support/gateway_support.rb +65 -0
  250. data/lib/support/outbound_hosts.rb +25 -0
  251. data/lib/support/ssl_verify.rb +93 -0
  252. metadata +482 -0
@@ -0,0 +1,351 @@
1
+ require File.dirname(__FILE__) + '/orbital/orbital_soft_descriptors.rb'
2
+ require "rexml/document"
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ # For more information on Orbital, visit the {integration center}[http://download.chasepaymentech.com]
7
+ #
8
+ # ==== Authentication Options
9
+ #
10
+ # The Orbital Gateway supports two methods of authenticating incoming requests:
11
+ # Source IP authentication and Connection Username/Password authentication
12
+ #
13
+ # In addition, these IP addresses/Connection Usernames must be affiliated with the Merchant IDs
14
+ # for which the client should be submitting transactions.
15
+ #
16
+ # This does allow Third Party Hosting service organizations presenting on behalf of other
17
+ # merchants to submit transactions. However, each time a new customer is added, the
18
+ # merchant or Third-Party hosting organization needs to ensure that the new Merchant IDs
19
+ # or Chain IDs are affiliated with the hosting companies IPs or Connection Usernames.
20
+ #
21
+ # If the merchant expects to have more than one merchant account with the Orbital
22
+ # Gateway, it should have its IP addresses/Connection Usernames affiliated at the Chain
23
+ # level hierarchy within the Orbital Gateway. Each time a new merchant ID is added, as
24
+ # long as it is placed within the same Chain, it will simply work. Otherwise, the additional
25
+ # MIDs will need to be affiliated with the merchant IPs or Connection Usernames respectively.
26
+ # For example, we generally affiliate all Salem accounts [BIN 000001] with
27
+ # their Company Number [formerly called MA #] number so all MIDs or Divisions under that
28
+ # Company will automatically be affiliated.
29
+
30
+ class OrbitalGateway < Gateway
31
+ API_VERSION = "4.6"
32
+
33
+ POST_HEADERS = {
34
+ "MIME-Version" => "1.0",
35
+ "Content-Type" => "Application/PTI46",
36
+ "Content-transfer-encoding" => "text",
37
+ "Request-number" => '1',
38
+ "Document-type" => "Request",
39
+ "Interface-Version" => "Ruby|ActiveMerchant|Proprietary Gateway"
40
+ }
41
+
42
+ SUCCESS, APPROVED = '0', '00'
43
+
44
+ class_attribute :secondary_test_url, :secondary_live_url
45
+
46
+ self.test_url = "https://orbitalvar1.paymentech.net/authorize"
47
+ self.secondary_test_url = "https://orbitalvar2.paymentech.net/authorize"
48
+
49
+ self.live_url = "https://orbital1.paymentech.net/authorize"
50
+ self.secondary_live_url = "https://orbital2.paymentech.net/authorize"
51
+
52
+ self.supported_countries = ["US", "CA"]
53
+ self.default_currency = "CAD"
54
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
55
+
56
+ self.display_name = 'Orbital Paymentech'
57
+ self.homepage_url = 'http://chasepaymentech.com/'
58
+
59
+ self.money_format = :cents
60
+
61
+ CURRENCY_CODES = {
62
+ "AUD" => '036',
63
+ "CAD" => '124',
64
+ "CZK" => '203',
65
+ "DKK" => '208',
66
+ "HKD" => '344',
67
+ "ICK" => '352',
68
+ "JPY" => '392',
69
+ "MXN" => '484',
70
+ "NZD" => '554',
71
+ "NOK" => '578',
72
+ "SGD" => '702',
73
+ "SEK" => '752',
74
+ "CHF" => '756',
75
+ "GBP" => '826',
76
+ "USD" => '840',
77
+ "EUR" => '978'
78
+ }
79
+
80
+ AVS_SUPPORTED_COUNTRIES = ['US', 'CA', 'UK', 'GB']
81
+
82
+ def initialize(options = {})
83
+ requires!(options, :merchant_id)
84
+ requires!(options, :login, :password) unless options[:ip_authentication]
85
+ @options = options
86
+ super
87
+ end
88
+
89
+ # A – Authorization request
90
+ def authorize(money, creditcard, options = {})
91
+ order = build_new_order_xml('A', money, options) do |xml|
92
+ add_creditcard(xml, creditcard, options[:currency])
93
+ add_address(xml, creditcard, options)
94
+ end
95
+ commit(order)
96
+ end
97
+
98
+ # AC – Authorization and Capture
99
+ def purchase(money, creditcard, options = {})
100
+ order = build_new_order_xml('AC', money, options) do |xml|
101
+ add_creditcard(xml, creditcard, options[:currency])
102
+ add_address(xml, creditcard, options)
103
+ end
104
+ commit(order)
105
+ end
106
+
107
+ # MFC - Mark For Capture
108
+ def capture(money, authorization, options = {})
109
+ commit(build_mark_for_capture_xml(money, authorization, options))
110
+ end
111
+
112
+ # R – Refund request
113
+ def refund(money, authorization, options = {})
114
+ order = build_new_order_xml('R', money, options.merge(:authorization => authorization)) do |xml|
115
+ add_refund(xml, options[:currency])
116
+ end
117
+ commit(order)
118
+ end
119
+
120
+ def credit(money, authorization, options= {})
121
+ deprecated CREDIT_DEPRECATION_MESSAGE
122
+ refund(money, authorization, options)
123
+ end
124
+
125
+ # setting money to nil will perform a full void
126
+ def void(authorization, options = {})
127
+ order = build_void_request_xml(authorization, options)
128
+ commit(order)
129
+ end
130
+
131
+ private
132
+
133
+ def add_customer_data(xml, options)
134
+ if options[:customer_ref_num]
135
+ xml.tag! :CustomerProfileFromOrderInd, 'S'
136
+ xml.tag! :CustomerRefNum, options[:customer_ref_num]
137
+ else
138
+ xml.tag! :CustomerProfileFromOrderInd, 'A'
139
+ end
140
+ end
141
+
142
+ def add_soft_descriptors(xml, soft_desc)
143
+ xml.tag! :SDMerchantName, soft_desc.merchant_name
144
+ xml.tag! :SDProductDescription, soft_desc.product_description
145
+ xml.tag! :SDMerchantCity, soft_desc.merchant_city
146
+ xml.tag! :SDMerchantPhone, soft_desc.merchant_phone
147
+ xml.tag! :SDMerchantURL, soft_desc.merchant_url
148
+ xml.tag! :SDMerchantEmail, soft_desc.merchant_email
149
+ end
150
+
151
+ def add_address(xml, creditcard, options)
152
+ if address = options[:billing_address] || options[:address]
153
+ avs_supported = AVS_SUPPORTED_COUNTRIES.include?(address[:country].to_s)
154
+
155
+ if avs_supported
156
+ xml.tag! :AVSzip, address[:zip]
157
+ xml.tag! :AVSaddress1, address[:address1]
158
+ xml.tag! :AVSaddress2, address[:address2]
159
+ xml.tag! :AVScity, address[:city]
160
+ xml.tag! :AVSstate, address[:state]
161
+ xml.tag! :AVSphoneNum, address[:phone] ? address[:phone].scan(/\d/).join.to_s : nil
162
+ end
163
+ xml.tag! :AVSname, creditcard.name
164
+ xml.tag! :AVScountryCode, avs_supported ? address[:country] : ''
165
+ end
166
+ end
167
+
168
+ def add_creditcard(xml, creditcard, currency=nil)
169
+ xml.tag! :AccountNum, creditcard.number
170
+ xml.tag! :Exp, expiry_date(creditcard)
171
+
172
+ xml.tag! :CurrencyCode, currency_code(currency)
173
+ xml.tag! :CurrencyExponent, '2' # Will need updating to support currencies such as the Yen.
174
+
175
+ xml.tag! :CardSecValInd, 1 if creditcard.verification_value? && %w( visa discover ).include?(creditcard.brand)
176
+ xml.tag! :CardSecVal, creditcard.verification_value if creditcard.verification_value?
177
+ end
178
+
179
+ def add_refund(xml, currency=nil)
180
+ xml.tag! :AccountNum, nil
181
+
182
+ xml.tag! :CurrencyCode, currency_code(currency)
183
+ xml.tag! :CurrencyExponent, '2' # Will need updating to support currencies such as the Yen.
184
+ end
185
+
186
+
187
+ def parse(body)
188
+ response = {}
189
+ xml = REXML::Document.new(body)
190
+ root = REXML::XPath.first(xml, "//Response") ||
191
+ REXML::XPath.first(xml, "//ErrorResponse")
192
+ if root
193
+ root.elements.to_a.each do |node|
194
+ recurring_parse_element(response, node)
195
+ end
196
+ end
197
+ response
198
+ end
199
+
200
+ def recurring_parse_element(response, node)
201
+ if node.has_elements?
202
+ node.elements.each{|e| recurring_parse_element(response, e) }
203
+ else
204
+ response[node.name.underscore.to_sym] = node.text
205
+ end
206
+ end
207
+
208
+ def commit(order)
209
+ headers = POST_HEADERS.merge("Content-length" => order.size.to_s)
210
+ request = lambda {return parse(ssl_post(remote_url, order, headers))}
211
+
212
+ # Failover URL will be used in the event of a connection error
213
+ begin response = request.call; rescue ConnectionError; retry end
214
+
215
+ Response.new(success?(response), message_from(response), response,
216
+ {:authorization => "#{response[:tx_ref_num]};#{response[:order_id]}",
217
+ :test => self.test?,
218
+ :avs_result => {:code => response[:avs_resp_code]},
219
+ :cvv_result => response[:cvv2_resp_code]
220
+ }
221
+ )
222
+ end
223
+
224
+ def remote_url
225
+ unless $!.class == ActiveMerchant::ConnectionError
226
+ self.test? ? self.test_url : self.live_url
227
+ else
228
+ self.test? ? self.secondary_test_url : self.secondary_live_url
229
+ end
230
+ end
231
+
232
+ def success?(response)
233
+ if response[:message_type].nil? || response[:message_type] == "R"
234
+ response[:proc_status] == SUCCESS
235
+ else
236
+ response[:proc_status] == SUCCESS &&
237
+ response[:resp_code] == APPROVED
238
+ end
239
+ end
240
+
241
+ def message_from(response)
242
+ success?(response) ? 'APPROVED' : response[:resp_msg] || response[:status_msg]
243
+ end
244
+
245
+ def ip_authentication?
246
+ @options[:ip_authentication] == true
247
+ end
248
+
249
+ def build_new_order_xml(action, money, parameters = {})
250
+ requires!(parameters, :order_id)
251
+ xml = xml_envelope
252
+ xml.tag! :Request do
253
+ xml.tag! :NewOrder do
254
+ add_xml_credentials(xml)
255
+ xml.tag! :IndustryType, parameters[:industry_type] || "EC"
256
+ xml.tag! :MessageType, action
257
+ add_bin_merchant_and_terminal(xml, parameters)
258
+
259
+ yield xml if block_given?
260
+
261
+ xml.tag! :Comments, parameters[:comments] if parameters[:comments]
262
+ xml.tag! :OrderID, format_order_id(parameters[:order_id])
263
+ xml.tag! :Amount, amount(money)
264
+
265
+ # Append Transaction Reference Number at the end for Refund transactions
266
+ if action == "R"
267
+ tx_ref_num, _ = parameters[:authorization].split(';')
268
+ xml.tag! :TxRefNum, tx_ref_num
269
+ end
270
+ end
271
+ end
272
+ xml.target!
273
+ end
274
+
275
+ def build_mark_for_capture_xml(money, authorization, parameters = {})
276
+ tx_ref_num, order_id = authorization.split(';')
277
+ xml = xml_envelope
278
+ xml.tag! :Request do
279
+ xml.tag! :MarkForCapture do
280
+ add_xml_credentials(xml)
281
+ xml.tag! :OrderID, order_id
282
+ xml.tag! :Amount, amount(money)
283
+ add_bin_merchant_and_terminal(xml, parameters)
284
+ xml.tag! :TxRefNum, tx_ref_num
285
+ end
286
+ end
287
+ xml.target!
288
+ end
289
+
290
+ def build_void_request_xml(authorization, parameters = {})
291
+ tx_ref_num, order_id = authorization.split(';')
292
+ xml = xml_envelope
293
+ xml.tag! :Request do
294
+ xml.tag! :Reversal do
295
+ add_xml_credentials(xml)
296
+ xml.tag! :TxRefNum, tx_ref_num
297
+ xml.tag! :TxRefIdx, parameters[:transaction_index]
298
+ xml.tag! :OrderID, order_id
299
+ add_bin_merchant_and_terminal(xml, parameters)
300
+ end
301
+ end
302
+ xml.target!
303
+ end
304
+
305
+ def currency_code(currency)
306
+ CURRENCY_CODES[(currency || self.default_currency)].to_s
307
+ end
308
+
309
+ def expiry_date(credit_card)
310
+ "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
311
+ end
312
+
313
+ def bin
314
+ @options[:bin] || (salem_mid? ? '000001' : '000002')
315
+ end
316
+
317
+ def xml_envelope
318
+ xml = Builder::XmlMarkup.new(:indent => 2)
319
+ xml.instruct!(:xml, :version => '1.0', :encoding => 'UTF-8')
320
+ xml
321
+ end
322
+
323
+ def add_xml_credentials(xml)
324
+ xml.tag! :OrbitalConnectionUsername, @options[:login] unless ip_authentication?
325
+ xml.tag! :OrbitalConnectionPassword, @options[:password] unless ip_authentication?
326
+ end
327
+
328
+ def add_bin_merchant_and_terminal(xml, parameters)
329
+ xml.tag! :BIN, bin
330
+ xml.tag! :MerchantID, @options[:merchant_id]
331
+ xml.tag! :TerminalID, parameters[:terminal_id] || '001'
332
+ end
333
+
334
+ def salem_mid?
335
+ @options[:merchant_id].length == 6
336
+ end
337
+
338
+ # The valid characters include:
339
+ #
340
+ # 1. all letters and digits
341
+ # 2. - , $ @ & and a space character, though the space character cannot be the leading character
342
+ # 3. PINless Debit transactions can only use uppercase and lowercase alpha (A-Z, a-z) and numeric (0-9)
343
+ def format_order_id(order_id)
344
+ illegal_characters = /[^,$@\- \w]/
345
+ order_id = order_id.to_s.gsub(/\./, '-')
346
+ order_id.gsub!(illegal_characters, '')
347
+ order_id[0...22]
348
+ end
349
+ end
350
+ end
351
+ end
@@ -0,0 +1,46 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class OrbitalSoftDescriptors
4
+ include Validateable
5
+
6
+ PHONE_FORMAT_1 = /\A\d{3}-\d{3}-\d{4}\z/
7
+ PHONE_FORMAT_2 = /\A\d{3}-\w{7}\z/
8
+
9
+ # ==== Tampa PNS Soft Descriptors
10
+ # The support for Soft Descriptors via the PNS Host is only for customers processing through Chase
11
+ # Paymentech Canada.
12
+
13
+ # Unlike Salem, the only value that gets passed on the cardholder statement is the Merchant Name field.
14
+ # And for these customers, it is a maximum of 25 bytes of data.
15
+ #
16
+ # All other Soft Descriptor fields can optionally be sent, but will not be submitted to the settlement host
17
+ # and will not display on the cardholder statement.
18
+
19
+ attr_accessor :merchant_name, :product_description, :merchant_city, :merchant_phone, :merchant_url, :merchant_email
20
+
21
+ def initialize(options = {})
22
+ self.merchant_name = options[:merchant_name]
23
+ self.merchant_city = options[:merchant_city]
24
+ self.merchant_phone = options[:merchant_phone]
25
+ self.merchant_url = options[:merchant_url]
26
+ self.merchant_email = options[:merchant_email]
27
+ end
28
+
29
+ def validate
30
+ errors.add(:merchant_name, "is required") if self.merchant_name.blank?
31
+ errors.add(:merchant_name, "is required to be 25 bytes or less") if self.merchant_name.bytesize > 25
32
+
33
+ unless self.merchant_phone.blank? || self.merchant_phone.match(PHONE_FORMAT_1) || self.merchant_phone.match(PHONE_FORMAT_2)
34
+ errors.add(:merchant_phone, "is required to follow \"NNN-NNN-NNNN\" or \"NNN-AAAAAAA\" format")
35
+ end
36
+
37
+ [:merchant_email, :merchant_url].each do |attr|
38
+ unless self.send(attr).blank?
39
+ errors.add(attr, "is required to be 13 bytes or less") if self.send(attr).bytesize > 13
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,266 @@
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ # This gateway accepts the following arguments:
6
+ # :login => your PayJunction username
7
+ # :password => your PayJunction pass
8
+ # Example use:
9
+ #
10
+ # gateway = ActiveMerchant::Billing::Base.gateway(:pay_gate_xml).new(
11
+ # :login => "my_account",
12
+ # :password => "my_pass"
13
+ # )
14
+ #
15
+ # # set up credit card obj as in main ActiveMerchant example
16
+ # creditcard = ActiveMerchant::Billing::CreditCard.new(
17
+ # :type => 'visa',
18
+ # :number => '4242424242424242',
19
+ # :month => 8,
20
+ # :year => 2009,
21
+ # :first_name => 'Bob',
22
+ # :last_name => 'Bobsen'
23
+ # )
24
+ #
25
+ # # run request
26
+ # response = gateway.purchase(1000, creditcard) # charge 10 dollars
27
+ #
28
+ # 1) Check whether the transaction was successful
29
+ #
30
+ # response.success?
31
+ #
32
+ # 2) Retrieve the message returned by PayJunction
33
+ #
34
+ # response.message
35
+ #
36
+ # 3) Retrieve the unique transaction ID returned by PayGateXML
37
+ #
38
+ # response.authorization
39
+ #
40
+ # This gateway has many other features which are not implemented here yet
41
+ # The basic setup here only supports auth/capture transactions.
42
+ #
43
+ # Test Transactions
44
+ #
45
+ # PayGateXML has a global test user/pass, but you can also sign up for your own.
46
+ # The class and the test come equipped with the global test creds
47
+ #
48
+ # Usage Details
49
+ #
50
+ # Below is a map of only SOME of the values accepted by PayGateXML and how you should submit
51
+ # each to ActiveMerchant
52
+ #
53
+ # PayGateXML Field ActiveMerchant Use
54
+ #
55
+ # pgid use :login value to gateway instantation
56
+ # pwd use :password value to gateway instantiation
57
+ #
58
+ # cname credit_card.name
59
+ # cc credit_card.number
60
+ # exp credit_card values formatted to YYYYMMDD
61
+ # budp South Africa only - set to 0 if purchase is not on budget
62
+ # amt include as argument to method for your transaction type
63
+ # ver do nothing, always set to current API version
64
+ #
65
+ # cref provide as :invoice in options, varchar(80)
66
+ # cur 3 char field, currently only ZAR
67
+ # cvv credit_card.verification
68
+ # bno batch processing number, i.e. you supply this
69
+ #
70
+ # others -- not used in this implementation
71
+ # nurl, rurl - must remain blank or absent or they will use an alternative authentication mechanism
72
+ # email, ip - must remain blank or absent or they will use a PayGate extra service call PayProtector
73
+ # threed - must remain blank unless you are using your own 3D Secure server
74
+ #
75
+ class PayGateXmlGateway < Gateway
76
+ self.live_url = 'https://www.paygate.co.za/payxml/process.trans'
77
+
78
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
79
+ self.supported_countries = ['US', 'ZA']
80
+
81
+ # The card types supported by the payment gateway
82
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
83
+
84
+ # The homepage URL of the gateway
85
+ self.homepage_url = 'http://paygate.co.za/'
86
+
87
+ # The name of the gateway
88
+ self.display_name = 'PayGate PayXML'
89
+
90
+ # PayGate only supports Rands
91
+ self.default_currency = 'ZAR'
92
+
93
+ # PayGate accepts only lowest denomination
94
+ self.money_format = :cents
95
+
96
+ # PayGateXML public test account - you can get a private one too
97
+ TEST_ID_3DSECURE = '10011013800'
98
+ TEST_ID = '10011021600'
99
+ TEST_PWD = 'test'
100
+
101
+ API_VERSION = '4.0'
102
+
103
+ DECLINE_CODES = {
104
+ # Credit Card Errors - These RESULT_CODEs are returned if the transaction cannot be authorized due to a problem with the card. The TRANSACTION_STATUS will be 2
105
+ 900001 => "Call for Approval",
106
+ 900002 => "Card Expired",
107
+ 900003 => "Insufficient Funds",
108
+ 900004 => "Invalid Card Number",
109
+ 900005 => "Bank Interface Timeout", # indicates a communications failure between the banks systems
110
+ 900006 => "Invalid Card",
111
+ 900007 => "Declined",
112
+ 900009 => "Lost Card",
113
+ 900010 => "Invalid Card Length",
114
+ 900011 => "Suspected Fraud",
115
+ 900012 => "Card Reported As Stolen",
116
+ 900013 => "Restricted Card",
117
+ 900014 => "Excessive Card Usage",
118
+ 900015 => "Card Blacklisted",
119
+
120
+ 900207 => "Declined; authentication failed", # indicates the cardholder did not enter their MasterCard SecureCode / Verified by Visa password correctly
121
+
122
+ 990020 => "Auth Declined",
123
+
124
+ 991001 => "Invalid expiry date",
125
+ 991002 => "Invalid amount",
126
+
127
+ # Communication Errors - These RESULT_CODEs are returned if the transaction cannot be completed due to an unexpected error. TRANSACTION_STATUS will be 0.
128
+ 900205 => "Unexpected authentication result (phase 1)",
129
+ 900206 => "Unexpected authentication result (phase 1)",
130
+
131
+ 990001 => "Could not insert into Database",
132
+
133
+ 990022 => "Bank not available",
134
+
135
+ 990053 => "Error processing transaction",
136
+
137
+ # Miscellaneous - Unless otherwise noted, the TRANSACTION_STATUS will be 0.
138
+ 900209 => "Transaction verification failed (phase 2)", # Indicates the verification data returned from MasterCard SecureCode / Verified by Visa has been altered
139
+ 900210 => "Authentication complete; transaction must be restarted", # Indicates that the MasterCard SecuerCode / Verified by Visa transaction has already been completed. Most likely caused by the customer clicking the refresh button
140
+
141
+ 990024 => "Duplicate Transaction Detected. Please check before submitting",
142
+
143
+ 990028 => "Transaction cancelled" # Customer clicks the 'Cancel' button on the payment page
144
+ }
145
+
146
+ SUCCESS_CODES = %w( 990004 990005 990017 990012 990018 990031 )
147
+
148
+ TRANSACTION_CODES = {
149
+ 0 => 'Not Done',
150
+ 1 => 'Approved',
151
+ 2 => 'Declined',
152
+ 3 => 'Paid',
153
+ 4 => 'Refunded',
154
+ 5 => 'Received by PayGate',
155
+ 6 => 'Replied to Client'
156
+ }
157
+
158
+ def initialize(options = {})
159
+ requires!(options, :login, :password)
160
+ @options = options
161
+ super
162
+ end
163
+
164
+ def purchase(money, creditcard, options = {})
165
+ MultiResponse.new.tap do |r|
166
+ r.process{authorize(money, creditcard, options)}
167
+ r.process{capture(money, r.authorization, options)}
168
+ end
169
+ end
170
+
171
+ def authorize(money, creditcard, options = {})
172
+ action = 'authtx'
173
+
174
+ options.merge!(:money => money, :creditcard => creditcard)
175
+ commit(action, build_request(action, options))
176
+ end
177
+
178
+ def capture(money, authorization, options = {})
179
+ action = 'settletx'
180
+
181
+ options.merge!(:money => money, :authorization => authorization)
182
+ commit(action, build_request(action, options))
183
+ end
184
+
185
+ def test?
186
+ @options[:test] || (Base.gateway_mode == :test)
187
+ end
188
+
189
+ private
190
+
191
+ def successful?(response)
192
+ SUCCESS_CODES.include?(response[:res])
193
+ end
194
+
195
+ def build_request(action, options={})
196
+ xml = Builder::XmlMarkup.new
197
+ xml.instruct!
198
+
199
+ xml.tag! 'protocol', :ver => API_VERSION, :pgid => (test? ? TEST_ID : @options[:login]), :pwd => @options[:password] do |protocol|
200
+ case action
201
+ when 'authtx'
202
+ money = options.delete(:money)
203
+ creditcard = options.delete(:creditcard)
204
+ build_authorization(protocol, money, creditcard, options)
205
+ when 'settletx'
206
+ money = options.delete(:money)
207
+ authorization = options.delete(:authorization)
208
+ build_capture(protocol, money, authorization, options)
209
+ else
210
+ raise "no action specified for build_request"
211
+ end
212
+ end
213
+
214
+ xml.target!
215
+ end
216
+
217
+ def build_authorization(xml, money, creditcard, options={})
218
+ xml.tag! 'authtx', {
219
+ :cref => options[:order_id],
220
+ :cname => creditcard.name,
221
+ :cc => creditcard.number,
222
+ :exp => "#{format(creditcard.month, :two_digits)}#{format(creditcard.year, :four_digits)}",
223
+ :budp => 0,
224
+ :amt => amount(money),
225
+ :cur => (options[:currency] || currency(money)),
226
+ :cvv => creditcard.verification_value
227
+ }
228
+ end
229
+
230
+ def build_capture(xml, money, authorization, options={})
231
+ xml.tag! 'settletx', {
232
+ :tid => authorization
233
+ }
234
+ end
235
+
236
+ def parse(action, body)
237
+ hash = {}
238
+ xml = REXML::Document.new(body)
239
+
240
+ response_action = action.gsub(/tx/, 'rx')
241
+ root = REXML::XPath.first(xml.root, response_action)
242
+ # we might have gotten an error
243
+ if root.nil?
244
+ root = REXML::XPath.first(xml.root, 'errorrx')
245
+ end
246
+ root.attributes.each do |name, value|
247
+ hash[name.to_sym] = value
248
+ end
249
+ hash
250
+ end
251
+
252
+ def commit(action, request)
253
+ response = parse(action, ssl_post(self.live_url, request))
254
+ Response.new(successful?(response), message_from(response), response,
255
+ :test => test?,
256
+ :authorization => response[:tid]
257
+ )
258
+ end
259
+
260
+ def message_from(response)
261
+ (response[:rdesc] || response[:edesc])
262
+ end
263
+ end
264
+ end
265
+ end
266
+