Sha256: ffd434b0658c7d5368c04418e3c004eac85b5cbac0ef4a4110742cb6850db4c3

Contents?: true

Size: 1.39 KB

Versions: 24

Compression:

Stored size: 1.39 KB

Contents

stripeCheckoutHandler = (key, form) ->
  StripeCheckout.configure
    key: key
    token: (token, args) ->
      if token.error
        form.find("input[type='submit']").removeAttr('disabled')
        $('input[data-disable-with]').each -> try $.rails.enableFormElement($(this))

        alert("An error ocurred when contacting Stripe.  Your card has not been charged.  Please refresh the page and try again. #{token.error.message}")
      else
        form.find('input#effective_providers_stripe_charge_token').val('' + token['id'])

        form.find("input[type='submit']").prop('disabled', true)
        $('input[data-disable-with]').each -> try $.rails.disableFormElement($(this))

        form.submit()

$(document).on 'click', "#effective-orders-new-charge-form form input[type='submit']", (event) ->
  event.preventDefault()

  obj = $('#effective-orders-new-charge-form')
  form = obj.find('form').first()

  form.find("input[type='submit']").prop('disabled', true)
  $('input[data-disable-with]').each -> try $.rails.disableFormElement($(this))

  stripeCheckoutHandler(obj.data('stripe-publishable-key'), form).open
    name: obj.data('site-title')
    email: obj.data('user-email')
    description: obj.data('description')
    amount: obj.data('amount')
    closed: ->
      form.find("input[type='submit']").removeAttr('disabled')
      $('input[data-disable-with]').each -> try $.rails.enableFormElement($(this))

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
effective_orders-2.2.4 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.2.3 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.2.2 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.2.1 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.2.0 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.17 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.16 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.15 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.14 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.13 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.12 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.10 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.9 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.8 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.7 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.6 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.5 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.4 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.3 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
effective_orders-2.1.2 app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee