Rui
Rui

Reputation: 39

Stripe order ID to appear on Thank You page

have this stripe form:

<form action="stripe/website-setup.php" method="POST">
    <button><img src="images/stripe1.png"/></button>
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_E33MEO7Xp6p5NmiYTaCBu1AJ"
    data-amount="34895"
    data-name=".org"
    data-description="Widget"
    data-image=""
    data-locale="auto"
    data-zip-code="true"
    data-currency="usd">
  </script>
</form>

When the payment is successful, it redirects to

header('Location: /payment-success');

How can I make the order/transaction ID to appear on the /payment-success page?

Thanks.

Upvotes: 2

Views: 1330

Answers (1)

Varun Pozhath
Varun Pozhath

Reputation: 626

I have worked with stripe in an ASP.NET application. This is what I did to achieve the above mentioned scenario.

When you create a charge in stripe, the charge object has a Paid property to check if the transaction was a success. It also has an ID property which is nothing but the transaction ID You have to store the transaction ID (result.ID) in a session. The following code is c#. I am pretty sure there will be something in php to store session Variables.

After you store the transaction ID in a session variable, you have to access it in your payment-success page. Hope it helps

  try {
     //Creating a charge. Returns a charge object and stored in result
     result = service.Create(newCharge);
     if (result.Paid) {

        //store the transaction ID in Session
        Session["stripeChargeID"] = result.Id;

     }
  }

  catch(StripeException e){

     //Do something

  }

Upvotes: 1

Related Questions