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, html_options) ⇒ FormBuilder

Returns a new instance of FormBuilder.



6
7
8
9
10
11
# File 'lib/webpay_interswitch/form_builder.rb', line 6

def initialize(txn_ref, amount, html_options)
  @txn_ref = txn_ref
  @amount = amount
  @html_options = html_options
  sanitize_options
end

Instance Method Details

#generate_webpay_formObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/webpay_interswitch/form_builder.rb', line 13

def generate_webpay_form
  form_html = "<form action=#{ WebpayInterswitch::Gateway.url } method=post>"

  form_html += generate_webpay_elements

  form_html += generate_transaction_data_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)


28
29
30
# File 'lib/webpay_interswitch/form_builder.rb', line 28

def valid?
  @txn_ref.present? && Integer(@amount.to_s) > 0 rescue false
end