Module: Auth::Shopping::Payments::PayUMoneyHelper
- Defined in:
- app/helpers/auth/shopping/payments/pay_u_money_helper.rb
Instance Method Summary collapse
-
#payment_error_message(payment) ⇒ Object
returns the first error message from the validations.
-
#payment_options(payment, resource) ⇒ Object
used in the _gateway.html.erb, while generating the form to post to create payment.
-
#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.
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) if payment.payment_success payment.class::SUCCESS elsif payment.payment_failed payment.class::FAILED elsif payment.payment_pending if !payment.errors..empty? payment.errors.[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,resource) = {} [:hidden] = {} [: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 [:hidden][:payment_type] = payment.payment_type [:hidden][:cart_id] = payment.cart_id.to_s [:visible][:productinfo] = payment.get_cart_name [:visible][:firstname] = resource.resource_first_name [:visible][:email] = resource.email [:visible][:phone] = resource.has_phone ? resource.additional_login_param : nil [:visible][:amount] = payment.amount 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, = {:id => "payumoney_form"}) result = [] result << form_tag(PayuIndia.service_url,.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 |