#itaied - payment intent source

1 messages · Page 1 of 1 (latest)

open bolt
#

Good question. Checking in to it. Are you listening for subscription payments in another webhook or are you trying to do both in one event handler?

fallow wraith
#

I'm doing it in the same event handler. My customers can both subscribe and one time purchase. I'm using the built-in checkout session, but it's not enough to listen to checkout.session.completed as capture_method of type manual require listening to payment_intent.amount_capturable_updated

open bolt
fallow wraith
#

This field won't be black only for subscriptions?

open bolt
#

Good point. It will also be populated if you create one-off invoices

#

So you may want to retrieve the invoice and check that it has a subscription ID in its subscription field

#

Also depending on what you are doing, you may want to check the invoice's billing_reason field to see if it is for a subscription update/cycle/creation

fallow wraith
#

OK I see.
It feels a bit of a hassle, do you think there is a better implementation path for what I'm trying to do?

open bolt
#

Can you tell me a bit more about what you are trying to do here? So right now are you just trying to differentiate between one-off payments and your subscription payments via these webhook events?

fallow wraith
#

yes, while also enabling manual capture (hold-capture later) and using the built-in checkout session pages

open bolt
#

If those are all of your scenarios, you can just check that invoice field. If all of your payments are a one off manual payment or a subscription payment, that will successfully tell the difference between the two

#

Though actually in that case, you can just process invoice.paid events for your subscription payments and listen to a payment_intent event for the manual payments (checking exactly which event that should be)

#

payment_intent.amount_capturable_updated

fallow wraith
#

ok I got it. thank you for your support

fallow wraith
#

just sharing a thought here, I would like to hear your thoughts @open bolt .
I can listen for subscriptions using checkout.session.completed and verifying their event.data.object.mode is subscription. Right?
If a checkout session of mode subscription succeeded, then it's done, there is no pending state or something like that

open bolt
#

Correct, you can also do that for the first payment. I was thinking first payment + subscription cycles when I said invoice.paid

fallow wraith
#

yes but I would like to keep it as lean as possible, and I think I can avoid listening to invoice.paid events

open bolt
#

Of course, whatever works for you