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

Go
    success := false

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

    curl := chilkat.NewHttpCurl()
    cmd := chilkat.NewStringBuilder()
    json := chilkat.NewJsonObject()

    var replaced int

    lookupKey := chilkat.NewStringBuilder()
    lookupKey.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"
    cmd.SetString("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\"")
    replaced = cmd.Replace("@LOOKUP@",*lookupKey.GetEncoded("url_rfc3986","utf-8"))
    replaced = cmd.Replace("@KEY@",apiKey)
    success = curl.DoYourThing(*cmd.GetAsString())
    if success != true {
        fmt.Println("No HTTP response. Chilkat failure code: ", curl.FailReason())
        curl.DisposeHttpCurl()
        cmd.DisposeStringBuilder()
        json.DisposeJsonObject()
        lookupKey.DisposeStringBuilder()
        return
    }

    success = curl.GetResponseJson(json)
    if (curl.StatusCode() != 200) || (success != true) {
        fmt.Println("Stripe HTTP ", curl.StatusCode(), "  Request-Id: ", *curl.GetResponseHeaderField("Request-Id"))
        if success == true {
            fmt.Println(*json.StringOf("error.message"))
        }

        curl.DisposeHttpCurl()
        cmd.DisposeStringBuilder()
        json.DisposeJsonObject()
        lookupKey.DisposeStringBuilder()
        return
    }

    if (json.SizeOfArray("data") != 1) || (json.BoolOf("has_more") == true) {
        fmt.Println("Expected one active price for this lookup key.")
        curl.DisposeHttpCurl()
        cmd.DisposeStringBuilder()
        json.DisposeJsonObject()
        lookupKey.DisposeStringBuilder()
        return
    }

    fmt.Println("id = ", *json.StringOf("data[0].id"))
    fmt.Println("lookup_key = ", *json.StringOf("data[0].lookup_key"))
    fmt.Println("currency = ", *json.StringOf("data[0].currency"))
    fmt.Println("unit_amount_decimal = ", *json.StringOf("data[0].unit_amount_decimal"))
    fmt.Println("type = ", *json.StringOf("data[0].type"))

    curl.DisposeHttpCurl()
    cmd.DisposeStringBuilder()
    json.DisposeJsonObject()
    lookupKey.DisposeStringBuilder()