Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1.  
  2. <div class="row stripeCardForm">
  3. <section class="col col-3">
  4. <label class="label">{{ 'card-number' | t }}</label>
  5. <label class="input">
  6. <span class="value-input ">
  7. <input type="text" size="20" data-stripe="number">
  8. </span>
  9. </label>
  10. </section>
  11.  
  12. <section class="col col-2">
  13. <label class="label">{{ 'expiration_month' | t }}</label>
  14. <label class="input">
  15. <span class="value-input ">
  16. <input type="text" size="2" data-stripe="exp_month">
  17. </span>
  18. </label>
  19. </section>
  20.  
  21. <section class="col col-2">
  22. <label class="label">{{ 'expiration_year' | t }}</label>
  23. <label class="input">
  24. <span class="value-input ">
  25. <input type="text" size="2" data-stripe="exp_year">
  26. </span>
  27. </label>
  28. </section>
  29.  
  30. <section class="col col-2">
  31. <label class="label">{{ 'cvc' | t }}</label>
  32. <label class="input">
  33. <span class="value-input ">
  34. <input type="text" size="4" data-stripe="cvc">
  35. </span>
  36. </label>
  37. </section>
  38.  
  39. <section class="col col-3">
  40. <label class="label">{{ 'billing-zip' | t }}</label>
  41. <label class="input">
  42. <span class="value-input ">
  43. <input type="text" size="6" data-stripe="address_zip">
  44. </span>
  45. </label>
  46. </section>
  47.  
  48. <span class="payment-errors"></span>
  49. </div>
  50.  
  51.  
  52. <script type="text/javascript">
  53. $(function() {
  54. var $form = $('{{ options.formName }}');
  55. $form.submit(function(event) {
  56. // Disable the submit button to prevent repeated clicks:
  57. $form.find('.submit').prop('disabled', true);
  58.  
  59. if (stripeFormEnabled) {
  60. // Set apikey
  61. Stripe.setPublishableKey('{{ options.APIKEY }}');
  62.  
  63. // Request a token from Stripe:
  64. Stripe.card.createToken($form, stripeResponseHandler);
  65.  
  66. // Prevent the form from being submitted:
  67. return false;
  68. } else {
  69. // Submit the form:
  70. var url = $form.attr('action');
  71.  
  72. if (url[0] === '#') {
  73. sendData(url, $form.serialize(), $('#content'));
  74. return false;
  75. }
  76. }
  77. });
  78. });
  79.  
  80. function stripeResponseHandler(status, response) {
  81. // Grab the form:
  82. var $form = $('{{ options.formName }}');
  83.  
  84. if (response.error) { // Problem!
  85.  
  86. // Show the errors on the form:
  87. $.smallBox({
  88. title: response.error.message,
  89. color: "danger"
  90. });
  91. $form.find('.submit').prop('disabled', false); // Re-enable submission
  92.  
  93. } else { // Token was created!
  94.  
  95. // Get the token ID:
  96. var token = response.id;
  97.  
  98. // Insert the token ID into the form so it gets submitted to the server:
  99. $form.append($('<input type="hidden" name="stripeToken">').val(token));
  100.  
  101. // Submit the form:
  102. var url = $form.attr('action');
  103.  
  104. if (url[0] === '#') {
  105. sendData(url, $form.serialize(), $('#content'));
  106. return false;
  107. }
  108.  
  109. }
  110. };
  111. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement