Tcl Requires Chilkat v11.7.0+
Tcl
Stripe: Schedule or undo a period-end cancellation
See more Stripe Examples
Schedule cancellation at the end of the billing period or undo a pending cancellation.
Stripe documentation and cURL example
Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# Requires an unlocked Chilkat bundle. See Global Unlock Sample.
# Supply a restricted sandbox key from merchant-controlled configuration.
set apiKey "YOUR_STRIPE_TEST_KEY"
# Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
set operationId "YOUR_SAVED_OPERATION_UUID"
set curl [new_CkHttpCurl]
set cmd [new_CkStringBuilder]
set json [new_CkJsonObject]
set subscriptionId "sub_FROM_ACCOUNT"
# Use false to undo a pending cancellation while the subscription is active.
# curl -X POST "https://api.stripe.com/v1/subscriptions/{subscriptionId}" \
# -u "$STRIPE_API_KEY:" \
# -H "Stripe-Version: 2026-10-28.endive" \
# -H "Idempotency-Key: {operationId}-period-end" \
# -d "cancel_at_period_end=true"
CkStringBuilder_SetString $cmd "curl -X POST \"https://api.stripe.com/v1/subscriptions/@SUB@\""
CkStringBuilder_Append $cmd " -u \"@KEY@:\""
CkStringBuilder_Append $cmd " -H \"Stripe-Version: 2026-10-28.endive\""
CkStringBuilder_Append $cmd " -H \"Idempotency-Key: @OP@-period-end\""
CkStringBuilder_Append $cmd " -d \"cancel_at_period_end=true\""
set replaced [CkStringBuilder_Replace $cmd "@SUB@" $subscriptionId]
set replaced [CkStringBuilder_Replace $cmd "@OP@" $operationId]
set replaced [CkStringBuilder_Replace $cmd "@KEY@" $apiKey]
set success [CkHttpCurl_DoYourThing $curl [CkStringBuilder_getAsString $cmd]]
if {$success != 1} then {
puts "No HTTP response. Chilkat failure code: [CkHttpCurl_get_FailReason $curl]"
delete_CkHttpCurl $curl
delete_CkStringBuilder $cmd
delete_CkJsonObject $json
exit
}
set success [CkHttpCurl_GetResponseJson $curl $json]
if {expr [[CkHttpCurl_get_StatusCode $curl] != 200] || [$success != 1]} then {
puts "Stripe HTTP [CkHttpCurl_get_StatusCode $curl] Request-Id: [CkHttpCurl_getResponseHeaderField $curl Request-Id]"
if {$success == 1} then {
puts [CkJsonObject_stringOf $json error.message]
}
delete_CkHttpCurl $curl
delete_CkStringBuilder $cmd
delete_CkJsonObject $json
exit
}
puts "id = [CkJsonObject_stringOf $json id]"
puts "status = [CkJsonObject_stringOf $json status]"
puts "Cancel at period end: [CkJsonObject_BoolOf $json cancel_at_period_end]"
delete_CkHttpCurl $curl
delete_CkStringBuilder $cmd
delete_CkJsonObject $json