Tcl Requires Chilkat v11.7.0+
Tcl
Stripe: Start a subscription billed by invoice
See more Stripe Examples
Start an invoice-billed subscription for an existing customer, using a recurring price and 30-day payment terms.
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 customerId "cus_FROM_BILLING_ACCOUNT"
set priceId "price_FROM_CATALOG"
# Choose a recurring price. The customer pays the invoice under the agreed terms.
# curl -X POST "https://api.stripe.com/v1/subscriptions" \
# -u "$STRIPE_API_KEY:" \
# -H "Stripe-Version: 2026-10-28.endive" \
# -H "Idempotency-Key: {operationId}-subscription" \
# -d "customer={customerId}" \
# -d "items[0][price]={priceId}" \
# -d "items[0][quantity]=3" \
# -d "collection_method=send_invoice" \
# -d "days_until_due=30"
CkStringBuilder_SetString $cmd "curl -X POST \"https://api.stripe.com/v1/subscriptions\""
CkStringBuilder_Append $cmd " -u \"@KEY@:\""
CkStringBuilder_Append $cmd " -H \"Stripe-Version: 2026-10-28.endive\""
CkStringBuilder_Append $cmd " -H \"Idempotency-Key: @OP@-subscription\""
CkStringBuilder_Append $cmd " -d \"customer=@CUSTOMER@\""
CkStringBuilder_Append $cmd " -d \"items[0][price]=@PRICE@\""
CkStringBuilder_Append $cmd " -d \"items[0][quantity]=3\""
CkStringBuilder_Append $cmd " -d \"collection_method=send_invoice\""
CkStringBuilder_Append $cmd " -d \"days_until_due=30\""
set replaced [CkStringBuilder_Replace $cmd "@CUSTOMER@" $customerId]
set replaced [CkStringBuilder_Replace $cmd "@PRICE@" $priceId]
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 "latest_invoice = [CkJsonObject_stringOf $json latest_invoice]"
# Save the subscription and invoice IDs. Read payment status from the invoice.
delete_CkHttpCurl $curl
delete_CkStringBuilder $cmd
delete_CkJsonObject $json