Module: PayuIndia::ActionViewHelper
- Defined in:
- lib/payuindia/action_view_helper.rb
Instance Method Summary collapse
-
#payment_form_for_payu(key, salt, options = {}) ⇒ Object
This Helper creates form with all parameters added.
-
#payu_biz_form(key, salt, options, &block) ⇒ Object
This Helper creates form with all parameters added.
Instance Method Details
#payment_form_for_payu(key, salt, options = {}) ⇒ Object
This Helper creates form with all parameters added.
<% payment_form_for_payu 'YOUR_KEY', 'YOUR_SALT',
:txnid => @cart.id,
:amount => @cart.total_price,
:productinfo => 'Book',
:firstname => 'abc',
:email => '[email protected]',
:phone => '1234567890',
:surl => 'http://localhost:3000/payu_callback',
:furl => 'http://localhost:3000/payu_callback',
:html => { :id => 'payment-form' } %>
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/payuindia/action_view_helper.rb', line 21 def payment_form_for_payu(key, salt, = {}) if !.is_a?(Hash) || !key.is_a?(String) || !salt.is_a?(String) concat("Something Wrong! params order -> key (String), salt (String), options (Hash) ") nil else = .delete(:html) || {} service = PayuIndia::Helper.new(key, salt, ) result = [] result << form_tag(PayuIndia.service_url, .merge(:method => :post)) result << hidden_field_tag('key', key) service.form_fields.each do |field, value| result << hidden_field_tag(field, value) end result << '<input type=submit value=" Pay with PayU ">' result << '</form>' result= result.join("\n") concat(result.respond_to?(:html_safe) ? result.html_safe : result) nil end end |
#payu_biz_form(key, salt, options, &block) ⇒ Object
This Helper creates form with all parameters added.
<% payu_biz_form 'YOUR_KEY', 'YOUR_SALT',
:txnid => @cart.id,
:amount => @cart.total_price,
:productinfo => 'Book',
:firstname => 'abc',
:email => '[email protected]',
:phone => '1234567890',
:surl => 'http://localhost:3000/payu_callback',
:furl => 'http://localhost:3000/payu_callback',
:html => { :id => 'payment-form', :button_text => 'Purchase' } do %>
<%= label_tag 'City' %>
<%= text_field_tag 'city' %>
<%= label_tag 'Country' %>
<%= text_field_tag 'country' %>
<% end %>
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/payuindia/action_view_helper.rb', line 68 def payu_biz_form(key, salt, , &block) if !.is_a?(Hash) || !key.is_a?(String) || !salt.is_a?(String) concat("Something Wrong! params order -> key (String), salt (String), options (Hash) ") nil else = .delete(:html) || {} service = PayuIndia::Helper.new(key, salt, ) result = [] result << form_tag(PayuIndia.service_url, .merge(:method => :post)) result << hidden_field_tag('key', key) service.form_fields.each do |field, value| result << hidden_field_tag(field, value) end result << capture(&block) result << "<input type=submit value='#{[:button_text] || ' Pay with PayU '}'>" result << '</form>' result = result.join("\n") concat(result.respond_to?(:html_safe) ? result.html_safe : result) nil end end |