Solved

Field billing_on in recurring app charge

danhho
Shopify Partner
22 1 6

hello everyone, I'm setup billing for my app with recurring plan and usage plan following docs. Now I have a response when query into "/admin/api/2023-07/recurring_application_charges.json" like this:

 

{
    "recurring_application_charge": {
        "id": xxxxxx,
        "name": "Silver",
        "price": "99.90",
        "billing_on": "2023-09-15",
        "status": "active",
        "created_at": "2023-09-14T23:41:14-04:00",
        "updated_at": "2023-09-14T23:41:42-04:00",
        "activated_on": "2023-09-15",
        "return_url": "xxxx",
        "test": true,
        "cancelled_on": null,
        "trial_days": 0,
        "trial_ends_on": "2023-09-15",
        "api_client_id": 53565095937,
        "decorated_return_url": "xxxx",
        "capped_amount": "500.00",
        "balance_used": 1.0,
        "balance_remaining": 499.0,
        "risk_level": 0.0,
        "currency": "USD"
    }
}

I have couple question:
1. Field billing_on will update if shopify charge success in last month and reset balance_used to 0?
Example:  my current billing_on is 2023-09-05, after 30 days pass and they are charged merchant store, now billing_on will update to  2023-10-05?
2. When billing_on field  update, can it trigger app_subscription_update webhook? (I see in docs say webhook will trigger when subscription update or cancel)

Because I cannot but test or simulate recurring charge in my dev store, so I want to make sure clarify above problem when shopify after charge

Thanks in advanced.
Accepted Solution (1)

Liam
Shopify Staff
2731 301 779

This is an accepted solution.

Hi Danhho,

  1. Yes, the billing_on field will be updated to the next billing date after a successful charge. It is essentially the start date of the next billing cycle. The balance_used field also resets to 0 at the start of each new billing cycle.

  2. Unfortunately, the app_subscription_update webhook does not get triggered when the billing_on field updates. It only gets triggered when the subscription itself is updated or cancelled.

You could potentially set up a task in your app to check the billing_on date regularly, such as daily, and take action when the date changes.

 

Also, it's worth noting that Shopify does not provide a way to simulate recurring charges in a development store. So, you would need to use a real transaction to test the billing cycle.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

Liam
Shopify Staff
2731 301 779

This is an accepted solution.

Hi Danhho,

  1. Yes, the billing_on field will be updated to the next billing date after a successful charge. It is essentially the start date of the next billing cycle. The balance_used field also resets to 0 at the start of each new billing cycle.

  2. Unfortunately, the app_subscription_update webhook does not get triggered when the billing_on field updates. It only gets triggered when the subscription itself is updated or cancelled.

You could potentially set up a task in your app to check the billing_on date regularly, such as daily, and take action when the date changes.

 

Also, it's worth noting that Shopify does not provide a way to simulate recurring charges in a development store. So, you would need to use a real transaction to test the billing cycle.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

danhho
Shopify Partner
22 1 6

Thanks for your comfirm @Liam, it nearly close to clarify

 

You could potentially set up a task in your app to check the billing_on date regularly, such as daily, and take action when the date changes.

Your mean is we must set up a schedule function in my app and run per days to check and update billing_on in my DB. Is it right?

zksumon
Shopify Partner
9 0 1

Hi Liam ,

that was an excellent answer.

will the app_subscription_update get triggered if status changes to "FROGEN" and "ACTIVE" from "FROGEN" ?