class PaypalHelper
Public Class Methods
form_url(use_sandbox)
click to toggle source
# File lib/sinatra/paypal/paypal-helper.rb, line 18 def self.form_url(use_sandbox) new(use_sandbox).form_url end
new(use_sandbox)
click to toggle source
# File lib/sinatra/paypal/paypal-helper.rb, line 4 def initialize(use_sandbox) @use_sandbox = use_sandbox end
Public Instance Methods
form_url()
click to toggle source
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 # => https://www.paypal.com/cgi-bin/webscr
# 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)
click to toggle source
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
# 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