Tcl Requires Chilkat v11.7.0+
Tcl
Stripe: Find a catalog price by its lookup key
See more Stripe Examples
Retrieve an active price by its catalog lookup key and read its price ID, currency, amount, and billing type.
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"
set curl [new_CkHttpCurl]
set cmd [new_CkStringBuilder]
set json [new_CkJsonObject]
set lookupKey [new_CkStringBuilder]
CkStringBuilder_SetString $lookupKey "support_monthly_usd"
# curl -X GET "https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D={lookupKey}&limit=2" \
# -u "$STRIPE_API_KEY:" \
# -H "Stripe-Version: 2026-10-28.endive"
CkStringBuilder_SetString $cmd "curl -X GET \"https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D=@LOOKUP@&limit=2\""
CkStringBuilder_Append $cmd " -u \"@KEY@:\""
CkStringBuilder_Append $cmd " -H \"Stripe-Version: 2026-10-28.endive\""
set replaced [CkStringBuilder_Replace $cmd "@LOOKUP@" [CkStringBuilder_getEncoded $lookupKey "url_rfc3986" "utf-8"]]
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
delete_CkStringBuilder $lookupKey
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
delete_CkStringBuilder $lookupKey
exit
}
if {expr [[CkJsonObject_SizeOfArray $json "data"] != 1] || [[CkJsonObject_BoolOf $json "has_more"] == 1]} then {
puts "Expected one active price for this lookup key."
delete_CkHttpCurl $curl
delete_CkStringBuilder $cmd
delete_CkJsonObject $json
delete_CkStringBuilder $lookupKey
exit
}
puts "id = [CkJsonObject_stringOf $json {data[0].id}]"
puts "lookup_key = [CkJsonObject_stringOf $json {data[0].lookup_key}]"
puts "currency = [CkJsonObject_stringOf $json {data[0].currency}]"
puts "unit_amount_decimal = [CkJsonObject_stringOf $json {data[0].unit_amount_decimal}]"
puts "type = [CkJsonObject_stringOf $json {data[0].type}]"
delete_CkHttpCurl $curl
delete_CkStringBuilder $cmd
delete_CkJsonObject $json
delete_CkStringBuilder $lookupKey