A place to discuss charging merchants for your apps and services using the billing API.
During development whenever I create a test recurring charge subscription, it always returns the "currentPeriodEnd" as few seconds ahead of the "createdAt" time instead of the expected "30 days" ahead of "createdAt". Here is a sample response from a test recurring charge.
{"name":"Basic","createdAt":"2019-08-12T08:29:20Z","currentPeriodEnd":"2019-08-12T08:29:33Z","id":"gid://shopify/AppSubscription/9596502116","status":"ACTIVE","test":true,"trialDays":0,"__typename":"AppSubscription"}
This makes development of billing flow very difficulty. I believe there are others as well who have raised this issue earlier but it still remains as it is.
Another question which is difficult for me to test is the response of activeSubscriptions graphql query when the user has cancelled his subscriptions but has some days left in the current app billing cycle. Since the "test subscription" is not working properly I am unable to test this scenario.
Please advise.
Hey @amardeep ,
When creating a test charge, the billing period's end date will be the same time that the charge was activated. I imagine this is by design since there is never any intent to have an actual full billing period or charge generated. This behaviour is the same both in GraphQL or REST.
With regards to testing your GraphQL query, If a user cancelled their subscription that would presumably be because they have uninstalled your app - which would prevent you from being able to run any queries on the shop anyway. So you wouldn't be able to see the response of activeSubscriptions anyway, so I'm not sure if there's much value in testing that response. If there's something I haven't considered here though please let me know!
With that being said, if a user uninstalls your app and cancels their recurring subscription before their billing period ends, we will pro-rate the charge and will still invoice the merchant for the period of time they did use your app for.
Josh | 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 the Shopify Help Center or the Shopify Blog
@Josh What are your thoughts on my previous response?
Hey @amardeep ,
You've made some fair points - I'll log a request to make test charges behave the same as real ones, but can't promise what the result of doing so would be as of yet. In terms of testing the same behaviour as a real charge as of today, the only way that I can see to do so would be by creating an actual, non-test recurring charge - which I can understand not being ideal.
Josh | 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 the Shopify Help Center or the Shopify Blog
Thanks @Josh for taking it up. Hoping for a solution.
Testing by creating a non-test charge would have been fine if it was a one time thing; development and testing are always an ongoing activity and debugging the whole flow would require a lot of non-test charges which seems not so ideal.
@Josh Any update on this?
Hey again @amardeep ,
No new news to share as of yet I'm afraid, but I'll check back in to see if I can get some attention on this.
Josh | 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 the Shopify Help Center or the Shopify Blog
@Josh I have also detailed out more issues with the Billing API in a separate thread https://community.shopify.com/c/Shopify-APIs-SDKs/Major-short-comings-with-Billing-API-amp-Proposed-...
I would like to bring your attention to that as well. I am sure this is an issue with other developers as well.
Thanks
Hi @Josh ,
I just spent over an hour worrying about our users not having access to our app because I thought the currentPeriodEnd time was being returned incorrectly by the Graph API due to this strange behavior. Our app relies on accurate renewal dates to determine if a customer is still active, we also use this date to determine when to reset any app usage for usage-based charges.
Having different behavior for test charges vs real charges makes an already difficult API to consume even more difficult/impossible to test. Like others have mentioned, I just have to hope that it works in production and ask the finance office if it's OK for us to bill ourselves for subscription charges.
It looks like this issue was opened nearly three years ago, so I don't have much hope that it will be solved, but please count me as a +1 in the level of frustration related to working with billing within Shopify. Now that Shopify REQUIRES that app developers use Shopify app billing for application charges, it needs to be a robust, testable solution.
Here is the example query I made:
```
{ node(id: "gid://shopify/AppSubscription/26434896088") { ...on AppSubscription { createdAt currentPeriodEnd id name } } }
Here is the response from the Graph API:
{ "data": { "node": { "createdAt": "2022-07-14T20:18:57Z", "currentPeriodEnd": "2022-07-14T20:19:02Z", "id": "gid://shopify/AppSubscription/26434896088", "name": "cloudeng-nesto.myshopify.com Cartr Subscription" } } }
As you can see, the createdAt and currentPeriodEnd are only about a minute apart. This makes the aforementioned testing in our development and local environments impossible.
Same problem here. We need to know the currentPeriodEnd to rely on accurate renewal dates.
@Josh even the simplest flows like buying subscriptions are impossible to test because we don't know how long the subscription is valid. If a customer buys a subscription, it would immediately become invalid again.
any news on this? what workarounds did you choose to recreate the productive behavior (as closely as possible)?
Same complaint here. I was about to implement (incorrect and dodgy) functionality to extrapolate the billing period end by adding 30 days because it seemed like currentPeriodEnd was being set to the end of the last billing period rather than the end of the current billing period, and I assumed that was normal behaviour.
This lack of functionality is really concerning, and nearly caused us to make a major implementation mistake that would have broken our user subscriptions once the Shopify billing was pushed to production.