Hi there, I have created an app and now I am checking how can I deploy this and I have a few questions about the process as this is my first app and I am totally new on shopify.
So, after I finished my app and selected a subscription model, I had noticed that app shows up on admin after install but it keeps showing before the user pay for the app… I tried to find a few solutions and the way I am thinking in do this is:
1 - Creating a app-data metafield using this mutation:
mutation CreateAppDataMetafield($metafieldsSetInput: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafieldsSetInput) {
metafields {
id
namespace
key
}
userErrors {
field
message
}
}
}
{
"metafieldsSetInput": [
{
"namespace": "applicationInstallation",
"key": "paid",
"type": "boolean",
"value": "true",
"ownerId": "gid://shopify/AppInstallation/XXXXXXXXXXXX <- got it from currentAppInstallation"
}
]
}
Now I can use on my liquid file:
{% schema %}
"available_if": "{{ app.metafields.applicationInstallation.paid }}",
{% endschema %}
So this way I can enable/disable the content to be displayed on frontend.
Now I needed a way to set this in a way that will consume less server, so instead check my server for each request, I am thinking in use webhooks for check the payment/subscription.
I have found these ones:
webhookSubscriptionUpdate,
webhookSubscriptionCreate
So my questions are:
1 - Managing the app view via metafields like app.metafields.applicationInstallation.paid is safe? Does someone can set this via graphql beside me?
2 - If I create a custom webhookSubscriptionCreate I should be able to get the data after a merchange pays the subscription?
3 - If the customer doesn’t pay the subscription for some reason, like not having money in the credit card, I should get an update from webhookSubscriptionUpdate ?
4 - It’s safe assume that I can use only these 2 webhooks for managing this enable/disable feature for merchants?
Thank you.