Sha256: 27f376516edd5a7757877e2ff7da89c424192844c862b43026740681ec0aa969

Contents?: true

Size: 1.14 KB

Versions: 24

Compression:

Stored size: 1.14 KB

Contents

stripeCheckoutHandler = (key, form) ->
  StripeCheckout.configure
    key: key
    token: (token, args) ->
      if token.error
        form.find("input[type='submit']").removeAttr('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_providers_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']").removeAttr('disabled')

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
effective_orders-2.1.1 app/assets/javascripts/effective_orders/providers/stripe_subscriptions.js.coffee
effective_orders-2.1.0 app/assets/javascripts/effective_orders/providers/stripe_subscriptions.js.coffee
effective_orders-2.0.1 app/assets/javascripts/effective_orders/providers/stripe_subscriptions.js.coffee
effective_orders-2.0.0 app/assets/javascripts/effective_orders/providers/stripe_subscriptions.js.coffee