Checkout validation
A webhook that lets you check if a plan or quantity change is allowed before the user can checkout.
When a user attempts to upgrade or change their subscription using the Bunny portal we call this a checkout.
In some cases you might want to check if the plan or quantity change should be allowed before letting the user proceed.
For example, you have a customer on a plan that includes 10 users and they have created 10 users on your platform. If they then tried to downgrade to a plan that only had 5 users you could use this webhook to block the change and provide a message explaning that they need to delete or deactivate some users before they can proceed with the change.
Enabling checkout validation
To enable this webhook you will need to ensure that you have enabled a webhook endpoint for your platform in Bunny.
Then on your platform enable the Checkout validation option.

Checkout validation webhook payload
The payload that will be sent will contain information about the tenant on your platform that is requesting a change and the features and quantities that they will be change to.
{
"type": "CheckoutValidation",
"payload": {
"tenant": {
"id": 132,
"code": "8c665dde-69ae-4c53-990b-3d19bf71791e",
"name": "Superdesk Inc"
},
"change": {
"features": [
{
"code": "users",
"name": "Users",
"value": "",
"quantity": 10,
"plan": {
"code": "enterprise",
"name": "Enterprise"
},
"price_list": {
"code": null,
"name": "Enterprise Monthly"
}
},
{
"code": "widgets",
"name": "Widgets",
"value": "100",
"quantity": 100,
"plan": {
"code": "enterprise",
"name": "Enterprise"
},
"price_list": {
"code": null,
"name": "Enterprise Monthly"
}
}
]
}
}
}
If you wanted to validate the number of users you would use the Tenant code to look up the relevant tenant in your application, get a count of the users and then compare this to the number of users requested in the checkout validation payload.
Responding to the webhook
If you opt-in to using the checkout validation webhook you must respond within 5 seconds with one of the following decisions.
Change approved
The user will be allowed to continue with the subscription change.
HTTP STATUS CODE: 200 - OK
No response body is required and will be ignored if provided.
Change denied
The user will not be able to continue and will be displayed the error message that you provide.
HTTP STATUS CODE: 422 - Unprocessable Content
The required JSON response body is an array of strings that explain why the subscription change is not possible.
[
"You have too many users to downgrade to this plan. Please remove some users and try again."
]

Last updated
Was this helpful?