#Harry-Webhook
1 messages · Page 1 of 1 (latest)
Hi there, you can listen to payment_method.updated events https://stripe.com/docs/api/events/types?lang=curl#event_types-payment_method.updated
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Oh awesome, I'll check that out
No problem, there's also a payment_method.automatically_updated (https://stripe.com/docs/api/events/types?lang=curl#event_types-payment_method.automatically_updated) It Occurs whenever a payment method’s details are automatically updated by the network.
Do those work differently? or does automatically_updated trigger updated?
Yes they are different, if the payment_method is updated via API, a payment_method.updated event is fired.
If the payment_method is automatically updated by the card network (i.e., the expiry date or cvv update), a payment_method.automatically_updated is fired.
Right, what about when its upaded throught Stripe Elements?
does that still trigger payment_method.updated
I don't think you can update a payment method via Stripe Elements, you need to call an PaymentMethod update API with your secret key.
I mean when you send a payment intent to the payment element
because that intent has a customer so adds it to that
No I don't think this triggers payment_method.updated event.
Right 🤔
So how do I go about getting that information async then if it's not going to trigger any events...
also looks the the API never exposes which is the default payment method unless I missed somthing?
Or can you tell me what do you plan to do with webhook event?
Sure! I try to cache some of the Stripe data - as suggested in the docs - to not fetch from the API on every request to certain endpoints so I store the default cards last 4 digits, exp month, exp year and brand in a customer's row in my DB so that I can show it on the UI with a link to the Stripe billing session to change/manage it
but all payment is originally setup by using a Payment Intent and the Checkout Element
OK, so basically you want to get the last4 digit of the payment method used in the PaymentIntent, am I right?
basically yeah
Got it
So you should listen to the payment_intent.succeeded event, and in the event handling, use the payment_method ID from the PaymentIntent object to and call PaymentMethod retrieval API to get the full PaymentMethod object, which you can find the last4, and exp data.
If I already get invoice.paid and invoice.payment_failed can I expand them to include the payment information?
Sorry I just thought of that
Sure you can do that as well
Do you know what I would have to expand on them?
Put this to the expand array ['payment_intend.payment_method']
Sorry for the typo, it's payment_intent
Don't worry just wanted to check
To expand the invoice I will have to re-request it right? I can't just expand the object I already have?
No you can't, you need to call the retrieve API