Sample code for 30+ languages & platforms
Lua 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 Lua Downloads

Lua
local chilkat = require("chilkat")

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

local curl = chilkat.HttpCurl.new()
local cmd = chilkat.StringBuilder.new()
local json = chilkat.JsonObject.new()

local lookupKey = chilkat.StringBuilder.new()
lookupKey:set_string("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:set_string("curl -X GET \"https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D=@LOOKUP@&limit=2\"")
cmd:append(" -u \"@KEY@:\"")
cmd:append(" -H \"Stripe-Version: 2026-10-28.endive\"")
local replaced = cmd:replace("@LOOKUP@", lookupKey:get_encoded("url_rfc3986", "utf-8"))
replaced = cmd:replace("@KEY@", apiKey)
local success = curl:do_your_thing(cmd:get_as_string())
if not success then
    print("No HTTP response. Chilkat failure code: " .. curl.fail_reason)
    return
end

success = curl:get_response_json(json)
if (curl.status_code ~= 200) or (not success) then
    print("Stripe HTTP " .. curl.status_code .. "  Request-Id: " .. curl:get_response_header_field("Request-Id"))
    if success then
        print(json:string_of("error.message"))
    end

    return
end

if (json:size_of_array("data") ~= 1) or (json:bool_of("has_more")) then
    print("Expected one active price for this lookup key.")
    return
end

print("id = " .. json:string_of("data[0].id"))
print("lookup_key = " .. json:string_of("data[0].lookup_key"))
print("currency = " .. json:string_of("data[0].currency"))
print("unit_amount_decimal = " .. json:string_of("data[0].unit_amount_decimal"))
print("type = " .. json:string_of("data[0].type"))