Integration Flow
If a user is logged into an account with your service, they start paying for your service once you implement the following flow:
-
Add a button for users to connect with their Pavillion Wallet. Place this button somewhere that makes it frictionless for the user to click to start paying you.
-
After the user clicks the button, direct them to a "Sign in to Pavillion" page.
-
If the user does not have a Pavillion account, provide a "Sign up for Pavillion" page. Refer to the sign up example. After the user signs up successfully, direct them to https://www.pavillion.ai/wallet to add credits.
-
Be sure to send your Client ID when the user signs up so that you can get credit for referring this user to Pavillion.
-
After the user has entered their credentials and hit enter, send the email and password, along with your Pavillion Client ID to Pavillion Login. When the login is successful, you will get a token in the response body, which can be used as a Bearer token to charge the user's account. Refer to the login example.
-
-
When the user is logged in, charge the user's wallet by sending a request to Pavillion's
/api/charge
endpoint. Refer to the charge example and charge API reference.- IMPORTANT: Make sure the charge request is successful (status code 200) before serving the user's request. If the charge request is unsuccessful, you may not receive funds for providing the service.
-
If the user's credit balance is insufficient, inform them that their balance is insufficient and open their Pavillion wallet page to add credits https://www.pavillion.ai/wallet