Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

Re: GraphQL Billing API Issue

GraphQL Billing API Issue

Enea
Shopify Partner
19 0 2

Hi,

 

I am having a tough time pinning this down. In general when I query the GraphQL API for billing info I get the correct currentPeriodEnd which is 30 days after the charge was activated like so: 

{
  "data": {
    "id": "gid://shopify/AppSubscription/12878577741",
    "name": "Pay As You Grow",
    "createdAt": "2020-04-25T18:55:46Z",
    "currentPeriodEnd": "2020-05-25T18:56:17Z",
    "test": false,
    "status": "ACTIVE",
    "trialDays": 0,
  },
  "casted_data": {},
  "errors": []
}

 

but sometimes the currentPeriodEnd is just a few days after the date the charge was activate. For Example here:

{
  "data": {
    "id": "gid://shopify/AppSubscription/15100870787",
    "name": "Pay As You Grow",
    "createdAt": "2020-04-22T21:23:47Z",
    "currentPeriodEnd": "2020-04-29T20:08:52Z",
    "test": false,
    "status": "ACTIVE",
    "trialDays": 0,
  },
  "casted_data": {},
  "errors": []
}

 What am I supposed to be using to determine the billing periods? If a store installed and activated a charge on 2020-04-22T21:23:47Z the billing period should end on 2020-05-22 21:23:25 UTC not 2020-04-29T20:08:52Z

Replies 10 (10)

SBD_
Shopify Staff
1831 273 421

Hey @Enea,

 

For 15100870787, the merchant first installed the app on 2020-02-29, and uninstalled/reinstalled the app on 2020-04-02 - so the 29th cycle stuck.

Scott | Developer Advocate @ Shopify 

Enea
Shopify Partner
19 0 2
Is this because this user is on a usage based plan? When users are on paid
plans and uninstall then install again the billing period resets.
Also, how should I know if a user is inside the trial period or not? The
GraphQL api returns a period end date and trial days but I have no way to
know if the trial has ended. As of right now I am having to make a call to
the legacy REST API in conjunction with the GraphQL api to try and figure
out if a Shop is within their trial. Is there a better way to go about
this?
SBD_
Shopify Staff
1831 273 421

We're looking into brining the trial_ends_on across to the GraphQL API. For now, you'll need to manually calculate (createdAt + trialDays). 

Scott | Developer Advocate @ Shopify 

Enea
Shopify Partner
19 0 2
Is the created at date always the same as the date the charge was
activated? Would it be possible to also add the activated/confirmed
timestamp to GraphQL?
SBD_
Shopify Staff
1831 273 421

Is the created at date always the same as the date the charge was activated?

Good point, these will be different. In that case, for now you'll need to rely on the REST API, or track the activation date on your side.

 

Would it be possible to also add the activated/confirmed timestamp to GraphQL?

I'll pass this feedback along.

Scott | Developer Advocate @ Shopify 

Enea
Shopify Partner
19 0 2

Thank you

Enea
Shopify Partner
19 0 2

What do you think the time table for adding those fields looks like? 

SBD_
Shopify Staff
1831 273 421

The discussion is still taking place. There's no ETA.

Scott | Developer Advocate @ Shopify 

EugeneKim
Shopify Partner
60 3 29

Hi SBD_ , a couple questions:

  1. Can you confirm that the free trial for a user only starts upon activation rather than AppSubscription creation?
  2. If I want to extend the free trial of a merchant that already has an active AppSubscription instance and I create a new charge that they accept, will their new free trial start from the activation time of the new AppSubscription or the previous AppSubscription?

Thank you

EugeneKim
Shopify Partner
60 3 29

SBD_ another follow up:

RecurringApplicationCharge.trial_ends_on is a date rather than a datetime. What time of day does the trial end?

 

Thank you