#mh_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/1286068555535876137
๐ 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.
- mh_code, 7 hours ago, 71 messages
- mh_invoicing-emails, 1 day ago, 18 messages
- mh_webhooks, 2 days ago, 29 messages
- mh_code, 2 days ago, 53 messages
- mh_webhooks, 2 days ago, 61 messages
Hi there
hey .good evening
I'm looking at your logs and I found examples of checkout.session.completed and payment_intent.succeeded events that were successfully sent to your endpoint
pls see this screen shot attatched .
iam seeing only the checkout.session.expired event
Click on "load more" on the left
Also, at the bottom of the screenshot you sent, i see a couple of checkout.session.completed events and a payment_intent.succeeded event
i know why.beause the recovery Url was sent in the email. and the customer didnt pay the payment yet ,so will not find the other two events until the user click on pay.right?
one other question pls. iam Receiving duplicate checkout.session.expired events .and i think that my code is ok, is it possible that its happening from stripe? how to fix?
case 'checkout.session.expired':
const expiredSession = event.data.object;
const sessionId = expiredSession.id; // Extract sessionId here
const email = expiredSession.metadata?.email || expiredSession.customer_details?.email;
const recoveryUrl = expiredSession.after_expiration?.recovery?.url;
// Fetch the customer metadata to retrieve promotional consent
const customer = await stripe.customers.retrieve(expiredSession.customer);
const promotionalConsent = customer.metadata?.promotionalConsent;
const recipientName = customer.metadata?.name || 'Valued Customer';
// Check if the values are undefined or null
console.log('email:', email);
console.log('recoveryUrl:', recoveryUrl);
console.log('promotionalConsent:', promotionalConsent);
if (!email || !recoveryUrl) {
return; // Ensure response is sent
}
// Check if email was already sent and send only if not
const alreadySent = await hasSentRecoveryEmailToCustomer(email, sessionId);
if (!alreadySent && promotionalConsent === 'true') {
await sendRecoveryEmail(email, recoveryUrl, recipientName, sessionId);
}
// console.log(`Recovery URL for ${email}: ${recoveryUrl}`);
// console.log('Promotional Consent:', promotionalConsent);
// res.json({ received: true });headers already sent error
break;
i know why.beause the recovery Url was sent in the email. and the customer didnt pay the payment yet ,so will not find the other two events until the user click on pay.right?
I don't understand this exactly. Can you rephrase?
Which event did you receive more than once?
duplicate checkout.session.expired event
Right, but which exact event. Can you share an ID?
i have added nodemailer to send an email that contain the recoveryURL to the user if he left the session and didnt complete it. thats why iam seeing only the checkout.session.expired
sure.just a minute
evt_1Q0UoZAcO1eKClr1ruUOM8uJ
evt_1Q0Uo3AcO1eKClr1lmzHtrqY
Right, so checkout.session.completed events (and payment_intent.succeeded) are only triggered if a customer completes a payment
i forgot that ๐
So just to be clear, you're saying you received evt_1Q0UoZAcO1eKClr1ruUOM8uJ twice?
actually i received those two events when i left the session (testing)
So you received evt_1Q0UoZAcO1eKClr1ruUOM8uJ once and evt_1Q0Uo3AcO1eKClr1lmzHtrqY once?
yes
Both of these events are checkout.session.expired events but they correspond to two different Checkout Sessions so it's not unusual
but i only left the session once .
What do you mean by "only left the session"?
ii clicked on pay to go to checkout page and then went back to trigger the session.expired event to test the RecoveryEmail. but i saw those two events on stripe . after each other
I'm still a little lost
Each of these events was triggered after some Node code explicitly canceled a Checkout Session
evt_1Q0UoZAcO1eKClr1ruUOM8uJ - https://dashboard.stripe.com/test/logs/req_k0bffsFKjyDGN9
evt_1Q0Uo3AcO1eKClr1lmzHtrqY - https://dashboard.stripe.com/test/logs/req_wMutpKCuNRaTut
ok. i understand .
i will try to figure out what is wrong . maybe i forgot to send a respones aftre this event, and stripe is retrying the event .
it will be allright.
I'm not sure what you mean by retry. I see both of the events above were sent to your endpoint and your endpoint acknowledged both
I think the key here is that these are two separate Checkout Sessions. Since both were expired, it makes sense that your handler code sent two emails
i recieved only one email , thats mean the session.expired event were triggered once . and the weired thing that i recieved 2 events on stripe.
iam saving the session id to the DB . so i can only receive one email per session
thanks for your time today RoadRunner
i will try to search for a solution tomorrow.
I recommend looking at any logs you have for your webhook handler code. From what I can tell, we sent two events and both were received. The Session IDs were:
cs_test_b1q038gJY9rTvlwaAgwN8t6r8LZTJWUHxTLYE6faFuwt9DUiPSYEgUyI2g
cs_test_b1GhR5Jcmn4WlAk2BdC47bIDPcRf9dgMfl70qYfB8gJOIr5qn2kxUX5BpD