Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Get start and end date of current billing cycle

Solved

Get start and end date of current billing cycle

noah_haub
Shopify Partner
25 2 5

Hi,

 

Im currently building an App that charges the user based on how many orders they get in one billing cycle.
To do that I need to know how many orders they received during the current billing cycle.

My thinking is this: Get the start and end date of the current billing cycle -> Get the orders during these dates.

 

But I do not know how to get the start and end date of the current billing cycle.

Is there some way to do this?

Would really appreciate your help.

Kind regards,

Noah

Accepted Solution (1)
noah_haub
Shopify Partner
25 2 5

This is an accepted solution.

I have sort of found a workaround.

What I am doing to get the start and end date of the current billing cycle is this:
- Get the currently active subscription (field needed: billing_on)

- I use the billing_on date as the end date of the current billing cycle

- I use the billing_on - 30 days as the start date of the current billing cycle (Because my billing interval is "EVERY-30-DAYS")

View solution in original post

Replies 5 (5)

ChaseKaneki
Shopify Staff
47 6 4

Hello @noah_haub !

Yes, you can use the subscription billing cycle query. You can add any of the SubscriptionBillingCycle attributes for the response(cycleStartAt and cycleEndAt). 

Hope that helps!

Chase Dougherty
noah_haub
Shopify Partner
25 2 5

Ah perfect thank you very much man! I didn't see that because I mostly use the REST API.

So thank you!

noah_haub
Shopify Partner
25 2 5

@ChaseKaneki is the subscription billing cycle used for customers of stores or for customers of apps?

 

Because to use the subscription billing cycle query, I need a subscription contract.
And to create a subscription contract, I need to include things like delivery address etc.

Also this query is under the "orders" tab.

What I need is the start and end cycle of the users of my app, not the customers of a store.

 

Did I understand the subscription billing cycle query wrong?

noah_haub
Shopify Partner
25 2 5

This is an accepted solution.

I have sort of found a workaround.

What I am doing to get the start and end date of the current billing cycle is this:
- Get the currently active subscription (field needed: billing_on)

- I use the billing_on date as the end date of the current billing cycle

- I use the billing_on - 30 days as the start date of the current billing cycle (Because my billing interval is "EVERY-30-DAYS")

danhho
Shopify Partner
22 1 7

Hi @noah_haub, I have a question whether the billing_on field will be updated if shopify successfully pays the old invoice in recurring plan?
Example my current billing_on is 2023-09-05, and 30 days pass and they are charged again, now billing_on will update to  2023-10-05?