Sample code for 30+ languages & platforms
Tcl Requires Chilkat v11.7.0+

Stripe: Apply the selected plan or seat change

See more Stripe Examples

Apply an accepted subscription change to the original item and retrieve that item to verify the new price and quantity.

Stripe documentation and cURL example

Chilkat Tcl Downloads

Tcl

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"

set itemId "si_SELECTED_ITEM"

set priceId "price_FROM_CATALOG"

set prorationDate "UNIX_SECONDS_FROM_PREVIEW"

#  Use the item, quantity, price, and UTC timestamp accepted by the operator.

#  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}-plan-change" \
#    -d "items[0][id]={itemId}" \
#    -d "items[0][price]={priceId}" \
#    -d "items[0][quantity]=5" \
#    -d "proration_behavior=create_prorations" \
#    -d "proration_date={prorationDate}"
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@-plan-change\""
CkStringBuilder_Append $cmd " -d \"items[0][id]=@ITEM@\""
CkStringBuilder_Append $cmd " -d \"items[0][price]=@PRICE@\""
CkStringBuilder_Append $cmd " -d \"items[0][quantity]=5\""
CkStringBuilder_Append $cmd " -d \"proration_behavior=create_prorations\""
CkStringBuilder_Append $cmd " -d \"proration_date=@DATE@\""
set replaced [CkStringBuilder_Replace $cmd "@SUB@" $subscriptionId]
set replaced [CkStringBuilder_Replace $cmd "@ITEM@" $itemId]
set replaced [CkStringBuilder_Replace $cmd "@PRICE@" $priceId]
set replaced [CkStringBuilder_Replace $cmd "@DATE@" $prorationDate]
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]"

#  curl -X GET "https://api.stripe.com/v1/subscription_items/{itemId}" \
#    -u "$STRIPE_API_KEY:" \
#    -H "Stripe-Version: 2026-10-28.endive"
CkStringBuilder_SetString $cmd "curl -X GET \"https://api.stripe.com/v1/subscription_items/@ITEM@\""
CkStringBuilder_Append $cmd " -u \"@KEY@:\""
CkStringBuilder_Append $cmd " -H \"Stripe-Version: 2026-10-28.endive\""
set replaced [CkStringBuilder_Replace $cmd "@ITEM@" $itemId]
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 "id = [CkJsonObject_stringOf $json price.id]"
puts "quantity = [CkJsonObject_stringOf $json quantity]"

delete_CkHttpCurl $curl
delete_CkStringBuilder $cmd
delete_CkJsonObject $json