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 <CkHttpCurlW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    bool success = false;

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

    CkHttpCurlW curl;
    CkStringBuilderW cmd;
    CkJsonObjectW json;

    int replaced;

    CkStringBuilderW lookupKey;
    lookupKey.SetString(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"
    cmd.SetString(L"curl -X GET \"https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D=@LOOKUP@&limit=2\"");
    cmd.Append(L" -u \"@KEY@:\"");
    cmd.Append(L" -H \"Stripe-Version: 2026-10-28.endive\"");
    replaced = cmd.Replace(L"@LOOKUP@",lookupKey.getEncoded(L"url_rfc3986",L"utf-8"));
    replaced = cmd.Replace(L"@KEY@",apiKey);
    success = curl.DoYourThing(cmd.getAsString());
    if (success != true) {
        wprintf(L"No HTTP response. Chilkat failure code: %d\n",curl.get_FailReason());
        return;
    }

    success = curl.GetResponseJson(json);
    if ((curl.get_StatusCode() != 200) || (success != true)) {
        wprintf(L"Stripe HTTP %d  Request-Id: %s\n",curl.get_StatusCode(),curl.getResponseHeaderField(L"Request-Id"));
        if (success == true) {
            wprintf(L"%s\n",json.stringOf(L"error.message"));
        }

        return;
    }

    if ((json.SizeOfArray(L"data") != 1) || (json.BoolOf(L"has_more") == true)) {
        wprintf(L"Expected one active price for this lookup key.\n");
        return;
    }

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