Build a Monthly Subscription App with Laravel Cashier

Create a Token

To create a token from a user's credit card information, we'll use the Stripe.js library.

Here is the code to process our form:

// target the form
  // on form submission, create a token
  $('#subscribe-form').submit(function(e) {
    var form = $(this);

    // disable the form button
    form.find('button').prop('disabled', true);

    // use the stripe library. create a single use token
    Stripe.card.createToken(form, function(status, response) {

      // if there are errors, show them
      if (response.error) {
        form.find('.stripe-errors').text(response.error.message).addClass('alert alert-danger');
        form.find('button').prop('disabled', false);
      } else {

        // if there are no errors...

        // append the token to the form
        form.append($('<input type="hidden" name="cc_token">').val(;

        // submit the form


Like this article? Follow @chrisoncode on Twitter