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

Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var curl = new CkHttpCurl();
var cmd = new CkStringBuilder();
var json = new CkJsonObject();

var replaced;

var 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) {
    console.log("No HTTP response. Chilkat failure code: " + curl.FailReason);
    return;
}

success = curl.GetResponseJson(json);
if ((curl.StatusCode !== 200) || (success !== true)) {
    console.log("Stripe HTTP " + curl.StatusCode + "  Request-Id: " + curl.GetResponseHeaderField("Request-Id"));
    if (success == true) {
        console.log(json.StringOf("error.message"));
    }

    return;
}

console.log("id = " + json.StringOf("id"));
console.log("status = " + json.StringOf("status"));
console.log("amount = " + json.StringOf("amount"));
console.log("currency = " + json.StringOf("currency"));

if (json.StringOf("status") == "failed") {
    console.log("Failure reason: " + json.StringOf("failure_reason"));
}

if (json.StringOf("status") == "pending") {
    console.log("Pending reason: " + json.StringOf("pending_reason"));
}