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

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 Unicode C Downloads

Unicode C
#include <C_CkHttpCurlW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    BOOL success;
    const wchar_t *apiKey;
    HCkHttpCurlW curl;
    HCkStringBuilderW cmd;
    HCkJsonObjectW json;
    int replaced;
    HCkStringBuilderW lookupKey;

    success = FALSE;

    //  Requires an unlocked Chilkat bundle. See Global Unlock Sample.
    //  Supply a restricted sandbox key from merchant-controlled configuration.
    apiKey = L"YOUR_STRIPE_TEST_KEY";

    curl = CkHttpCurlW_Create();
    cmd = CkStringBuilderW_Create();
    json = CkJsonObjectW_Create();

    lookupKey = CkStringBuilderW_Create();
    CkStringBuilderW_SetString(lookupKey,L"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"
    CkStringBuilderW_SetString(cmd,L"curl -X GET \"https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D=@LOOKUP@&limit=2\"");
    CkStringBuilderW_Append(cmd,L" -u \"@KEY@:\"");
    CkStringBuilderW_Append(cmd,L" -H \"Stripe-Version: 2026-10-28.endive\"");
    replaced = CkStringBuilderW_Replace(cmd,L"@LOOKUP@",CkStringBuilderW_getEncoded(lookupKey,L"url_rfc3986",L"utf-8"));
    replaced = CkStringBuilderW_Replace(cmd,L"@KEY@",apiKey);
    success = CkHttpCurlW_DoYourThing(curl,CkStringBuilderW_getAsString(cmd));
    if (success != TRUE) {
        wprintf(L"No HTTP response. Chilkat failure code: %d\n",CkHttpCurlW_getFailReason(curl));
        CkHttpCurlW_Dispose(curl);
        CkStringBuilderW_Dispose(cmd);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(lookupKey);
        return;
    }

    success = CkHttpCurlW_GetResponseJson(curl,json);
    if ((CkHttpCurlW_getStatusCode(curl) != 200) || (success != TRUE)) {
        wprintf(L"Stripe HTTP %d  Request-Id: %s\n",CkHttpCurlW_getStatusCode(curl),CkHttpCurlW_getResponseHeaderField(curl,L"Request-Id"));
        if (success == TRUE) {
            wprintf(L"%s\n",CkJsonObjectW_stringOf(json,L"error.message"));
        }

        CkHttpCurlW_Dispose(curl);
        CkStringBuilderW_Dispose(cmd);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(lookupKey);
        return;
    }

    if ((CkJsonObjectW_SizeOfArray(json,L"data") != 1) || (CkJsonObjectW_BoolOf(json,L"has_more") == TRUE)) {
        wprintf(L"Expected one active price for this lookup key.\n");
        CkHttpCurlW_Dispose(curl);
        CkStringBuilderW_Dispose(cmd);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(lookupKey);
        return;
    }

    wprintf(L"id = %s\n",CkJsonObjectW_stringOf(json,L"data[0].id"));
    wprintf(L"lookup_key = %s\n",CkJsonObjectW_stringOf(json,L"data[0].lookup_key"));
    wprintf(L"currency = %s\n",CkJsonObjectW_stringOf(json,L"data[0].currency"));
    wprintf(L"unit_amount_decimal = %s\n",CkJsonObjectW_stringOf(json,L"data[0].unit_amount_decimal"));
    wprintf(L"type = %s\n",CkJsonObjectW_stringOf(json,L"data[0].type"));


    CkHttpCurlW_Dispose(curl);
    CkStringBuilderW_Dispose(cmd);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(lookupKey);

    }