Module: PayPal::Helpers

Defined in:
lib/sinatra/paypal.rb

Instance Method Summary collapse

Instance Method Details

#_call_paypal_method(key, paypal_request) ⇒ Object



33
34
35
# File 'lib/sinatra/paypal.rb', line 33

def _call_paypal_method(key, paypal_request)
	self.send self.class._paypal_method_name(key), paypal_request
end

#html_payment_form(item, data = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sinatra/paypal.rb', line 15

def html_payment_form(item, data = {})
	# it is valid to send a nil item through - we might be going to set the fields in
	# javascript - but if it isn't null then there are certain fields that need to be
	# set
	if !item.nil?
		raise 'item.code required' if !item.respond_to?(:code) || item.code.nil?
		raise 'item.price required' if !item.respond_to?(:price) || item.price.nil?
		raise 'item.price must be a number above zero' if item.price.to_f <= 0
	end

	raise 'cannot generate a payment form without settings.paypal.email' if settings.paypal.email.nil?

	erb :_payment, :views => File.join(File.dirname(__FILE__), '/paypal'), :locals => {
		:custom_data => data,
		:item => item
	}
end

#paypal_form_urlObject



11
12
13
# File 'lib/sinatra/paypal.rb', line 11

def paypal_form_url
	PaypalHelper.form_url(settings.paypal.sandbox?)
end