Sha256: ca38ccf836d1e2772073014026184bd50edfb6404e1ca333c2817b0d91de5012

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

stripeCheckoutHandler = (key, form) ->
  StripeCheckout.configure
    key: key
    token: (token, args) ->
      if token.error
        form.find("input[type='submit']").removeProp('disabled')
        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[type='submit']").prop('disabled', true)
        form.find('input#effective_stripe_subscription_token').val('' + token['id'])
        form.submit()

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

  obj = $('#effective-orders-new-subscription-form')
  form = obj.find('form').first()
  plan = form.find('option:selected')

  if plan.length > 0
    form.find("input[type='submit']").prop('disabled', true)

    stripeCheckoutHandler(obj.data('stripe-publishable-key'), form).open
      name: obj.data('site-title')
      email: obj.data('user-email')
      description: plan.text()
      panelLabel: 'Start Subscription'
      closed: -> form.find("input[type='submit']").removeProp('disabled')

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
effective_orders-1.5.5 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.5.4 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.5.3 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.5.2 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.5.1 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.5.0 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.4.8 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.4.7 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.4.6 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.4.5 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.4.4 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee
effective_orders-1.4.3 app/assets/javascripts/effective_orders/stripe_subscriptions.js.coffee