New Shopify Certification now available: Liquid Storefronts for Theme Developers

How Billing API subscriptions work

Solved
pepebo
Tourist
3 0 1

Good day!

We're a Shopify partner and trying to get a use of Shopify Billing API, but reading the docs I don't understand a few things.

 

We were able to create a subscription using appSubscriptionCreate mutation with an interval of `EVERY_30_DAYS`, which creates a 30-days license for a user on our side when the subscription is activated.

 

The thing which is not clear to me is how can we get programatically notified about recurring charges (when 30 days period is over and the subscription renews).

Based on the documentation, I thought we should create a webhook with app_subscriptions/update topic, but after testing it out it seems that it sends notifications only about the subscription status updates?

Webhook payload examle:

 

 

{
    "app_subscription": {
        "admin_graphql_api_id": "gid://shopify/AppSubscription/XXXXX",
        "name": "Package name",
        "status": "ACTIVE",
        "admin_graphql_api_shop_id": "gid://shopify/Shop/YYYYY",
        "created_at": "2023-03-07T16:44:39+02:00",
        "updated_at": "2023-03-07T16:44:53+02:00",
        "currency": "USD",
        "capped_amount": null
    }
}

 

 


The documentation is quite limited and I would appreciate if someone could help me understand how subscriptions work and how can we make sure that the customer is succesfully charged every 30 days.

 

BR,

Peter

Accepted Solution (1)
Mancl
Shopify Partner
2 1 2

This is an accepted solution.

Shopify will not notify the application via Webhook after a merchant has made a successful payment, you will need to initiate a query to Shopify via the relevant API interface. You can search the Partner's API related documentation

View solution in original post

Replies 6 (6)
SaaSEnthu
Shopify Partner
426 58 102

Hi @pepebo,

 

Welcome to Shopify Community!

 

Few resources I found with might be helpful to you. 

Create a billing attempt

To schedule and automate the billing of subscriptions, apps need to create a billing attempt. A subscription is renewed when an app makes a billing attempt. A billing attempt represents an attempt at executing a billing cycle and charging the customer payment method for a subscription contract. A billing attempt executes a contract based on the billing cycle at the origin time if provided. Otherwise, the billing attempt is created for the current billing cycle by default. You can also create a billing attempt on a specific billing cycle.

Source: https://shopify.dev/docs/apps/subscriptions/contracts/create#step-4-create-a-billing-attempt

 

Read more:

https://shopify.dev/docs/api/admin-graphql/2023-01/queries/subscriptionbillingattempt

https://shopify.dev/docs/api/admin-graphql/2023-01/mutations/subscriptionbillingattemptcreate

 

Was the reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution
Auto post your Shopify products to Instagram, Facebook and Twitter.
App: Social Schedular
pepebo
Tourist
3 0 1

Thanks for a quick response. Appreciate it.

The links you've posted are related to subscriptionBillingAttempt which is used to manage subscriptions between a customer and a merchant.

What I'm looking for is how to manage subscriptions between an app and a merchant, so it's not exactly what I'm looking for.

Mancl
Shopify Partner
2 1 2

This is an accepted solution.

Shopify will not notify the application via Webhook after a merchant has made a successful payment, you will need to initiate a query to Shopify via the relevant API interface. You can search the Partner's API related documentation

pepebo
Tourist
3 0 1

That's what I anticipated. Thanks for verifying, Mancl.

Mancl
Shopify Partner
2 1 2

As far as I know, developers often don't actively query, but wait for notifications from webhooks for subscription status updates, or from app uninstallations. When the webhook sends a notification, the billing module within the App then modifies the merchant's usage rights. Of course, this approach has some drawbacks, but it is better than launching queries frequently.

If you find a better way to do it, feel free to share it with me.

JackL
Shopify Partner
8 0 2

Hi @Mancl @pepebo may I know what APIs that may be useful to retrieve the successful payment?
Is it using the Transactions API?