Module: Auth::Shopping::Payments::PayUMoneyHelper

Defined in:
app/helpers/auth/shopping/payments/pay_u_money_helper.rb

Instance Method Summary collapse

Instance Method Details

#payment_error_message(payment) ⇒ Object

returns the first error message from the validations. used in views.



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/auth/shopping/payments/pay_u_money_helper.rb', line 43

def payment_error_message(payment)
	if payment.payment_success
		payment.class::SUCCESS
	elsif payment.payment_failed
		payment.class::FAILED
	elsif payment.payment_pending
		if !payment.errors.full_messages.empty?
			payment.errors.full_messages[0]
		else
			payment.class::PENDING
		end
	end
end

#payment_options(payment, resource) ⇒ Object

used in the _gateway.html.erb, while generating the form to post to create payment.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/auth/shopping/payments/pay_u_money_helper.rb', line 3

def payment_options(payment,resource)
	options = {}
	options[:hidden] = {}
	options[:visible] = {}
	#these three options are set in the before_save callback of the payumoney concern
	#options[:hidden][:txnid] = payment.id.to_s
	#options[:hidden][:surl] = success_url
	#options[:hidden][:furl] = failure_url
	options[:hidden][:payment_type] =  payment.payment_type
	options[:hidden][:cart_id] = payment.cart_id.to_s
	
	options[:visible][:productinfo] = payment.get_cart_name
	options[:visible][:firstname] =  resource.resource_first_name
	options[:visible][:email] = resource.email
	options[:visible][:phone] = resource.has_phone ? resource. : nil
	options[:visible][:amount] = payment.amount
	options
end

#payment_to_gateway_form(payment, html_options = {:id => "payumoney_form"}) ⇒ Object

converts the payment object to a form that can be submitted to the gateway.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/auth/shopping/payments/pay_u_money_helper.rb', line 23

def payment_to_gateway_form(payment,html_options = {:id => "payumoney_form"})
	result = []
	result << form_tag(PayuIndia.service_url,html_options.merge(:method => :post))

       result << hidden_field_tag('key', payment.payment_gateway_key)

       payment.attributes.each do |field, value|

         result << hidden_field_tag(field == "hast" ? "hash" : field, value)
       end

       result << '<input type="image" src="/assets/payumoney.png" >'
       result << '</form>'
       result = result.join("\n")
       concat(result.respond_to?(:html_safe) ? result.html_safe : result)
       nil
end