Sha256: df39ef1110a10c132fc39876164c9f09cdca343929f2d1d6fadb55c78e9c525e

Contents?: true

Size: 1.4 KB

Versions: 18

Compression:

Stored size: 1.4 KB

Contents

stripeCheckoutHandler = (key, form) ->
  StripeCheckout.configure
    key: key
    closed: ->
      form.find("input[type='submit']").removeAttr('disabled')
      $('input[data-disable-with]').each -> try $.rails.enableFormElement($(this))
    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[name$='[stripe_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()
  stripe = obj.data('stripe')

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

  stripeCheckoutHandler(stripe.key, $form).open
    image: stripe.image
    name: stripe.name
    description: stripe.description
    email: stripe.email
    amount: stripe.amount

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
effective_orders-3.2.3 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.2.2 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.2.1 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.2.0 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.1.7 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.1.6 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.1.4 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.1.3 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.1.0 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.0.4 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.0.3 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.0.2 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-4.0.0beta4 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-4.0.0beta3 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-4.0.0beta2 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-4.0.0beta1 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.0.1 app/assets/javascripts/effective_orders/providers/stripe.js.coffee
effective_orders-3.0.0 app/assets/javascripts/effective_orders/providers/stripe.js.coffee