#derin_webhooks
1 messages · Page 1 of 1 (latest)
👋 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/1297767602050826280
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- derin_webhooks, 26 minutes ago, 13 messages
Can you share the request ID (req_xxx) of the error? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
const createRefund = async (req, res, next) => {
const { paymentIntentId, bookId } = req.body;
try {
const book = await Book.findById(bookId);
if (!book) {
return res
.status(404)
.json({ success: false, message: "Book not found" });
}
const refundAmount = book.price * 100;
const refund = await stripe.refunds.create({
payment_intent: paymentIntentId,
amount: refundAmount,
});
res.status(200).json({ success: true, refund });
} catch (error) {
console.error("Error creating refund:", error);
res
.status(500)
.json({ success: false, message: "Failed to create refund" });
}
};
const webhookRefund = (req, res, next) => {
const signature = req.headers["stripe-signature"];
let event;
try {
event = stripe.webhooks.constructEvent(
req.body,
signature,
process.env.STRIPE_REFUND_WEBHOOK_TEST_SECRET
);
} catch (err) {
console.error("Webhook signature verification failed:", err.message);
return res.status(400).send(Webhook Error: ${err.message});
}
if (event.type === "charge.refunded") {
const refund = event.data.object;
if (refund.status === "succeeded") {
const paymentIntentId = refund.payment_intent;
const { bookId } = req.body;
Purchase.findOneAndUpdate(
{ paymentIntentId, book: bookId },
{ refunded: true }
)
.then(() => {
console.log("Purchase marked as refunded");
})
.catch((err) => {
console.error("Error updating refund status:", err);
});
}
}
{
"error": {
"message": "Refund amount ($9.00) is greater than unrefunded amount on charge ($4.53)",
"param": "amount",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_oPUhwwsLZhnN3M?t=1729481678",
"type": "invalid_request_error"
}
}
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
The charge amount of pi_3QCC1kHloKxPxF5L0QjRjiss was CAD 22.53. There were multiple refunds performed on this Payment Intent:
- [2024-10-21 03:11:50 UTC] CAD 9.00 was refunded in https://dashboard.stripe.com/test/logs/req_AOseH5N1U9COP5 - remaining balance for refund was: (22.53-9) = 13.53 CAD
- [2024-10-21 03:17:31 UTC] CAD 9.00 was refunded in https://dashboard.stripe.com/test/logs/req_7jD8PsbTdP3AsE - remaining balance was (13.53 - 9) = 4.53 CAD
This pi_3QCC1kHloKxPxF5L0QjRjiss only left with CAD 4.53 to refund, which was fewer than the refunded amount of CAD 9.00 in https://dashboard.stripe.com/test/logs/req_oPUhwwsLZhnN3M that was made on 2024-10-21 03:34:38 UTC
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
In https://dashboard.stripe.com/test/events/evt_3QCC1kHloKxPxF5L0GQJWCLn, amount_refunded has indicated the refund amount so far. The total refund amounts that added up from each refund request shouldn't be more than the total charge amount
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Thank you so much River. This explanation is satisfactory. The problem is that I am not seeing the details on the dashboard. I am working on testing mode so i'll need to adjust the frontend codes. Thanks a million once again.
The problem I am having is that even though the create is been created an the refund is taking place. The dashboard is still returning an error response. HTTP status code
404 (Not Found)
{
"status": "fail",
"message": "Can't find /api/webhook-refund on this server"
}
Okay, thank you. The request ID is "evt_3QCDFeHloKxPxF5L1kjLEl8X"
This is the webhook event ID. and the event wasn't delievered successfully because your server returned 404
Do you mean the webhook ID
Looks like the endpoint https://api.thewordthatsuits.com/api/webhook-refund isn't available. I'd suggest you to work with your engineer and host provider to ensure this endpoint is accessible.
Thank you so very much. I have identified my error. The endpoint URL is wrong. I will fix that and test again. Thanks a million. I really appreciate your support.