Guest User

Untitled

a guest
Apr 21st, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class RegisterForm
  2.  
  3.     constructor: ->
  4.         @initEvents()
  5.         @discountForm = new DiscountCodeForm()
  6.         @initForm()
  7.         @isFree = window.isFree;
  8.  
  9.     initForm: ->
  10.         $('#frmEnrollment').powerForm
  11.             submitButton: "#enroll-paypal-btn"
  12.             submitButtonLabel: 'Processing...'
  13.             ajaxSubmit: no
  14.             submitHandler: (form) =>
  15.                 console.log "submitHander firing"
  16.                 cb.utils.trackAction("/catalog/#{courseURL}/click/pay-now/")
  17.                 if not @isFree and not $("#free-container").is(":visible")
  18.                     console.log "Non-Free, going through stripe."
  19.                     stripe_data =
  20.                         number: $('#id_cc').val()
  21.                         exp_month: $('#id_expiry_month').val()
  22.                         exp_year: $('#id_expiry_year').val()
  23.  
  24.                     Stripe.createToken stripe_data, amount, (response) =>
  25.                         console.log 'Stripe response'
  26.                         console.log response
  27.                         #form.submit()
  28.                 else
  29.                     console.log "Free, skipping stripe."
  30.                     $.blockUI message: "Processing..."
  31.                     form.submit()
  32.             onError: ->
  33.                 $.unblockUI()
  34.             onResponse: @processEnrollment
  35.  
  36.     initEvents: ->
Add Comment
Please, Sign In to add comment