Billing API implementation flow

Alan2
Tourist
7 0 1

Greetings,

We are interested in publishing an app on Shopify - the app will basically use a Script Tag to add a widget to store pages. We have implemented this part and can install the app on test stores.

We need to implement billing. A recurring charge, with an initial free trial.

We are insure at which step we should post that initial charge. It is during the app installation? After the oauth process and before adding the Script Tag?

Additionally, we should post a new recurring charge once for each of our monthly billing cycle? 

Any pointers here would of great help

Best regards, 

 

Joel-Reeds
Shopify Partner
164 9 56

A typical install process looks like this:

  1. User Clicks "Get" on App Store Listing
  2. App Receives Shop Domain And Redirects User Back To Install Page With client_id, scope, redirect_uri and state.
  3. User Clicks "Install" and is redirected back to your app using the redirect_uri above for authentication.  Response should include a code, HMAC, timestamp, state and shop.  The app should validate the returned response by comparing the sent state to the returned state, as well as validating the return HMAC.
  4. App generates an oauth access token using the returned code and your app API Key & secret.
  5. App creates a recurring application charge with the plan name, price, return_url, trial_days and test status.  App then redirects user to the returned confirmation_url.
  6. User accepts charge and is redirected back to your App using the redirect_url defined in the recurring application charge creation.  Returned user carries a charge_id in the URL.
  7. App looks up the recurring application charge status using the returned charge_id.  If user has accepted the charge, app activates the charge.
  8. App completes necessary install functions.  For example in your case this would include adding the Script Tag.

Once the user has accepted the recurring application charge you shouldn't need to create another one, unless the customer cancels.  Keep the returned charge_id stored so you can make a API call to check the status of the charge if needed.

 

Good luck with your app!

 

Cheers,

Joel.

Co-Founder / CTO @ Intuitive Shipping Inc.
Intuitive Shipping | Smart Boxing | Automate Shipping Profiles
Alan2
Tourist
7 0 1

Hi Joel,

Thanks, this helps a lot - very clear steps.

I do have one question. If the customer at a later date cancels billing how do we know so we can remove the Script Tag? I assume we have to periodically query the endpoint, or is there a webhook?

Best regards,

 

0 Likes
Joel-Reeds
Shopify Partner
164 9 56

Add a webhook for app/uninstalled.   This will send you a notification when the user uninstalls the app.

Co-Founder / CTO @ Intuitive Shipping Inc.
Intuitive Shipping | Smart Boxing | Automate Shipping Profiles
0 Likes
Alan2
Tourist
7 0 1

Perfect - thanks.

Is this webhook event invoked only when the customer explicitly uninstalls the app, or will it also be automatically invoked when the user cancels the billing?

Best regards,

0 Likes
Felix2
Shopify Partner
98 0 16

From my experience, it's only fired when uninstalling the app.

Looga.io
0 Likes
Joel-Reeds
Shopify Partner
164 9 56

From everything I can find the only way a user can cancel the billing for an app is to uninstall it.

Perhaps a Shopify Expert could weigh in to confirm this for us.

Co-Founder / CTO @ Intuitive Shipping Inc.
Intuitive Shipping | Smart Boxing | Automate Shipping Profiles
0 Likes