#Harry-Webhook

1 messages · Page 1 of 1 (latest)

sleek mirage
deft dove
#

Oh awesome, I'll check that out

sleek mirage
deft dove
sleek mirage
#

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.

deft dove
#

Right, what about when its upaded throught Stripe Elements?

#

does that still trigger payment_method.updated

sleek mirage
#

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.

deft dove
#

I mean when you send a payment intent to the payment element

#

because that intent has a customer so adds it to that

sleek mirage
#

No I don't think this triggers payment_method.updated event.

deft dove
#

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?

sleek mirage
#

Or can you tell me what do you plan to do with webhook event?

deft dove
#

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

sleek mirage
#

OK, so basically you want to get the last4 digit of the payment method used in the PaymentIntent, am I right?

deft dove
#

basically yeah

sleek mirage
#

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.

deft dove
#

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

sleek mirage
#

Sure you can do that as well

deft dove
#

Do you know what I would have to expand on them?

sleek mirage
#

Put this to the expand array ['payment_intend.payment_method']

deft dove
#

Oh awesome 😄

#

is it payment_intend or payment_intent?

sleek mirage
#

Sorry for the typo, it's payment_intent

deft dove
#

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?

sleek mirage
#

No you can't, you need to call the retrieve API

deft dove
#

👍🏼

#

Thanks again, and enjoy your day