Class: WebpayInterswitch::FormBuilder

Inherits:
Object
  • Object
show all
Includes:
Core
Defined in:
lib/webpay_interswitch/form_builder.rb

Instance Method Summary collapse

Methods included from Core

#sha_hash

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, html_options, optional_parameters)
  @txn_ref = txn_ref
  @amount = amount
  @html_options = html_options
  @cust_name = cust_name
  @cust_id = cust_id
  @optional_parameters = optional_parameters
  sanitize_options
end

Instance Method Details

#generate_webpay_formObject



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

Returns:

  • (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