title: PHP Stripe get the transaction id after successful purchase
body: <p>I'm trying to get the transaction ID after the purchase, but it returns empty on thankyou page</p>
  
  <p>order.php</p>
  
  <pre><code>&lt;?php
  \Stripe\Stripe::setApiKey('&lt;test token&gt;');
  
  $amount = 100;
  $card = $_POST['stripeToken'];
  
  // Create a Customer
  $customer = \Stripe\Customer::create(array(
      "source" =&gt; $card,
      "email" =&gt; $email,
      "description" =&gt; "Example description")
  );
  
  // Charge the Customer instead of the card
  $charge = \Stripe\Charge::create(array(
      "amount" =&gt; 100,
      "currency" =&gt; "usd",
      "customer" =&gt; $customer-&gt;id)
  );
  
  // Save the billing info
  set_billing([
      'customer_id' =&gt; $customer-&gt;id,
      'address' =&gt; $address,
      'address2' =&gt; $address2,
      'city' =&gt; $city,
      'state' =&gt; $state,
      'country' =&gt; $country,
      'postal' =&gt; $postal,
      'trans_id' =&gt; $charge-&gt;id // Save the transaction id
  ]);
  
  function set_billing($fields = array())
  {
      $bdate = time();
  
      $query = "INSERT INTO billings (
          customer_id, address, address2, city,
          state, postal, country, billing_date, trans_id
      ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
  
      $stmt = $GLOBALS['sqlConnection']-&gt;prepare($query);
      $stmt-&gt;bind_param(
          'sssssssis', $fields['customer_id'], $fields['address'], $fields['address2'], $fields['city'], $fields['state'], $fields['postal'], $fields['country'], $bdate, $fields['trans_id']);
      $stmt-&gt;execute();
  }
  
  // If successful, redirect to thank you page
  header('Location: /thankyou.php?id=' . $user_id);
  exit;
  </code></pre>
  
  <p>thankyou.php</p>
  
  <pre><code>&lt;?php
  $s = $sql-&gt;prepare('SELECT trans_id FROM billings WHERE user_id = ?');
  $s-&gt;bind_param('i', $_GET['id']);
  $s-&gt;execute();
  $s-&gt;bind_result($trans_id);
  $s-&gt;fetch();
  ?&gt;
  
  &lt;ul&gt;
      &lt;li&gt;Transaction id: &lt;?php echo $trans_id ?&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Is there any problem with my code?</p>