How to test the Graphql billing API in apps?

Hello ,
Greetings!

This is the first time we are building an app for Shopify.

We have created a Custom app for Shopify Admin to implement our functionality to ease the returns of the items by customers.
We wanted to make this a paid app when we publish the app.
When we want to call appSubscriptionCreate API to setup the billing plan, it is giving an error. It seems this can be called only by public app.
Can anyone please let me know how to test the billing feature, preferably before publishing the app?

Thanks in advance,
Srinivasa Pradeep

Hi @Srinivasa_Pradeep

You can try pass testSubscription: true in AppSubscriptionCreate API.

Though I’m not sure if the error you are getting is because of public app but please do you mind sharing your error in detail?

Hi @Srinivasa_Pradeep, are you getting the following error when you call AppSubscriptionCreate?

Apps without a public distribution cannot use the Billing API

If so, the following should fix it:

  1. Open up your app in the Partner admin
  2. Click on Distribution on the left side
  3. Choose Public distribution and click on Select

At that point you should be able to access the AppSubscriptionCreate mutation with your app, even though it’s not published on the app store yet.

Thanks for the input. This is possible for a new app. I will try with a new app.
However for existing custom app, is there any way to test the billing api?

Hi @kinngh @Daniel_Ablestar
This mean on development we can’t use billing API?

Incorrect. This means that your development app should be a Public App that you don’t submit to the App Store. This allows you to build and test the Billing API

but this is my dev app, not public app to be submit

Hi,

I’ve struggling these issue for days,

I’ve created (few times) an app and marked it as a public distribution so now it’s on “Draft” mode. Even though, I still keep getting this error saying:

“Apps without a public distribution cannot use the Billing API”

When using the GraphiQL tool, I do manage to call appSubscriptionCreate mutation.

Please help!

Hey I was able to create test subscription by passing the test argument to the appSubscriptionCreate mutation (api + docs)

mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!, $test: Boolean) {
  appSubscriptionCreate(
    name: $name
    returnUrl: $returnUrl
    lineItems: $lineItems
    test: $test
  ) {
    userErrors {
      field
      message
    }
    appSubscription {
      id
      status
    }
    confirmationUrl
  }
}