title: Creating a modal success notification for Stripe checkout
body: <p>I'm trying to make the success of a stripe checkout a little nicer then a <code>div</code> that says "Thank you for your submission". I'm looking to add a modal that will have this thank you message. But I'm new to PHP and I keep breaking the stripe token. I am not sure what way to go about this. I've seen custom submit buttons with AJAX but not sure if that is needed. Thanks in advance!</p>
  
  <p><strong>Here is my HTML:</strong></p>
  
  <pre><code>&lt;?php if (isset($_POST['cart_errors'])) : ?&gt;
      &lt;div class="thank-you"&gt;&lt;?=$_POST['cart_errors']?&gt;&lt;/div&gt;
  &lt;?php endif // errors ?&gt;
  </code></pre>
  
  <p><strong>Here is the JS</strong></p>
  
  <pre><code>var stripeResponseHandler = function(status, response) {
    var $form = $('#cart-payment-form');
    console.log(response);
    if (response.error) {
      // Show the errors on the form
      $form.find('.payment-errors').text(response.error.message);
      $form.find('button').prop('disabled', false);
    } else {
      // token contains id, last4, and card type
      var token = response.id;
      // Insert the token into the form so it gets submitted to the server
      $form.append($('&lt;input type="hidden" name="stripeToken" /&gt;').val(token));
      // and submit
      $form.get(0).submit();
    }
  };
  
  $('#cart-payment-form').submit(function(event) {
    var $form = $(this);
  
    // Disable the submit button to prevent repeated clicks
    $form.find('button').prop('disabled', true);
  
    Stripe.card.createToken($form, stripeResponseHandler);
  
    // Prevent the form from submitting with the default action
    return false;
  });
  
  $('#thank-you').dialog({
    height: 140,
    modal: true
  });
  </code></pre>
  
  <p><strong>Here is my PHP:</strong></p>
  
  <pre><code>$cart_stripe_secret_key = get_option("cart_stripe_secret_key");
  Stripe::setApiKey($cart_stripe_secret_key);
  
  $token = $_POST['stripeToken'];
  
  try
  {
      $charge = Stripe_Charge::create(array(
      "amount" =&gt; $totalCharge*100, // amount in cents, again
      "currency" =&gt; "usd",
      "card" =&gt; $token,
      "description" =&gt; $_POST['surgecart_email']
  ));
  }
  catch(Stripe_CardError $e)
  {
      $_POST['cart_errors'] = "Whoops! There was a problem with your card. Try again?";
  return FALSE;
  }
  
  $_POST['cart_errors'] = "Thank you for your order!";
  </code></pre>