#niladri-sub-webhoks

1 messages · Page 1 of 1 (latest)

steel night
#

For payment_intent.succeeded
You don't listen to that for subs and Invoices, you listed to invoice.paid

onyx nimbus
#

I see. Let me check that

#

So inside the response, this one conveys it's a subscription?
"type": "subscription"

#

It's pretty nested, do I look for this or something else?

#

Or do I just look for this - "subscription": "sub_1KRg6MKJDNSNdeFgvxqN9Jy4"?

#

There's also this - "billing_reason": "subscription_create"

#

@steel night what's the most robust method to check?

steel night
#

well you're looking at a subscription event there, which is why it says type: subscription

#

just clarifying, there are multiple event types

some for invoice.* and others for customer.subscription.*

#

you can use either one, depends on which event you want to listen to

onyx nimbus
#

Yeah, but I can get invoice.paid for both manual invoices and subscriptions.
What should I check for in this response to know the difference?

#

@steel night Do I look for this key pair - "billing_reason": "subscription_create"
Or some other one?
As in what would be the most robust key to look for?

steel night
#

What should I check for in this response to know the difference?
[
an invoice relating to a sub has subscription: sub_123 field on it

onyx nimbus
#

cool, thanks!

#

One more thing, how do I know if the user is paying for the next cycle and that it is not a creation?

#

@steel night

hearty bramble
#

Sorry @steel night had to step away, but I can help! You can check if a user is paying for an invoice that was AFTER creation if billing_reason is subscription_update or subscription_cycle