title: Redirecting Stripe to Confirmation Page After Charge
body: <p>I am unable to redirect to a confirmation page after stripe checkout. Things break with the code below. Things work without error if I remove the header part.  The charge posts either way, but everything stays on the checkout page no matter what.  Am I doing something obviously wrong?</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/34758565/redirect-to-new-page-after-stripe-charge">a SO answer by one of their developers</a>, but it unfortunately doesn't work. The action strangely is not documented at all by Stripe for PHP, and support infuriatingly gave me the same exact answer of header redirect. </p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
    require_once('./config.php');
  
  // Variables passed by Ajax request. Shipping address, selection, and message attached via metadata to Stripe Tx.
    $token  = $_POST['token'];
    $price = $_POST['price'];
    $email = $_POST['email'];
    $metadata = $_POST['metadata'];
  
  
  // Post charge to Stripe with the variables.
  try {
   $customer = \Stripe\Customer::create(array(
        'email'    =&gt;  $email,
        'source'   =&gt; $token
  
    ));
  
    $charge = \Stripe\Charge::create(array(
        'customer' =&gt; $customer-&gt;id,
        'amount'   =&gt; $price,
        'currency' =&gt; 'usd',
        'metadata' =&gt; array("metadata" =&gt; $metadata)    
    ));
  
  //Ajax hears and prints in console.log that Tx successful. Then page redirects.
  echo  'success';
  
  header('Location: /success.php');
  
  } catch(Stripe\CardError $e) {
    // When the card declines.
      echo $token;
  
  }
  
  
  ?&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>var handler = StripeCheckout.configure({
      key: 'pk_test_00000000',
      image: '/logo.png',
      locale: 'auto',
      token: function(token, args) {
          // Use the token to create the charge with a server-side script.
          // You can access the token ID with `token.id`
          console.log(token)
          $.ajax({
              url: '/charge.php',
              type: 'POST',
              data: { token: token.id, email: token.email, price: price, metadata: metadata },
  
              success: function(data) {
                  if (data == 'success') {
                      console.log("Things went well for once, success!");
                      console.log(metadata);
                  } else {
                      console.log("Charge Error");
                      console.log(metadata);
  
                  }
  
              },
              error: function(data) {
                  console.log("Ajax Error");
                  console.log(data);
              }
          }); // end ajax call
      }
  });
  </code></pre>