Balance used is zero when requesting it on last billing cycle day

Hi there,

on usage based subscriptions, when requesting the ‘balance used’ amount on the last day of the billing cycle, it often returns zero although the installation has been charged previously on that billing cycle.

This is something that only happens on the last day of the billing cycle. It seems that the balance used resets too early.

Please could you take a look?

Hey @sinuhe! The fact that this only occurs on the last day is useful.

Could you share the x-request-id from one affected API response? That gives us the context needed to trace the call. If you do not have the header logged, share the operation or query name and exact UTC timestamp instead, and we should be able to locate the request in our logs

balanceUsed is scoped to usage records for the interval, while currentPeriodEnd provides the exact period-ending timestamp. The request details will let us compare the response with that boundary and check whether the same usage line item still returned usageRecords when balanceUsed was zero.

Thanks in advance!

Hi @Donal-Shopify ,

sure:

f27cd247-e6b1-469c-99b5-33642100ce16-1787814000

This is an x-request-id that gathers the current subscription in the last day of the billing cycle (about 6 hours before the cycle ends). It returns zero ‘balance used’, but it actually is 39.99$:

This is just an example, but it happens always with all stores. This is weird, because y we cannot trust on Shopify data on that last billing cycle day, we cannot generate charges, so we are loosing possible created charges with a probability of 1/30…

Please could you take a look?

Thanks for the follow-up with the request ID @sinuhe! It let me trace the exact request, which completed successfully with no API errors. Internal billing records also confirm the two usage charges totaling $39.99 against the $39.99 cap, so the usage was charged and recorded as expected. The request ran about eight hours before that subscription’s recorded billing time, so it wasn’t made after the period had already rolled over.

I’ve raised this with the relevant team to determine whether the zero value on the last billing-cycle day is expected or an issue with how balanceUsed is calculated.

One thing that would help me narrow it down further is the currentPeriodEnd value returned in that same response (the response to the query is not visible in our logs). If it still showed the Aug 27 boundary while balanceUsed returned 0, the two fields would be disagreeing. If it had already advanced to the next cycle, the zero would line up with the interval rolling forward.

In any case, I’ll follow up here once I hear back from the App Billing team internally - thanks again!