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,40 @@
1
+ require File.dirname(__FILE__) + '/nelnet/helper.rb'
2
+ require File.dirname(__FILE__) + '/nelnet/notification.rb'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ module Integrations #:nodoc:
7
+ module Nelnet
8
+
9
+ # Overwrite this if you want to change the Paypal test url
10
+ mattr_accessor :test_url
11
+ self.test_url = 'http://localhost:3000/gateway/payment'
12
+
13
+ # Overwrite this if you want to change the Paypal production url
14
+ mattr_accessor :production_url
15
+ self.production_url = 'https://prod.nelnet.com/'
16
+
17
+ # Returns the current service url
18
+ def self.service_url
19
+ mode = ActiveMerchant::Billing::Base.integration_mode
20
+ case mode
21
+ when :production
22
+ self.production_url
23
+ when :test
24
+ self.test_url
25
+ else
26
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
27
+ end
28
+ end
29
+
30
+ def self.notification(post)
31
+ Notification.new(post)
32
+ end
33
+
34
+ def self.return(query_string)
35
+ Return.new(query_string)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,34 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Nelnet
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ # Replace with the real mapping
7
+ mapping :account, ''
8
+ mapping :amount, ''
9
+
10
+ mapping :order, ''
11
+
12
+ mapping :customer, :first_name => '',
13
+ :last_name => '',
14
+ :email => '',
15
+ :phone => ''
16
+
17
+ mapping :billing_address, :city => '',
18
+ :address1 => '',
19
+ :address2 => '',
20
+ :state => '',
21
+ :zip => '',
22
+ :country => ''
23
+
24
+ mapping :notify_url, ''
25
+ mapping :return_url, ''
26
+ mapping :cancel_return_url, ''
27
+ mapping :description, ''
28
+ mapping :tax, ''
29
+ mapping :shipping, ''
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,100 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Nelnet
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+ def complete?
9
+ params['']
10
+ end
11
+
12
+ def item_id
13
+ params['']
14
+ end
15
+
16
+ def transaction_id
17
+ params['']
18
+ end
19
+
20
+ # When was this payment received by the client.
21
+ def received_at
22
+ params['']
23
+ end
24
+
25
+ def payer_email
26
+ params['']
27
+ end
28
+
29
+ def receiver_email
30
+ params['']
31
+ end
32
+
33
+ def security_key
34
+ params['']
35
+ end
36
+
37
+ # the money amount we received in X.2 decimal.
38
+ def gross
39
+ params['']
40
+ end
41
+
42
+ # Was this a test transaction?
43
+ def test?
44
+ params[''] == 'test'
45
+ end
46
+
47
+ def status
48
+ params['']
49
+ end
50
+
51
+ # Acknowledge the transaction to Nelnet. This method has to be called after a new
52
+ # apc arrives. Nelnet will verify that all the information we received are correct and will return a
53
+ # ok or a fail.
54
+ #
55
+ # Example:
56
+ #
57
+ # def ipn
58
+ # notify = NelnetNotification.new(request.raw_post)
59
+ #
60
+ # if notify.acknowledge
61
+ # ... process order ... if notify.complete?
62
+ # else
63
+ # ... log possible hacking attempt ...
64
+ # end
65
+ def acknowledge
66
+ payload = raw
67
+
68
+ uri = URI.parse(Nelnet.notification_confirmation_url)
69
+
70
+ request = Net::HTTP::Post.new(uri.path)
71
+
72
+ request['Content-Length'] = "#{payload.size}"
73
+ request['User-Agent'] = "Active Merchant -- http://home.leetsoft.com/am"
74
+ request['Content-Type'] = "application/x-www-form-urlencoded"
75
+
76
+ http = Net::HTTP.new(uri.host, uri.port)
77
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_strict
78
+ http.use_ssl = true
79
+
80
+ response = http.request(request, payload)
81
+
82
+ # Replace with the appropriate codes
83
+ raise StandardError.new("Faulty Nelnet result: #{response.body}") unless ["AUTHORISED", "DECLINED"].include?(response.body)
84
+ response.body == "AUTHORISED"
85
+ end
86
+ private
87
+
88
+ # Take the posted data and move the relevant data into a hash
89
+ def parse(post)
90
+ @raw = post
91
+ for line in post.split('&')
92
+ key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
93
+ params[key] = value
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,88 @@
1
+
2
+ module ActiveMerchant #:nodoc:
3
+ module Billing #:nodoc:
4
+ module Integrations #:nodoc:
5
+ # To start with Nochex, follow the instructions for installing
6
+ # ActiveMerchant as a plugin, as described on
7
+ # http://www.activemerchant.org/.
8
+ #
9
+ # The plugin will automatically add the ActionView helper for
10
+ # ActiveMerchant, which will allow you to make the Nochex payments.
11
+ # The idea behind the helper is that it generates an invisible
12
+ # forwarding screen that will automatically redirect the user.
13
+ # So you would collect all the information about the order and then
14
+ # simply render the hidden form, which redirects the user to Nochex.
15
+ #
16
+ # The syntax of the helper is as follows:
17
+ #
18
+ # <% payment_service_for 'order id', 'nochex_user_id',
19
+ # :amount => 50.00,
20
+ # :service => :nochex,
21
+ # :html => { :id => 'nochex-form' } do |service| %>
22
+ #
23
+ # <% service.customer :first_name => 'Cody',
24
+ # :last_name => 'Fauser',
25
+ # :phone => '(555)555-5555',
26
+ # :email => 'cody@example.com' %>
27
+ #
28
+ # <% service.billing_address :city => 'Ottawa',
29
+ # :address1 => '21 Snowy Brook Lane',
30
+ # :address2 => 'Apt. 36',
31
+ # :state => 'ON',
32
+ # :country => 'CA',
33
+ # :zip => 'K1J1E5' %>
34
+ #
35
+ # <% service.invoice '#1000' %>
36
+ # <% service.shipping '0.00' %>
37
+ # <% service.tax '0.00' %>
38
+ #
39
+ # <% service.notify_url url_for(:action => 'notify', :only_path => false) %>
40
+ # <% service.return_url url_for(:action => 'done', :only_path => false) %>
41
+ # <% service.cancel_return_url 'http://mystore.com' %>
42
+ # <% end %>
43
+ #
44
+ # The notify_url is the URL that the Nochex IPN will be sent. You can
45
+ # handle the notification in your controller action as follows:
46
+ #
47
+ # class NotificationController < ApplicationController
48
+ # include ActiveMerchant::Billing::Integrations
49
+ #
50
+ # def notify
51
+ # notification = Nochex::Notification.new(request.raw_post)
52
+ #
53
+ # begin
54
+ # # Acknowledge notification with Nochex
55
+ # raise StandardError, 'Illegal Notification' unless notification.acknowledge
56
+ # # Process the payment
57
+ # rescue => e
58
+ # logger.warn("Illegal notification received: #{e.message}")
59
+ # ensure
60
+ # head(:ok)
61
+ # end
62
+ # end
63
+ # end
64
+ module Nochex
65
+ autoload :Return, File.dirname(__FILE__) + '/nochex/return.rb'
66
+ autoload :Helper, File.dirname(__FILE__) + '/nochex/helper.rb'
67
+ autoload :Notification, File.dirname(__FILE__) + '/nochex/notification.rb'
68
+
69
+
70
+ mattr_accessor :service_url
71
+ self.service_url = 'https://secure.nochex.com'
72
+
73
+ mattr_accessor :notification_confirmation_url
74
+ self.notification_confirmation_url = 'https://www.nochex.com/nochex.dll/apc/apc'
75
+
76
+ # Simply a convenience method that returns a new
77
+ # ActiveMerchant::Billing::Integrations::Nochex::Notification
78
+ def self.notification(post, options = {})
79
+ Notification.new(post)
80
+ end
81
+
82
+ def self.return(query_string, options = {})
83
+ Return.new(query_string)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,68 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Nochex
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ # Required Parameters
7
+ # email
8
+ # amount
9
+ mapping :account, 'email'
10
+ mapping :amount, 'amount'
11
+
12
+ # Set the field status = test for testing with accounts:
13
+ # Account Password
14
+ # test1@nochex.com 123456
15
+ # test2@nochex.com 123456
16
+ # def initialize(order, account, options = {})
17
+ # super
18
+ # add_field('status', 'test')
19
+ # end
20
+
21
+ # Need to format the amount to have 2 decimal places
22
+ def amount=(money)
23
+ cents = money.respond_to?(:cents) ? money.cents : money
24
+ if money.is_a?(String) or cents.to_i <= 0
25
+ raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.'
26
+ end
27
+ add_field mappings[:amount], sprintf("%.2f", cents.to_f/100)
28
+ end
29
+
30
+ # Optional Parameters
31
+ # ordernumber
32
+ mapping :order, 'ordernumber'
33
+
34
+ # firstname
35
+ # lastname
36
+ # email_address_sender
37
+ mapping :customer, :first_name => 'firstname',
38
+ :last_name => 'lastname',
39
+ :email => 'email_address_sender'
40
+
41
+ # town
42
+ # firstline
43
+ # county
44
+ # postcode
45
+ mapping :billing_address, :city => 'town',
46
+ :address1 => 'firstline',
47
+ :state => 'county',
48
+ :zip => 'postcode'
49
+
50
+ # responderurl
51
+ mapping :notify_url, 'responderurl'
52
+
53
+ # returnurl
54
+ mapping :return_url, 'returnurl'
55
+
56
+ # cancelurl
57
+ mapping :cancel_return_url, 'cancelurl'
58
+
59
+ # description
60
+ mapping :description, 'description'
61
+
62
+ # Currently unmapped
63
+ # logo
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,94 @@
1
+ require 'net/http'
2
+ require 'date'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ module Integrations #:nodoc:
7
+ module Nochex
8
+ # Parser and handler for incoming Automatic Payment Confirmations from Nochex.
9
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
10
+ include ActiveMerchant::PostsData
11
+
12
+ def complete?
13
+ status == 'Completed'
14
+ end
15
+
16
+ # Id of the order we passed to Nochex
17
+ def item_id
18
+ params['order_id']
19
+ end
20
+
21
+ def transaction_id
22
+ params['transaction_id']
23
+ end
24
+
25
+ def currency
26
+ 'GBP'
27
+ end
28
+
29
+ # When was this payment received by the client.
30
+ def received_at
31
+ # U.K. Format: 27/09/2006 22:30:54
32
+ return if params['transaction_date'].blank?
33
+ time = params['transaction_date'].scan(/\d+/)
34
+ Time.utc(time[2], time[1], time[0], time[3], time[4], time[5])
35
+ end
36
+
37
+ def payer_email
38
+ params['from_email']
39
+ end
40
+
41
+ def receiver_email
42
+ params['to_email']
43
+ end
44
+
45
+ def security_key
46
+ params['security_key']
47
+ end
48
+
49
+ # the money amount we received in X.2 decimal.
50
+ def gross
51
+ sprintf("%.2f", params['amount'].to_f)
52
+ end
53
+
54
+ # Was this a test transaction?
55
+ def test?
56
+ params['status'] == 'test'
57
+ end
58
+
59
+ def status
60
+ 'Completed'
61
+ end
62
+
63
+ # Acknowledge the transaction to Nochex. This method has to be called after a new
64
+ # apc arrives. Nochex will verify that all the information we received are correct and will return a
65
+ # ok or a fail. This is very similar to the PayPal IPN scheme.
66
+ #
67
+ # Example:
68
+ #
69
+ # def nochex_ipn
70
+ # notify = NochexNotification.new(request.raw_post)
71
+ #
72
+ # if notify.acknowledge
73
+ # ... process order ... if notify.complete?
74
+ # else
75
+ # ... log possible hacking attempt ...
76
+ # end
77
+ def acknowledge
78
+ payload = raw
79
+
80
+ response = ssl_post(Nochex.notification_confirmation_url, payload,
81
+ 'Content-Length' => "#{payload.size}",
82
+ 'User-Agent' => "Active Merchant -- http://activemerchant.org",
83
+ 'Content-Type' => "application/x-www-form-urlencoded"
84
+ )
85
+
86
+ raise StandardError.new("Faulty Nochex result: #{response}") unless ["AUTHORISED", "DECLINED"].include?(response)
87
+
88
+ response == "AUTHORISED"
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,10 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Nochex
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,62 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ class Notification
5
+ attr_accessor :params
6
+ attr_accessor :raw
7
+
8
+ # set this to an array in the subclass, to specify which IPs are allowed to send requests
9
+ class_attribute :production_ips
10
+
11
+ def initialize(post, options = {})
12
+ @options = options
13
+ empty!
14
+ parse(post)
15
+ end
16
+
17
+ def status
18
+ raise NotImplementedError, "Must implement this method in the subclass"
19
+ end
20
+
21
+ # the money amount we received in X.2 decimal.
22
+ def gross
23
+ raise NotImplementedError, "Must implement this method in the subclass"
24
+ end
25
+
26
+ def gross_cents
27
+ (gross.to_f * 100.0).round
28
+ end
29
+
30
+ # This combines the gross and currency and returns a proper Money object.
31
+ # this requires the money library located at http://dist.leetsoft.com/api/money
32
+ def amount
33
+ return Money.new(gross_cents, currency) rescue ArgumentError
34
+ return Money.new(gross_cents) # maybe you have an own money object which doesn't take a currency?
35
+ end
36
+
37
+ # reset the notification.
38
+ def empty!
39
+ @params = Hash.new
40
+ @raw = ""
41
+ end
42
+
43
+ # Check if the request comes from an official IP
44
+ def valid_sender?(ip)
45
+ return true if ActiveMerchant::Billing::Base.integration_mode == :test || production_ips.blank?
46
+ production_ips.include?(ip)
47
+ end
48
+
49
+ private
50
+
51
+ # Take the posted data and move the relevant data into a hash
52
+ def parse(post)
53
+ @raw = post.to_s
54
+ for line in @raw.split('&')
55
+ key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
56
+ params[key] = CGI.unescape(value)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end