Usage charge stopped working after shop changed plan [GRAPHQL]

Solved
Highlighted
Tourist
9 3 2

Hi, 

I get a very generic error message when trying to generate a usage charge on a shop after it changed plan. 

{
  "data": {
    "appUsageRecordCreate": {
      "userErrors": [
        {
          "field": null,
          "message": "Failed to create usage charge"
        }
      ],
      "appUsageRecord": null
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 1000.0,
        "currentlyAvailable": 990,
        "restoreRate": 50.0
      }
    }
  }
}

Here is the timeline of the events

  • morning : usage charge are working for the shop
  • 1:58pm : shop change plan
  • 1:58pm to 3:01pm: I am able to emit multiple usage charges
  • after 3:01pm: unable to emit usage charge

I am still able to emit usage charge for other shops.

I am not the only one with the problem, but all the other thread are not solved.

 

I have provided the correct app_subscription_line_item_id

Here is the GraphQL request

 mutation($subcription_line_item_id: ID!, $description: String!, $amount: Decimal!) {
        appUsageRecordCreate(
          subscriptionLineItemId: $subcription_line_item_id
          description: $description,
          price:{ amount: $amount, currencyCode: USD}
        ) {
          userErrors {
            field
            message
          }
          appUsageRecord {
            id
          }
        }
      }

 

Thank you

0 Likes
Tourist
9 3 2

This is an accepted solution.

Alright so I got the answer. (I use the 2020-04 GraphQL APIs)

TLDR: Shopify usage balance of your last plan follows on the new plan even if AppSubscription information says that the balance is 0$. Solution: you have to wait until the plan resets or make the merchant increase its cap amount again.

Long version:

It is because I was exceeding the cap amount even if it does not says so. 

Here is what happened chronologically

  • I had a merchant with a cap amount of 99$ [normal]
  • I charged the full balance of 99$ [normal]
  • I tried to charge above the 99$ cap amount, I received a "you have exceeded cap amount" response [normal]
  • The merchant change to a new plan with an increased the cap amount of 199$ [normal]
  • I get information about the new plan. The balance is 0$ on 199$ [NOT NORMAL - BUG in Shopify API]
    • At this point what the API does not says it, but the balance is 99$ on 199$ in reality. In the Shopify backend, the balance of the last plan is following on the new plan. The balance should be 99$ on 199$. So really I only just had a 100$ extra dollars to charge. 
  • I was able to charge 99.45$ dollars. The balance returned by GraphQL was 98.45$ on 199$ [NOT NORMAL - BUG in Shopify API]
    • In reality the balance was 198.45$ on 199$.
  • I tried to charge 0.85$ more (98.45 + 0.85$ = 99.30$ [or 199.30$ in reality]). I get a general "Failed to create usage charge". [NOT NORMAL - BUG in Shopify API]
    • This request should have returned the usual "you have exceeded cap amount" response

Solution: 

You have to wait until plan reset date or make the merchant increase its cap amount again. 

 

** sight **

0 Likes