Billing API in custom app not understanding how to implement

Billing API in custom app not understanding how to implement

Annarao
Shopify Partner
2 0 0

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

Reply 1 (1)

oscprofessional
Shopify Partner
15961 2387 3095

Hi @Annarao,

You can provide two types of billing for your app.

1. 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
}

2.  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.

1. https://shopify.dev/docs/apps/billing#the-billing-process 

2. https://shopify.dev/docs/api/admin-graphql/2023-07/mutations/appSubscriptionCreate

 

Please like and accept if post is helpful for you.

Thanks...

 

 

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free