Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Shopify.Billing.check is useless for staff accounts #564

Closed
dxptqhtlutehvlyxcmtg opened this issue Oct 12, 2022 · 5 comments
Closed

Shopify.Billing.check is useless for staff accounts #564

dxptqhtlutehvlyxcmtg opened this issue Oct 12, 2022 · 5 comments
Labels

Comments

@dxptqhtlutehvlyxcmtg
Copy link

Issue summary

It's nice to have a billing check built in to the library, but it's currently insufficient as Shopify.Billing.check has no support for (all) staff accounts.

Depending on the permissions set on the staff account, responses from the GraphQL api range from working as expected, to "access denied".

Only with these excessive permissions does check() work:
x

These permssions result in check() throwing "access denied": (but a similar query is allowed via the REST api)
y

In the 2nd scenario, even though disallowed via Grapqhl the staff account user has access to similar information via the recurring_application_charges REST endpoint.

When "Manage and install apps..." is not checked, neither method works. Even with the per-app permission enabled.

Expected behavior

At the very least, the affect of staff account permissions on check() should be outlined in the docs.

If the session indicates user is not a store owner, perhaps check() should use the REST api to query subscription status. Unfortunately, this seemingly only works if "Manage and install apps..." is enabled.

It's strange that an app can procure a valid authentication session for a user and yet lack access to basic crucial information like billing status.

Actual behavior

As a staff account user without "Approve app charges" permission, the response from check() is:

{
  "data": null,
  "errors": [
    {
      "message": "access denied",
      "locations": [{ "line": 4, "column": 7 }],
      "path": ["currentAppInstallation", "activeSubscriptions"]
    }
  ],
  "extensions": {
    "cost": {
      "requestedQueryCost": 2,
      "actualQueryCost": 2,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 998,
        "restoreRate": 50
      }
    }
  }
}
@daviareias
Copy link

daviareias commented Oct 15, 2022

I'm using my own app and just ran into this problem, depending on the staff user permission, this query won't return any data:

query appSubscription {
    currentAppInstallation {
      activeSubscriptions {
        name
        test
      }
    }
  }

Shopify is not clear about what permissions are needed to run this query, I tested on several shops that we have different degrees of access, some of them just return "access denied"

I'm going to try to use offline tokens, but we'll still have to create an extra screen warning the staff user that doesn't have permission to approve subscriptions and that he needs to contact the store owner to approve it.

But I'm not even sure if that's really the problem, so instead of risking a bad user experience, I've chosen not to throw an error if that happens and run the risk of losing some money.

@daviareias
Copy link

daviareias commented Oct 15, 2022

I decided to log every time that query returned an error and just ran into a weird situation now:

on our partner dashboard this store has an active subscription with our app, but their store has an inactive Shopify plan. When we run the query using their access token, we get access denied 😂

@github-actions
Copy link
Contributor

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Jan 31, 2023
@github-actions
Copy link
Contributor

We are closing this issue because it has been inactive for a few months.
This probably means that it is not reproducible or it has been fixed in a newer version.
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!

@salehp
Copy link

salehp commented Apr 1, 2024

This is still an active issue I'm facing. Can this be re-opened?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants