#ahjaydog-email

1 messages · Page 1 of 1 (latest)

errant bay
#

Hello! What email is this? Is this code you've written to send an email? Or is this a Stripe email?

keen crane
#

line 6

#

whenever I put that code anywhere else (not in a webhook) it works

#

It severely seems delayed.

errant bay
#

I'm not familiar with this EmailMessage function - what is this from?

keen crane
#

what is strange too is i don't even get errors if i do anything wrong in that EmailMessage linee

errant bay
#

You're not getting any errors or exceptions at all?

keen crane
#

Like if I remove the [ ] I should get an error but i don't

#

Nope

#

@csrf_exempt -> does this have anything to do with it?

#

the webhook itself succeeds though

#

the invoice and subs get deleted though

errant bay
#

have you confirmed your code is even reaching that line? Like if you put print statements before and after the send email code are they being hit?

keen crane
#

i'll try again

#

It did not.. i'll try putting it before the try block

#

ok that worked right away.

#

However... I don't want to send an email after network retries

#

just once

#

that is why i put it in the try block to make sure there was a sub first

errant bay
#

Do you mind sharing one of the subscription or invoice IDs that you're testing this out with?

keen crane
#

yea one sec i'll make a fresh test

#

in_1LFMYFIeTJrsS1reX6XCFPqJ
sub_1LFMYFIeTJrsS1rejOaQo6zs

#

The try block runs that is what I printed for invoice and sub

#

from inside the try block

#

unless... could it be because I am cancelling and it runs another webhook I have for cancel event?

#

Actually it runs the cancel one before that

errant bay
#

I think the issue here is that you have other code somewhere in your integration that's deleting the subscription BEFORE you get to the 'stripe.Subscription.delete(subscription_id)' line in your webhook code. As a result, that line fails and bypasses the next line that send the email

keen crane
#

[27/Jun/2022 18:22:06] "POST /webhooks/stripe_failed_webhook/ HTTP/1.1" 200 0
subscription deleted
[27/Jun/2022 18:22:07] "POST /webhooks/stripe_cancel_webhook/ HTTP/1.1" 200 0
test
in_1LFMYFIeTJrsS1reX6XCFPqJ
sub_1LFMYFIeTJrsS1rejOaQo6zs
[27/Jun/2022 18:22:09] "POST /webhooks/stripe_payment_webhook/ HTTP/1.1" 200 0

errant bay
keen crane
#

right

#

i'll have to review my code again

#

thanks

errant bay
#

👍 hopefully that helps narrow it down!

keen crane
#

yea i think it does