Hey everyone,
I need some help with create billing plans to my app
I take an overview on the Billing API, but not sure how to implement this correctly.
Any help can be helpful,
Thanks
Hi @Annarao ,
You can provide two types of billing for your app.
- Recurring Billing
It is nothing but subscription plan. You can simplify your plan by having one subscription plan.
For this you can create one function RecurringCreate()
and with mutation using GraphQL you can create appSubscriptionCreate.
In this mutation you can decide plan.
For Example :
Plan name
Plan Price
Currency
Trial Days
mutation appSubscriptionCreate($lineItems: [AppSubscriptionLineItemInput!]!, $name: String!, $returnUrl: URL!) {
appSubscriptionCreate(lineItems: $lineItems, name: $name, returnUrl: $returnUrl) {
appSubscription {
# AppSubscription fields
}
confirmationUrl
userErrors {
field
message
}
}
}
Variables :
{
lineItems: [
{
plan: {
appRecurringPricingDetails: {
price: { amount: 10, currencyCode: USD }
}
}
}
],
"name": "",
"replacementBehavior": "",
"returnUrl": "",
"test": true,
"trialDays": 1
}
- One-Time Billing
You can create using mutation appPurchaseOneTimeCreate
Similar to Recurring Billing you can decide,
Plan name
Plan Price
Currency
Is Test
mutation appPurchaseOneTimeCreate($name: String!, $price: MoneyInput!, $returnUrl: URL!) {
appPurchaseOneTimeCreate(name: $name, price: $price, returnUrl: $returnUrl) {
appPurchaseOneTime {
name
}
confirmationUrl
userErrors {
field
message
}
}
}
Variables :
{
"name": "Test Billing",
"price": {
"amount": "10.99",
"currencyCode": "USD"
},
"returnUrl": "https://yourstore.myshopify.com/"
}
Make sure that you created a public app when testing for billing code.
I hope some part is clear to you.
Please refer shopify document links, might be helpful for you.
Please like and accept if post is helpful for you.
Thanks…
Hello, I am facing an issue implementing
AppPurchaseOneTimeCreate.
returnUrl: ${process.env.SHOPIFY_APP_URL}/app/settings}
I want to redirect this url after approving the payment. But it redirect me to a login page and after login it redirect me to default page.
returnUrl: ${process.env.SHOPIFY_APP_URL}/auth/login?shop=${session.shop}&target=/app/settings},
if i want to go through with this url then it’s not redirecting me to login page. But it redirects to default page.
How can i redirect to /app/settings after approve the charge?