Module: Supercharged::ChargesHelper

Defined in:
app/helpers/supercharged/charges_helper.rb

Constant Summary collapse

FAKE_ORDER_ID =

No order id while generating form. It will be added later via JS

"[payment_order_id]"

Instance Method Summary collapse

Instance Method Details

#charge_form_amount_field(service, options = {}) ⇒ Object



23
24
25
26
27
28
29
# File 'app/helpers/supercharged/charges_helper.rb', line 23

def charge_form_amount_field(service, options = {})
  amount_field_name = service.mappings[:amount] || raise(ArgumentError, "Undefined amount field mapping")

  options = default_amount_field_options.merge(options)

  number_field_tag amount_field_name, nil, options
end

#charge_form_for(service_name, options = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/supercharged/charges_helper.rb', line 5

def charge_form_for(service_name, options = {}, &block)
  raise ArgumentError, "Missing block" unless block_given?

  default_options = {service: service_name}
  options.merge!(default_options)

  options = with_default_html_options(options)

   = options.delete(:account)

  payment_service_for(FAKE_ORDER_ID, , options) do |service|
    service.notify_url gateways_result_url(service_name)
    service.return_url root_url
    service.cancel_return_url new_charge_url
    block.call(service)
  end
end