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

Stripe: Check where a refund stands

See more Stripe Examples

Read the current status of a saved refund, including the reason for a pending or failed refund when available.

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

    refundId := "re_FROM_REFUND_RECORD"

    //  curl -X GET "https://api.stripe.com/v1/refunds/{refundId}" \
    //    -u "$STRIPE_API_KEY:" \
    //    -H "Stripe-Version: 2026-10-28.endive"
    cmd.SetString("curl -X GET \"https://api.stripe.com/v1/refunds/@ID@\"")
    cmd.Append(" -u \"@KEY@:\"")
    cmd.Append(" -H \"Stripe-Version: 2026-10-28.endive\"")
    replaced = cmd.Replace("@ID@",refundId)
    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()
        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()
        return
    }

    fmt.Println("id = ", *json.StringOf("id"))
    fmt.Println("status = ", *json.StringOf("status"))
    fmt.Println("amount = ", *json.StringOf("amount"))
    fmt.Println("currency = ", *json.StringOf("currency"))

    if json.StringOf("status") == "failed" {
        fmt.Println("Failure reason: ", *json.StringOf("failure_reason"))
    }

    if json.StringOf("status") == "pending" {
        fmt.Println("Pending reason: ", *json.StringOf("pending_reason"))
    }


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