This is a very weird situation I am in. Here is the scenario: After a payment is complete, the user lands on the thankyou page of my site. Here there are some functions on the page that do the following:
- Send order email.
- Store data in the DB of the payment
- Add some marketing pixels so that the sale is tracked.
The problem I am facing is:
- After the redirect from the payment gateway I get the transaction_id from the url.
- I use it to get the sales order details and send out the order email.
- While showing the pixels, the sales order details is gone. the variable dont exist no more I tried to get the transaction ID and get the details from the DB again but with no luck.
Now after I do a refresh on this page, everything works fine. Just like it should.
My question is:
- Why is it when its redirected from the gateway, this variable is un initialized?
- Why does it work after a manual refresh (Considering it shouldn't if there was a problem in my code)?
Thanks.