
Originally Posted by
carlwhat
get the next order number from the orders table, use that, and move on.
i like the method in
this post.
best.
When I try to grab the orders_id, it is empty.
Here's the sequence I have implemented so far:
In the before_process method, I generate an iframe for the payment interface.
I've attempted to capture the order ID in the after_order_create method, which seems to be the logical place to get the latest order ID. This is the code snippet I've used:
Code:
public function after_order_create($insert_id) {
global $db;
// Logging the order ID for debugging
file_log("after_order_create called. Order ID: {$insert_id}");
// Prepare the webhook data with the order ID
$webhookData = [
'amount' => $amount,
'currency' => $currency,
'externalUserId' => $insert_id,
];
// Send the webhook with the prepared data
$this->send_webhook($webhookData);
}
I've also tried fetching the order ID directly in the webhook.php file.
I am aware that guessing the next order number is not feasible due to the risk of duplication. My concern is ensuring the after_order_create method is triggered at the correct time so I can send the order ID via the webhook without issues.
Could you advise on the proper sequence to handle this process, especially concerning the placement of the after_order_create in relation to the iframe generation in the before_process method? Is there an established best practice for this scenario that I might be overlooking?
Any insights or suggestions would be greatly appreciated, as I might be missing something obvious due to my close involvement with the project.
Bookmarks