Unable to get customer details from APP_SUBSCRIPTIONS_UPDATE webhook response

Unable to get customer details from APP_SUBSCRIPTIONS_UPDATE webhook response

ChandrakanthTV
Shopify Partner
1 0 0

Hi,

 

We are working on shopify app development and implemented billing API. 

 

in index.js file i have added the below code after  shopify.auth.callback(),

 

 async (req, res, next) => {
  const plans = Object.keys(billingConfig);
    const session = res.locals.shopify.session;
    const hasPayment = await shopify.api.billing.check({
      session,
      plans: plans,
      isTest: true,
    });

    if (hasPayment) {
      next();
    } else {
      res.redirect(
        await shopify.api.billing.request({
          session,
          plan: plans[0],
          isTest: true,
        }),
      );
    }
  },
and in app gdpr.js  file we have added the below code

 

  APP_SUBSCRIPTIONS_UPDATE: {
    deliveryMethod: DeliveryMethod.Http,
    callbackUrl: "/api/webhooks",
    callback: async (topic, shop, body, webhookId) => {
      const payload = JSON.parse(body);
        console.log(shop, "shop");
      console.log(payload, "payload");
     //Implemented post method to send the data to our server using API
    }
  }
and we are getting below response in our server API 

{
shop: '{shop}.myshopify.com',
payload: {
app_subscription: {
admin_graphql_api_id: 'gid://shopify/AppSubscription/29910434089',
 name: 'Enterprise',
 status: 'ACTIVE',
 admin_graphql_api_shop_id: 'gid://shopify/Shop/75939283241',
created_at: '2023-07-14T08:09:11-04:00',
updated_at: '2023-07-14T08:09:39-04:00',
currency: 'USD',
 capped_amount: null
}
 }
 }

After getting the APP_SUBSCRIPTIONS_UPDATE webhook response, we want to get the customer details using the above response in node JS. We have gone through this link shop (shopify.dev) and did not find how to get the customer details.

 

Please help us in fixing this ASAP.

 

Regards,

Chandrakanth S

Replies 0 (0)