Skip to main content
Web payment checkout flow
Updated over a week ago

The Web Payment checkout flow begins when a user clicks the “Subscribe” button on a Web Payment plan card on the checkout page in the Treefort web app. The web app then reaches out to the Treefort API, and the Treefort API reaches out to your checkout session endpoint to fetch a checkout session link. The Treefort API sends your checkout session link back to the app, which redirects the user to the link. The page at the link should handle taking the user’s payment information and billing them. If the user’s payment succeeds your API should send the necessary requests to the Treefort subscription POST or PATCH endpoints to set the user’s subscription state. Wait to redirect the user to the success URL specified in the request to your checkout session endpoint until you’ve received success responses from the Treefort API for the request(s) you made to set the user’s subscription state, otherwise the user might briefly see an incorrect state once they’ve been redirected to the web app. If you provide an option to cancel the checkout then in that case redirect the user to the cancel URL specified in the request to your checkout session endpoint.

Treefort might request a checkout session for the user because they’re subscribing for the first time, or it might be because they’re switching plans. It’s up to your responsibility to:

  1. Determine the user’s current state, either by making requests to the Treefort API or by consulting your own internal system.

  2. Make the right requests to the Treefort subscription endpoints so that the user’s subscription in the Treefort system is in the correct state once checkout is complete.

🚧 A user should only have one subscription in Treefort. Please design your integration to avoid creating multiple active web payment subscriptions for a user.

Did this answer your question?