Extracting next available order number from a payment module.

Open to all! Ask other shopowners for help.
Post Reply
Yahalimu
Member
Posts: 29
Joined: Mon Oct 26, 2020 1:27 pm
Phoenix Version: v1.0.5.0
Has thanked: 4 times
Been thanked: 1 time

Extracting next available order number from a payment module.

Post by Yahalimu »

Hello,
My current payment module sends a time-stamp in UTC + 3 random numbers as a transaction ID to the payment processor as the order number is not set until payment has been completed successfully..

The accountant is complaining it's hard the match the Trans-ID to order numbers.
I was thinking to send the next available order number + 3 random numbers as the Trans-ID.
This will be wrong (one or two out on the order number) if several people are completing at once but not far out.

Any ideas how can I extract the next available order number from inside a payment module?


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Extracting next available order number from a payment module.

Post by ecartz »

The way that PayPal does it: insert the order before redirecting off-site. Anything else is going to not match at least some of the time. Because if two people try to pay at the same time, both would get the same "next available order ID" unless you reserve it by inserting the order.

But if you reject that solution,

Code: Select all

$query = tep_db_query("SHOW TABLE STATUS LIKE 'orders'");
$data = $query->fetch_assoc();
echo $data['auto_increment'];
Reference: https://stackoverflow.com/q/2251463


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply