Class: PaypalHelper
- Inherits:
-
Object
- Object
- PaypalHelper
- Defined in:
- lib/sinatra/paypal/paypal-helper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#form_url ⇒ Object
returns the url that the payment forms must be submitted to so they can be processed by paypal.
-
#initialize(use_sandbox) ⇒ PaypalHelper
constructor
A new instance of PaypalHelper.
-
#ipn_valid?(params) ⇒ Boolean
validates the ipn request with paypal to make sure it is genuine.
Constructor Details
#initialize(use_sandbox) ⇒ PaypalHelper
Returns a new instance of PaypalHelper.
4 5 6 |
# File 'lib/sinatra/paypal/paypal-helper.rb', line 4 def initialize(use_sandbox) @use_sandbox = use_sandbox end |
Class Method Details
.form_url(use_sandbox) ⇒ Object
18 19 20 |
# File 'lib/sinatra/paypal/paypal-helper.rb', line 18 def self.form_url(use_sandbox) new(use_sandbox).form_url end |
Instance Method Details
#form_url ⇒ Object
returns the url that the payment forms must be submitted to so they can be processed by paypal. If the sandbox attribute is set, then it will return the url for the sandbox
form_url # => www.paypal.com/cgi-bin/webscr
14 15 16 |
# File 'lib/sinatra/paypal/paypal-helper.rb', line 14 def form_url @use_sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr' end |
#ipn_valid?(params) ⇒ Boolean
validates the ipn request with paypal to make sure it is genuine. params
should contain the exact params object that was sent as part of the IPN POST
24 25 26 27 28 29 |
# File 'lib/sinatra/paypal/paypal-helper.rb', line 24 def ipn_valid?(params) return false if params.nil? params[:cmd] = '_notify-validate' return RestClient.post(self.form_url, params) == 'VERIFIED' end |