Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
Hi,
I am registered to "APP_SUBSCRIPTIONS_UPDATE" and I am trying to find out based on the payload which action actually triggered this webhook. I.e there is many actions the user may take to trigger this i.e. approve a billing plan, cancel a billing plan or manually increase the monthly capped amount for usage charges.
But I am not seeing any way based on the payload of the webhook which action triggered the webhook.
We are making some assumption based on payload.app_subscription.status but doesn't suffice for the situation we find ourselves which is
new subscription vs subscription update i.e. capped amount increase
both payloads look very similar but we want to perform an action for a new subscription which we don't want to do if a user manually increases their monthly cap.
From what I can see both return the same shape below with status active and the only difference being the capped amount is different.
17:04:45 │ remix │ {
17:04:45 │ remix │ app_subscription: {
17:04:45 │ remix │ admin_graphql_api_id: 'gid://shopify/AppSubscription/xxxxxxx',
17:04:45 │ remix │ name: 'Basic Usage',
17:04:45 │ remix │ status: 'ACTIVE',
17:04:45 │ remix │ admin_graphql_api_shop_id: 'gid://shopify/Shop/xxxxxxxx',
17:04:45 │ remix │ created_at: '2024-04-23T12:04:38-04:00',
17:04:45 │ remix │ updated_at: '2024-04-23T12:04:43-04:00',
17:04:45 │ remix │ currency: 'USD',
17:04:45 │ remix │ capped_amount: '15.0'
17:04:45 │ remix │ }
17:04:45 │ remix │ }
Is there something else we can depend on to determine which action the user performed?
Right now we destructuring the following
const { topic, shop, session, admin, payload } = await authenticate.webhook(request);
Thanks in advace.