Xbase++ Requires Chilkat v11.7.0+
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL cApiKey
LOCAL oCurl
LOCAL oCmd
LOCAL oJson
LOCAL nReplaced
LOCAL oLookupKey
nSuccess := 0
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
cApiKey := "YOUR_STRIPE_TEST_KEY"
oCurl := CreateObject("Chilkat.HttpCurl")
oCmd := CreateObject("Chilkat.StringBuilder")
oJson := CreateObject("Chilkat.JsonObject")
oLookupKey := CreateObject("Chilkat.StringBuilder")
oLookupKey:SetString("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"
oCmd:SetString('curl -X GET "https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D=@LOOKUP@&limit=2"')
oCmd:Append(' -u "@KEY@:"')
oCmd:Append(' -H "Stripe-Version: 2026-10-28.endive"')
nReplaced := oCmd:Replace("@LOOKUP@", oLookupKey:GetEncoded("url_rfc3986", "utf-8"))
nReplaced := oCmd:Replace("@KEY@", cApiKey)
nSuccess := oCurl:DoYourThing(oCmd:GetAsString())
IF (nSuccess != 1)
? "No HTTP response. Chilkat failure code: " + Str(oCurl:FailReason)
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oLookupKey:destroy()
RETURN
ENDIF
nSuccess := oCurl:GetResponseJson(oJson)
IF ((oCurl:StatusCode != 200) .OR. (nSuccess != 1))
? "Stripe HTTP " + Str(oCurl:StatusCode) + " Request-Id: " + oCurl:GetResponseHeaderField("Request-Id")
IF (nSuccess == 1)
? oJson:StringOf("error.message")
ENDIF
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oLookupKey:destroy()
RETURN
ENDIF
IF ((oJson:SizeOfArray("data") != 1) .OR. (oJson:BoolOf("has_more") == 1))
? "Expected one active price for this lookup key."
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oLookupKey:destroy()
RETURN
ENDIF
? "id = " + oJson:StringOf("data[0].id")
? "lookup_key = " + oJson:StringOf("data[0].lookup_key")
? "currency = " + oJson:StringOf("data[0].currency")
? "unit_amount_decimal = " + oJson:StringOf("data[0].unit_amount_decimal")
? "type = " + oJson:StringOf("data[0].type")
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oLookupKey:destroy()