#shoonjohn_webhooks
1 messages ยท Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- shoonjohn_code, 2 days ago, 12 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1265995925092958249
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Can you share the webhook code?
sure:
Does the code inside the switch statement run?
if (isset($checkout_session->line_items->data)) {
foreach ($checkout_session->line_items->data as $line_item) {
$productId = intval($line_item->description); // Ensure you're using the correct product identifier
$quantity = $line_item->quantity;
// Log the values for debugging
error_log("Product ID: $productId, Quantity: $quantity");
if ($productId) {
updateProductQuantity($productId, $quantity, $conn);
} else {
error_log("Invalid Product ID retrieved from line item description.");
}
}
} else {
error_log("Line items data not available in checkout session.");
}```
Then you probably need to debug the code in your updateProductQuantity function
i used to get some errors
The 2xx response is not dependent on the success of that function overall so it seems expected that you'd get a success message event if that logic doesn't run
As I said, the webhook code itself looks fine. You process the event, return a 2xx. Your custom logic is not working as you expect (you haven't shared that code)
my datebase is really simple... is there any way I can implent a easier logic. This is my first project working with a database and backend in general...
hi! I'm taking over this thread.
if you have specific questions about Stripe, I'd be happy to help.
Hey, I am trying to set up a webhook, that automaticly updates the stock in my databse... I am not receiving any errors , yet the stock wont update in my DB
I can't really help with database since this is unrelated to Stripe. but make sure to add some logs in your backend code to make sure that:
- the code is actually executed
- and see if there are any errors
I have logs in my Code and fixed some errors that were shown here...
I don't receive any errors now but the stock wont update.
like mentioned before, add some logs to your code to understand why the stock won't update. maybe that code is never executed, or maybe you have a error in your dabase query, or something else.