What is the charge ID in the returnURL of the Billing API?

What is the charge ID in the returnURL of the Billing API?

lifesight_user
Shopify Partner
3 0 0

I was reading through the following article: https://shopify.dev/apps/billing/subscriptions/annual

and found the following information:
"You can use the appSubscriptionCreate mutation to create an annual subscription. You can specify the details of the plan by using the appRecurringPricingDetails field on the line item's plan. Provide the namepriceinterval, and returnUrl. The returnUrl is where the merchant is redirected after accepting the subscription charge. This URL needs to include the charge ID."

 

What is the charge ID in the returnUrl (specified in the last line above)?

Additionally, how do I use the response from the Billing API?
Should fields such as confirmationUrl and appSubscription (from the response) be used somewhere?

Replies 3 (3)

DigiXoft
Shopify Partner
109 19 76

Hi,
When you will subscribe it, shopify will return you a chargeID that you can use further.

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on arslan@digixoft.com regarding any help
Shopify Partner | Skype : arslan.saleem261

CurtisRF
Shopify Partner
8 0 6

I just went down this rabbit hole myself.

 

The charge ID is the ID that is assigned to a Charge on creation. Shopify refers to these as Charges when dealing with the Admin REST API, however, they are referred to as AppSubscriptions in the GraphQL API... just because. The data you get from either API is also slightly different, but the IDs are definitely the same.

 

I imagine the ID is passed back on the return URL so that you can use it again in any subsequent API request which requires the ID to be passed along with it. You could fetch the resource object and then show the plan name or number of trial days left to your user for example. I'm sure there are other use-cases that aren't clearly documented.

 

The confirmation URL is provided so that you can redirect the user to the charge authorisation page, which upon confirmation, will then redirect to the return URL (your app).

 

So:

  1. Create App Subscription
  2. Created, status: pending
  3. Receive confirmation URL
  4. Send user to this URL
  5. User confirms charge/app subscription i.e agrees to pay
  6. App subscription is now status: active
  7. Shopify sends user to return URL (your app)
  8. Handle scenario accordingly e.g Thanks for paying

Hope that helps.

Girish_Rajwani
Shopify Partner
87 3 9

Hey,

 

How can we access charge id? When I use custom route in return URL, it is giving missing Authorization header error. However it's working if i give only cloudfare URL without URL.

 

Kindly assist 

Girish | Shopify Expert  
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - My Shopify Apps: App Store | Looking for a solution to a problem in your store? Send me an email