#jtishler-invoice-trial
1 messages · Page 1 of 1 (latest)
👋
stepping in here as hmunoz had to step away
Taking a look
Hmm yeah you will need to listen for a payment method attachment in this case if you want to reliably know a card was added
what event is that? and is there a way to distinguish subscriptions from one time purchases?
You only are about this for Subs I would assume
In that case, yeah the payment_method.attached won't be the best event
What you could do instead would be to listen for customer.subscription.updated
That should fire when the default_payment_method is no longer null due to the SetupIntent confirmation
gotcha
that event seemed pretty broad from the documentation and there wasnt a lot there on how to distinguish specific scenarios
such as first purchase from renewal
That event will contain the full details of the Subscription object (https://stripe.com/docs/api/subscriptions/object) each time and it will include a previous_attributes hash which will indicate what changed.
For renewal versus first purchase you would look at the status and the previous_attributes to determine that.
ah i see - thanks that's very helpful!