#dr_ironbeard
1 messages ยท Page 1 of 1 (latest)
Not sure when it showed up. We started using it about 6 weeks ago.
Gotcha, should I still expect to receive payment_method.automatically_updated events too?
https://stripe.com/docs/upgrades#2020-08-27
Deprecate the payment_method.card_automatically_updated webhook in favor of payment_method.automatically_updated.
or just change the name of the event?
payment_method.card_automatically_updated event is the old one
What API version is your account on?
hmm one sec
The one that generated the event
Can you share the event ID?
Thanks, checking..
np, thank you!
Can you provide more details about where you're seeing payment_method.card_automatically_updated event type on your webhook?
Like are you seeing it in the raw content of the Event or after you construct event by using stripe.Event.construct_Event or equivalent function from some other SDK?
One second
Well, I see it here:
But..the event itself says "type": "payment_method.automatically_updated" which is what it should be using in my code
I am using the Python lib to construct the event
Hi there ๐ I'm helping my teammate look into this. If you scroll down on the right side of that page, near the bottom of the request body what do you see provided for type?
Okay, that matches what I would have expected us to send. Can you share the code snippet from your Event handler that is breaking when receiving this type of Event?
I think the Python stripe lib is 6.0.0
Sorry, taking a moment to get this
All good
Actually, I think the event is working as expected..
def setup(self, request, *args, **kwargs):
# Retrieve event
event = stripe.Webhook.construct_event(
payload=request.body,
sig_header=request.META['HTTP_STRIPE_SIGNATURE'],
secret=settings.STRIPE_WEBHOOK_SECRET_KEY,
)
self.stripe_obj = event.data.object
self.method_name = event.type.replace('.', '_')
# Get the relevant User
if event.type == 'customer.deleted':
q = Q(email=self.stripe_obj.email)
elif self.stripe_obj.object == 'customer':
q = Q(customer__id=self.stripe_obj.id)
elif ('customer' in self.stripe_obj) and (self.stripe_obj.customer):
q = Q(customer__id=self.stripe_obj.customer)
else:
q = Q(email=None)
try:
self.user = get_user_model().objects.get(q)
except get_user_model().DoesNotExist:
self.user = None
def post(self, request: HttpRequest) -> HttpResponse:
"""Fetch webhook event and act on it."""
try:
getattr(self, self.method_name)()
response = HttpResponse('Success!', status=200)
except Exception as e:
response = HttpResponse(f'Error! {e}', status=500)
return response
I put it in a logging statement for the method_name, which correctly printed payment_method_automatically_updated (which is the name of the method defined to handle this event).
So, must have been something else. The error report I got isn't pointing to the exact line of code, which is strange to me
and when I manually run the event handler (e.g. the payment_method_automatically_updated method) in a shell with the resent event, everything is fine ๐คท
Gotcha, glad to hear that Event type is coming through as expected! The errors we're seeing returned to us aren't too specific about what is going wrong either. I'm seeing a 500 status that is giving me the impression something is crashing or erroring out within the Event handler, but I don't see specifics on why it's crashing.
Yeah, it's not giving a great message: if you look in the post method above, it just tries to run the method then returns the error message.
According to the webhook dashboard, the error message was "[Errno 32] Broken pipe," so I think it's some Django thing. Strange that it would have happened multiple times, though.
or the webserver went down for some reason. It does seem to continue happening when I resend the event, though.
Oh wait, it went through with 200 at some point: evt_1Nkn8kCoTIfwbn28Bum9lZK7
Welp, I guess everythings working as expected from your end. I'm not too worried about it unless it happens again.
I think I was mislead at first because the webhook dashboard looks like its sending card_automatically_updated, but that's not a huge deal
Thanks for your help ๐
Any time, happy to help! I agree the dashboard showing different type names is confusing ๐