FROM CACHE - en_header

RecurringApplicationChargeId in GraphQL api

zanzaf
Shopify Partner
4 0 2

I'm using Partner API for internal reporting. When creating a usage charge, Shopify's Rest API url endpoint requires a recurring_application_charge_id, however, when fetching the same usage charge record via the GraphQL Api, I don't see any way to fetch the associated recurring application charge id in UsageChargeApplied GraphQL API query.

Is there any workaround this? I need to be able to link the usage charge to the recurring subscription.

Reply 1 (1)
Flafi87
Shopify Partner
11 1 3

Hello,

When you create the recurring application charge you are getting the Charge ID as a response. At least I am doing it like that. query is the appsubscriptionCreate mutation

For creating usageCharge you will need the appUsageChargeId which is also there in the response.

 

const response = await client.query({
    data: query,
  });
  const {
      confirmationUrl,
      appSubscription: {lineItems},
      appSubscription: {id},
    } = response.body.data.appSubscriptionCreate;
  const appUsageChargeId = lineItems[0].id;
  const chargeID = id.split("/")[4];