Sha256: 58d3d587bc3d562d3cf91092efabc11182d91481fbc7811610a0a6dae06310ed
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
class ChargeForm constructor: (selector, options = {}) -> @form = $(selector) return if @form.length == 0 @amount_input = @form.find("[role='charge-amount']") @id_input = @form.find("[value='<%= Supercharged::ChargesHelper::FAKE_ORDER_ID %>']") @form.submit => @start_payment() unless parseInt(@id_input.val()) alert("Error: undefined charge id") return false start_payment: -> @create_internal_transaction( success: (charge) => @prepare_gateway_form(charge) ) create_internal_transaction: (options) -> charge_attributes = @get_charge_attributes() $.ajax( url: "/charges.json", type: "POST", async: false, data: { charge: charge_attributes}, success: (response, a) -> options.success(response) ) get_charge_attributes: -> { amount: @amount_input.val() } prepare_gateway_form: (charge) -> @id_input.val(charge.id) $ -> window.widgets ||= {} window.widgets.charge_form = new ChargeForm("[role='gateway-charge-form']")
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
supercharged-1.0.0 | app/assets/javascripts/charge_form.js.coffee.erb |