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,19 @@
1
+ require File.dirname(__FILE__) + '/smart_ps.rb'
2
+ require File.dirname(__FILE__) + '/braintree/braintree_common'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ class BraintreeOrangeGateway < SmartPs
7
+ include BraintreeCommon
8
+
9
+ self.display_name = 'Braintree (Orange Platform)'
10
+
11
+ self.live_url = self.test_url = 'https://secure.braintreepaymentgateway.com/api/transact.php'
12
+
13
+ def add_processor(post, options)
14
+ post[:processor_id] = options[:processor] unless options[:processor].nil?
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,23 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CardSaveGateway < IridiumGateway
4
+ #CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down
5
+ #URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/']
6
+
7
+ self.money_format = :cents
8
+ self.default_currency = 'GBP'
9
+ self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :solo, :american_express, :jcb ]
10
+ self.supported_countries = [ 'GB' ]
11
+ self.homepage_url = 'http://www.cardsave.net/'
12
+ self.display_name = 'CardSave'
13
+
14
+ def initialize(options={})
15
+ super
16
+ @test_url = 'https://gw1.cardsaveonlinepayments.com:4430/'
17
+ @live_url = 'https://gw1.cardsaveonlinepayments.com:4430/'
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,230 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ #
4
+ # CardStream supports the following credit cards, which are auto-detected by
5
+ # the gateway based on the card number used:
6
+ # * AM American Express
7
+ # * Diners Club
8
+ # * Electron
9
+ # * JCB
10
+ # * UK Maestro
11
+ # * Maestro International
12
+ # * Mastercard
13
+ # * Solo
14
+ # * Style
15
+ # * Switch
16
+ # * Visa Credit
17
+ # * Visa Debit
18
+ # * Visa Purchasing
19
+ #
20
+ class CardStreamGateway < Gateway
21
+ self.live_url = self.test_url = 'https://gateway.cardstream.com/process.ashx'
22
+
23
+ self.money_format = :cents
24
+ self.default_currency = 'GBP'
25
+ self.supported_countries = ['GB']
26
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :solo, :switch]
27
+ self.homepage_url = 'http://www.cardstream.com/'
28
+ self.display_name = 'CardStream'
29
+
30
+ APPROVED = '00'
31
+
32
+ CURRENCY_CODES = {
33
+ "AUD"=> '036',
34
+ "CAD"=> '124',
35
+ "CZK"=> '203',
36
+ "DKK"=> '208',
37
+ "HKD"=> '344',
38
+ "ICK"=> '352',
39
+ "JPY"=> '392',
40
+ "NOK"=> '578',
41
+ "SGD"=> '702',
42
+ "SEK"=> '752',
43
+ "CHF"=> '756',
44
+ "GBP"=> '826',
45
+ "USD"=> '840',
46
+ "EUR"=> '978'
47
+ }
48
+
49
+ TRANSACTIONS = {
50
+ :purchase => 'ESALE_KEYED',
51
+ :refund => 'EREFUND_KEYED',
52
+ :authorization => 'ESALE_KEYED'
53
+ }
54
+
55
+ CVV_CODE = {
56
+ '0' => 'U',
57
+ '1' => 'P',
58
+ '2' => 'M',
59
+ '4' => 'N'
60
+ }
61
+
62
+ # 0 - No additional information available.
63
+ # 1 - Postcode not checked.
64
+ # 2 - Postcode matched.
65
+ # 4 - Postcode not matched.
66
+ # 8 - Postcode partially matched.
67
+ AVS_POSTAL_MATCH = {
68
+ "0" => nil,
69
+ "1" => nil,
70
+ "2" => "Y",
71
+ "4" => "N",
72
+ "8" => "N"
73
+ }
74
+
75
+ # 0 - No additional information available.
76
+ # 1 - Address numeric not checked.
77
+ # 2 - Address numeric matched.
78
+ # 4 - Address numeric not matched.
79
+ # 8 - Address numeric partially matched.
80
+ AVS_STREET_MATCH = {
81
+ "0" => nil,
82
+ "1" => nil,
83
+ "2" => "Y",
84
+ "4" => "N",
85
+ "8" => "N"
86
+ }
87
+
88
+ def initialize(options = {})
89
+ requires!(options, :login, :password)
90
+ @options = options
91
+ super
92
+ end
93
+
94
+ def purchase(money, credit_card, options = {})
95
+ requires!(options, :order_id)
96
+
97
+ post = {}
98
+
99
+ add_amount(post, money, options)
100
+ add_invoice(post, money, credit_card, options)
101
+ add_credit_card(post, credit_card)
102
+ add_address(post, options)
103
+ add_customer_data(post, options)
104
+
105
+ commit(:purchase, post)
106
+ end
107
+
108
+ private
109
+
110
+ def add_amount(post, money, options)
111
+ add_pair(post, :Amount, amount(money), :required => true)
112
+ add_pair(post, :CurrencyCode, currency_code(options[:currency] || currency(money)), :required => true)
113
+ end
114
+
115
+ def add_customer_data(post, options)
116
+ add_pair(post, :BillingEmail, options[:email])
117
+ add_pair(post, :BillingPhoneNumber, options[:phone])
118
+ end
119
+
120
+ def add_address(post, options)
121
+ address = options[:billing_address] || options[:address]
122
+
123
+ return if address.nil?
124
+
125
+ add_pair(post, :BillingStreet, address[:address1])
126
+ add_pair(post, :BillingHouseNumber, address[:address2])
127
+ add_pair(post, :BillingCity, address[:city])
128
+ add_pair(post, :BillingState, address[:state])
129
+ add_pair(post, :BillingPostCode, address[:zip])
130
+ end
131
+
132
+ def add_invoice(post, money, credit_card, options)
133
+ add_pair(post, :TransactionUnique, options[:order_id], :required => true)
134
+ add_pair(post, :OrderDesc, options[:description] || options[:order_id], :required => true)
135
+
136
+ if [ 'american_express', 'diners_club' ].include?(card_brand(credit_card).to_s)
137
+ add_pair(post, :AEIT1Quantity, 1)
138
+ add_pair(post, :AEIT1Description, (options[:description] || options[:order_id]).slice(0, 15))
139
+ add_pair(post, :AEIT1GrossValue, amount(money))
140
+ end
141
+ end
142
+
143
+ def add_credit_card(post, credit_card)
144
+ add_pair(post, :CardName, credit_card.name, :required => true)
145
+ add_pair(post, :CardNumber, credit_card.number, :required => true)
146
+
147
+ add_pair(post, :ExpiryDateMM, format(credit_card.month, :two_digits), :required => true)
148
+ add_pair(post, :ExpiryDateYY, format(credit_card.year, :two_digits), :required => true)
149
+
150
+ if requires_start_date_or_issue_number?(credit_card)
151
+ add_pair(post, :StartDateMM, format(credit_card.start_month, :two_digits))
152
+ add_pair(post, :StartDateYY, format(credit_card.start_year, :two_digits))
153
+
154
+ add_pair(post, :IssueNumber, credit_card.issue_number)
155
+ end
156
+
157
+ add_pair(post, :CV2, credit_card.verification_value)
158
+ end
159
+
160
+ def commit(action, parameters)
161
+ response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
162
+
163
+ Response.new(response[:response_code] == APPROVED, message_from(response), response,
164
+ :test => test?,
165
+ :authorization => response[:cross_reference],
166
+ :cvv_result => CVV_CODE[ response[:avscv2_response_code].to_s[0, 1] ],
167
+ :avs_result => {
168
+ :street_match => AVS_STREET_MATCH[ response[:avscv2_response_code].to_s[2, 1] ],
169
+ :postal_match => AVS_POSTAL_MATCH[ response[:avscv2_response_code].to_s[1, 1] ]
170
+ }
171
+ )
172
+ end
173
+
174
+ def message_from(results)
175
+ results[:response_code] == APPROVED ? "APPROVED" : results[:message]
176
+ end
177
+
178
+ def post_data(action, parameters = {})
179
+ parameters.update(
180
+ :MerchantPassword => @options[:password],
181
+ :MerchantID => @options[:login],
182
+ :MessageType => TRANSACTIONS[action],
183
+ :CallBack => "disable",
184
+ :DuplicateDelay => "0",
185
+ :EchoCardType => "YES",
186
+ :EchoAmount => "YES",
187
+ :EchoAVSCV2ResponseCode => "YES",
188
+ :ReturnAVSCV2Message => "YES",
189
+ :CountryCode => '826' # 826 for UK based merchant
190
+ )
191
+
192
+ add_pair(parameters, :Dispatch, action == :authorization ? "LATER" : "NOW")
193
+
194
+ parameters.collect { |key, value| "VP#{key}=#{CGI.escape(value.to_s)}" }.join("&")
195
+ end
196
+
197
+ # VPCrossReference
198
+ # The value in VPCrossReference on a success transaction will contain
199
+ # a unique reference that you may use to run future transactions.
200
+ # Please note that cross reference transactions must come a static IP
201
+ # addressed that has been pre-registered with Cardstream. To
202
+ # register an IP address please send it to support@cardstream.com
203
+ # with your Cardstream issued merchant ID and it will be added to
204
+ # your account.
205
+ def parse(body)
206
+ result = {}
207
+ pairs = body.split("&")
208
+ pairs.each do |pair|
209
+ a = pair.split("=")
210
+ result[a[0].gsub(/^VP/,'').underscore.to_sym] = a[1]
211
+ end
212
+
213
+ result
214
+ end
215
+
216
+ def test?
217
+ @options[:test] || Base.gateway_mode == :test
218
+ end
219
+
220
+ def currency_code(currency)
221
+ CURRENCY_CODES[currency]
222
+ end
223
+
224
+ def add_pair(post, key, value, options = {})
225
+ post[key] = value if !value.blank? || options[:required]
226
+ end
227
+ end
228
+ end
229
+ end
230
+
@@ -0,0 +1,278 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CertoDirectGateway < Gateway
4
+ self.live_url = self.test_url = "https://secure.certodirect.com/gateway/process/v2"
5
+
6
+ self.supported_countries = [
7
+ "BE", "BG", "CZ", "DK", "DE", "EE", "IE", "EL", "ES", "FR",
8
+ "IT", "CY", "LV", "LT", "LU", "HU", "MT", "NL", "AT", "PL",
9
+ "PT", "RO", "SI", "SK", "FI", "SE", "GB"
10
+ ]
11
+
12
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
13
+ self.homepage_url = 'http://www.certodirect.com/'
14
+ self.display_name = 'CertoDirect'
15
+
16
+ # Creates a new CertoDirectGateway
17
+ #
18
+ # The gateway requires that a valid login and password be passed
19
+ # in the +options+ hash.
20
+ #
21
+ # ==== Options
22
+ #
23
+ # * <tt>:login</tt> -- The CertoDirect Shop ID (REQUIRED)
24
+ # * <tt>:password</tt> -- The CertoDirect Shop Password. (REQUIRED)
25
+ # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
26
+ # Otherwise, perform transactions against the production server.
27
+ def initialize(options = {})
28
+ requires!(options, :login, :password)
29
+ @options = options
30
+ super
31
+ end
32
+
33
+ # Perform a purchase, which is essentially an authorization and capture in a single operation.
34
+ #
35
+ # ==== Parameters
36
+ #
37
+ # * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
38
+ # * <tt>credit_card</tt> -- The CreditCard details for the transaction.
39
+ # * <tt>options</tt> -- A hash of optional parameters.
40
+ def purchase(money, credit_card, options = {})
41
+ requires!(options, :email, :currency, :ip, :description)
42
+
43
+ commit(build_sale_request(money, credit_card, options))
44
+ end
45
+
46
+ # Refund a transaction.
47
+ #
48
+ # This transaction indicates to the gateway that
49
+ # money should flow from the merchant to the customer.
50
+ #
51
+ # ==== Parameters
52
+ #
53
+ # * <tt>money</tt> -- The amount to be credited to the customer as an Integer value in cents.
54
+ # * <tt>identification</tt> -- The ID of the original order against which the refund is being issued.
55
+ # * <tt>options</tt> -- A hash of parameters.
56
+ def refund(money, identification, options = {})
57
+ requires!(options, :reason)
58
+
59
+ commit(build_refund_request(money, identification, options))
60
+ end
61
+
62
+ # Performs an authorization, which reserves the funds on the customer's credit card, but does not
63
+ # charge the card.
64
+ #
65
+ # ==== Parameters
66
+ #
67
+ # * <tt>money</tt> -- The amount to be authorized as an Integer value in cents.
68
+ # * <tt>credit_card</tt> -- The CreditCard details for the transaction.
69
+ # * <tt>options</tt> -- A hash of optional parameters.
70
+ def authorize(money, credit_card, options = {})
71
+ requires!(options, :email, :currency, :ip, :description)
72
+
73
+ commit(build_authorize_request(money, credit_card, options))
74
+ end
75
+
76
+ # Captures the funds from an authorized transaction.
77
+ #
78
+ # ==== Parameters
79
+ #
80
+ # * <tt>money</tt> -- The amount to be captured as an Integer value in cents.
81
+ # * <tt>identification</tt> -- The authorization returned from the previous authorize request.
82
+ def capture(money, identification, options = {})
83
+ commit(build_capture_request(money, identification))
84
+ end
85
+
86
+ # Void a previous transaction
87
+ #
88
+ # ==== Parameters
89
+ #
90
+ # * <tt>money</tt> -- The amount to be captured as an Integer value in cents.
91
+ # * <tt>identification</tt> - The authorization returned from the previous authorize request.
92
+ def void(money, identification, options = {})
93
+ commit(build_void_request(money, identification))
94
+ end
95
+
96
+ # Create a recurring payment.
97
+ #
98
+ # ==== Parameters
99
+ #
100
+ # * <tt>options</tt> -- A hash of parameters.
101
+ #
102
+ # ==== Options
103
+ #
104
+ def recurring(identification, options={})
105
+ commit(build_recurring_request(identification, options))
106
+ end
107
+
108
+
109
+ private
110
+
111
+ def commit(request_xml)
112
+ begin
113
+ response = Hash.from_xml(ssl_post(self.live_url, request_xml, headers))
114
+ Response.new(success?(response),
115
+ message(response),
116
+ response,
117
+ :test => test?,
118
+ :authorization => authorization(response))
119
+ rescue ResponseError => e
120
+ raise e unless e.response.code == '403'
121
+ response = Hash.from_xml(e.response.body)['response']
122
+ Response.new(false, message(response), {}, :test => test?)
123
+ end
124
+ end
125
+
126
+ def build_sale_request(money, credit_card, options)
127
+ build_request_xml('Sale') do |xml|
128
+ add_order(xml, money, credit_card, options)
129
+ end
130
+ end
131
+
132
+ def build_authorize_request(money, credit_card, options)
133
+ build_request_xml('Authorize') do |xml|
134
+ add_order(xml, money, credit_card, options)
135
+ end
136
+ end
137
+
138
+ def build_refund_request(money, identification, options)
139
+ build_request_xml('Refund') do |xml|
140
+ add_reference_info(xml, money, identification, options)
141
+ xml.tag! 'reason', options[:reason]
142
+ end
143
+ end
144
+
145
+ def build_capture_request(money, identification)
146
+ build_request_xml('Capture') do |xml|
147
+ add_reference_info(xml, money, identification, options)
148
+ end
149
+ end
150
+
151
+ def build_void_request(money, identification)
152
+ build_request_xml('Void') do |xml|
153
+ add_reference_info(xml, money, identification, options)
154
+ end
155
+ end
156
+
157
+ def build_recurring_request(identification, options)
158
+ build_request_xml('Sale') do |xml|
159
+ xml.tag! 'order' do |xml|
160
+ xml.tag!('test', 'true') if test?
161
+ xml.tag! 'initial_order_id', identification, :type => 'integer'
162
+
163
+ add_order_details(xml, options[:amount], options) if has_any_order_details_key?(options)
164
+ add_address(xml, 'billing_address', options[:billing_address]) if options[:billing_address]
165
+ add_address(xml, 'shipping_address', options[:shipping_address]) if options[:shipping_address]
166
+ end
167
+ end
168
+ end
169
+
170
+ def build_request_xml(type, &block)
171
+ xml = Builder::XmlMarkup.new(:indent => 2)
172
+ xml.tag! 'transaction' do
173
+ xml.tag! 'type', type
174
+ yield(xml)
175
+ end
176
+ xml.target!
177
+ end
178
+
179
+ def add_order(xml, money, credit_card, options)
180
+ xml.tag! 'order' do
181
+ xml.tag!('test', 'true') if test?
182
+
183
+ xml.tag!('return_url', options[:return_url]) if options[:return_url]
184
+ xml.tag!('cancel_url', options[:cancel_url]) if options[:cancel_url]
185
+
186
+ xml.tag! 'payment_method_type', 'CreditCard'
187
+ xml.tag! 'payment_method' do
188
+ xml.tag! 'number', credit_card.number
189
+ xml.tag! 'exp_month', "%02i" % credit_card.month
190
+ xml.tag! 'exp_year', credit_card.year
191
+ xml.tag! 'holder', credit_card.name
192
+ xml.tag! 'verification_value', credit_card.verification_value
193
+ end
194
+
195
+ add_order_details(xml, money, options)
196
+ add_address(xml, 'billing_address', options[:billing_address]) if options[:billing_address]
197
+ add_address(xml, 'shipping_address', options[:shipping_address]) if options[:shipping_address]
198
+ end
199
+ end
200
+
201
+ def add_order_details(xml, money, options)
202
+ xml.tag! 'details' do
203
+ xml.tag!('amount', localized_amount(money, options[:currency]), :type => 'decimal') if money
204
+ xml.tag!('currency', options[:currency]) if options[:currency]
205
+ xml.tag!('email', options[:email]) if options[:email]
206
+ xml.tag!('ip', options[:ip]) if options[:ip]
207
+ xml.tag!('shipping', options[:shipping], :type => 'decimal') if options[:shipping]
208
+ xml.tag!('description', options[:description]) if options[:description]
209
+ end
210
+ end
211
+
212
+ def add_reference_info(xml, money, identification, options)
213
+ xml.tag! 'order_id', identification, :type => 'integer'
214
+ xml.tag! 'amount', localized_amount(money, options[:currency]), :type => 'decimal'
215
+ end
216
+
217
+ def add_address(xml, address_type, address)
218
+ xml.tag! address_type do
219
+ xml.tag! 'address', address[:address1]
220
+ xml.tag! 'city', address[:city]
221
+ xml.tag! 'country', address[:country]
222
+ xml.tag! 'first_name', address[:first_name]
223
+ xml.tag! 'last_name', address[:last_name]
224
+ xml.tag! 'state', address[:state]
225
+ xml.tag! 'phone', address[:phone]
226
+ xml.tag! 'zip', address[:zip]
227
+ end
228
+ end
229
+
230
+ def has_any_order_details_key?(options)
231
+ [ :currency, :amount, :email, :ip, :shipping, :description ].any? do |key|
232
+ options.has_key?(key)
233
+ end
234
+ end
235
+
236
+ def success?(response)
237
+ %w(completed forwarding).include?(state(response)) and
238
+ status(response) == 'success'
239
+ end
240
+
241
+ def error?(response)
242
+ response['errors']
243
+ end
244
+
245
+ def state(response)
246
+ response["transaction"].try(:[], "state")
247
+ end
248
+
249
+ def status(response)
250
+ response['transaction'].try(:[], 'response').try(:[], 'status')
251
+ end
252
+
253
+ def authorization(response)
254
+ error?(response) ? nil : response["transaction"]["order"]['id'].to_s
255
+ end
256
+
257
+ def message(response)
258
+ return response['errors'].join('; ') if error?(response)
259
+
260
+ if state(response) == 'completed'
261
+ response["transaction"]["response"]["message"]
262
+ else
263
+ response['transaction']['message']
264
+ end
265
+ end
266
+
267
+ def headers
268
+ { 'authorization' => basic_auth,
269
+ 'Accept' => 'application/xml',
270
+ 'Content-Type' => 'application/xml' }
271
+ end
272
+
273
+ def basic_auth
274
+ 'Basic ' + ["#{@options[:login]}:#{@options[:password]}"].pack('m').delete("\r\n")
275
+ end
276
+ end
277
+ end
278
+ end