Class: WebpayInterswitch::FormBuilder
- Inherits:
-
Object
- Object
- WebpayInterswitch::FormBuilder
- Includes:
- Core
- Defined in:
- lib/webpay_interswitch/form_builder.rb
Instance Method Summary collapse
- #generate_webpay_form ⇒ Object
-
#initialize(txn_ref, amount, cust_name, cust_id, html_options, optional_parameters) ⇒ FormBuilder
constructor
A new instance of FormBuilder.
- #valid? ⇒ Boolean
Methods included from Core
Constructor Details
#initialize(txn_ref, amount, cust_name, cust_id, html_options, optional_parameters) ⇒ FormBuilder
Returns a new instance of FormBuilder.
6 7 8 9 10 11 12 13 14 |
# File 'lib/webpay_interswitch/form_builder.rb', line 6 def initialize(txn_ref, amount, cust_name, cust_id, , optional_parameters) @txn_ref = txn_ref @amount = amount @html_options = @cust_name = cust_name @cust_id = cust_id @optional_parameters = optional_parameters end |
Instance Method Details
#generate_webpay_form ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/webpay_interswitch/form_builder.rb', line 16 def generate_webpay_form form_html = "<form action=#{ WebpayInterswitch::Gateway.url } method=post>" form_html += generate_webpay_elements form_html += generate_transaction_data_elements form_html += generate_optional_parameter_elements # This generates the submit button alongwith the @submit_button_text # If submit_button_text is not provided, it defaults to 'Make Payment' form_html += generate_input_field('commit', @submit_button_text, 'submit', @html_options) form_html += '</form>' end |
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/webpay_interswitch/form_builder.rb', line 32 def valid? @txn_ref.present? && Integer(@amount.to_s) > 0 rescue false end |