Cancel an existing hosted checkout that is still pending. BotSubscription expires the provider session first, then updates the local payment request—so a payment that completes at the same moment always wins over the cancellation.
POST /v2/projects/ {project_id} /payment-requests/ {payment_request_id} /cancel CopyTry it Authorization Bearer API Key Required
The response includes the payment-operation fields . A terminal response omits the live checkout URL; use Get Payment Request for customer identity and stored timestamps.
API key scope: payment-requests:update (required for restricted keys).
The request body and query string must both be empty.
An open payable checkout can block a new automatic trial with 409 SUBSCRIPTION_IN_PROGRESS from Create Payment Request . Use this endpoint with its saved ID, or wait for provider expiry. Cancellation is provider-dependent: a 409 means it could not be safely confirmed, so do not assume the checkout is cancelled or that a new trial can start.
Path Parameters The unique identifier of the project.
The unique identifier of the payment request to cancel (UUID).
curl -X POST "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/payment-requests/11111111-1111-1111-1111-111111111111/cancel" \
-H "Authorization: Bearer YOUR_API_KEY" const project_id = 'YOUR_PROJECT_ID' ;
const payment_request_id = '11111111-1111-1111-1111-111111111111' ;
const response = await fetch ( `https://api.botsubscription.com/v2/projects/${ project_id }/payment-requests/${ payment_request_id }/cancel` , {
method: 'POST' ,
headers: {
'Authorization' : 'Bearer YOUR_API_KEY'
}
});
const data = await response. json (); import requests
project_id = 'YOUR_PROJECT_ID'
payment_request_id = '11111111-1111-1111-1111-111111111111'
response = requests.post(
f 'https://api.botsubscription.com/v2/projects/ { project_id } /payment-requests/ { payment_request_id } /cancel' ,
headers = { 'Authorization' : 'Bearer YOUR_API_KEY' }
)
data = response.json() $project_id = 'YOUR_PROJECT_ID' ;
$payment_request_id = '11111111-1111-1111-1111-111111111111' ;
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL , "https://api.botsubscription.com/v2/projects/{ $project_id }/payment-requests/{ $payment_request_id }/cancel" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Authorization: Bearer YOUR_API_KEY' ]);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
$response = curl_exec ($ch); Checkout cancelled application/json
{
"ok" : true ,
"request_id" : "11111111-1111-1111-1111-111111111111" ,
"method" : "POST" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/payment-requests/11111111-1111-1111-1111-111111111111/cancel" ,
"code" : 200 ,
"data" : {
"payment_request_id" : "11111111-1111-1111-1111-111111111111" ,
"request_type" : "invoice" ,
"amount" : "1" ,
"currency" : "USD" ,
"status" : "expired" ,
"provider_payment_id" : "cs_test_example" ,
"merchant_account_id" : "22222222-2222-4222-8222-222222222222" ,
"failure_reason" : null ,
"payment_error_code" : null ,
"provider" : "stripe" ,
"payment_request_data" : {}
}
} Provider session could not be safely expired application/json
{
"ok" : false ,
"request_id" : "11111111-1111-1111-1111-111111111111" ,
"method" : "POST" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/payment-requests/11111111-1111-1111-1111-111111111111/cancel" ,
"code" : 409 ,
"error" : {
"error_code" : "CONFLICT" ,
"message" : "The payment provider could not confirm the session was cancellable"
}
} Payment request not found application/json
{
"ok" : false ,
"request_id" : "11111111-1111-1111-1111-111111111111" ,
"method" : "POST" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/payment-requests/11111111-1111-1111-1111-111111111111/cancel" ,
"code" : 404 ,
"error" : {
"error_code" : "NOT_FOUND" ,
"message" : "Payment request not found"
}
} Invalid or expired API key application/json
{
"ok" : false ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "POST" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/payment-requests/22222222-2222-4222-8222-222222222222/cancel" ,
"code" : 401 ,
"error" : {
"message" : "Invalid or expired authentication token." ,
"error_code" : "UNAUTHORIZED"
}
} If the provider returns an indeterminate result, BotSubscription responds with a retryable error rather than guessing at the outcome—retry the cancellation once the provider's state is clear.