#mh_webhooks

1 messages ยท Page 1 of 1 (latest)

sacred breachBOT
#

๐Ÿ‘‹ 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.

plush wedge
#

Hi there

wide pewter
#

hey .good evening

plush wedge
#

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

wide pewter
#

pls see this screen shot attatched .

#

iam seeing only the checkout.session.expired event

plush wedge
#

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

wide pewter
#

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;
plush wedge
#

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?

wide pewter
#

duplicate checkout.session.expired event

plush wedge
#

Right, but which exact event. Can you share an ID?

wide pewter
#

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

plush wedge
plush wedge
#

So just to be clear, you're saying you received evt_1Q0UoZAcO1eKClr1ruUOM8uJ twice?

wide pewter
#

actually i received those two events when i left the session (testing)

plush wedge
#

So you received evt_1Q0UoZAcO1eKClr1ruUOM8uJ once and evt_1Q0Uo3AcO1eKClr1lmzHtrqY once?

wide pewter
#

yes

plush wedge
#

Both of these events are checkout.session.expired events but they correspond to two different Checkout Sessions so it's not unusual

wide pewter
#

but i only left the session once .

plush wedge
#

What do you mean by "only left the session"?

wide pewter
#

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

plush wedge
#

I'm still a little lost

#

Each of these events was triggered after some Node code explicitly canceled a Checkout Session

wide pewter
#

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.

plush wedge
#

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

wide pewter
#

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.

plush wedge
#

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

wide pewter
#

you are the best . i will take a look

#

bye