#ironbeard-invoices
1 messages · Page 1 of 1 (latest)
hello! quick question, what is the goal of updating the Sub with the PaymentMethod here? I think I'm missing something around that
In order to set the default payment method...although my workflow actually has it being set on the Customer, not the subscription
So, yeah I suppose really what I want to do is get the PaymentMethod information once everything goes well.. using the workflow where I create a Subscription with Prices+Customer, and send the PaymentIntent client secret to the front end.
So, then I listen for events to make a local PaymentMethod and attach it to the Customer as Default PaymentMethod
then yes correct, if you're setting default_payment_method on the Subscription after the first payment has been confirmed, then yep you'd use the invoice.payment_succeeded webhook event and grab the PaymentIntent's PaymentMethod (via an expand: ) and update the Subscription
Gotcha, thanks!
So I dont want to listen to payment_intent.created since the first payment might not have been confirmed at that point?
gotcha gotcha. Thanks! 🙂
Referencing above, I was wondering why I would listen to invoice.payment_succeeded and then make a call to get the associated PaymentMethod instead of just listening for payment_method.attached? To clarify, my intention is to store the payment method ID in my database and set the payment method as a default by using Customer.modify(<id>, invoice_settings={'default_payment_method': pm.id})
Clever! That does seem like it would save a step. As long as you're seeing the payment_method.attached event firing when you're expecting it to (which I suspect you are) in your testing then this probably would be a better approach.
Gotcha, sounds good! Also, is the difference between payment_method_updated and payment_method_automatically_updated that the former happens when I use the Stripe library or Stripe dashboard, and the later is done by, say, CC comapnies who may update e.g., the zip code?
Exactly, payment_method.updated is triggered when the payment method is updated via the API. payment_method.automatically_updated is triggered when a card is updated based on information we get back from the card network (limited brands offer this, and it can only update the exp date and last 4 of the card).
https://stripe.com/docs/saving-cards#automatic-card-updates
That should hold me over for awhile, thanks!