Swift Requires Chilkat v11.7.0+
Swift
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 Swift Downloads
func chilkatTest() {
var success: Bool = false
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
var apiKey: String? = "YOUR_STRIPE_TEST_KEY"
let curl = CkoHttpCurl()!
let cmd = CkoStringBuilder()!
let json = CkoJsonObject()!
var replaced: Int
var refundId: String? = "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(value: "curl -X GET \"https://api.stripe.com/v1/refunds/@ID@\"")
cmd.append(value: " -u \"@KEY@:\"")
cmd.append(value: " -H \"Stripe-Version: 2026-10-28.endive\"")
replaced = cmd.replace(value: "@ID@", replacement: refundId).intValue
replaced = cmd.replace(value: "@KEY@", replacement: apiKey).intValue
success = curl.doYourThing(targetCurl: cmd.getAsString())
if success != true {
print("No HTTP response. Chilkat failure code: \(curl.failReason.intValue)")
return
}
success = curl.getResponseJson(json: json)
if (curl.statusCode.intValue != 200) || (success != true) {
print("Stripe HTTP \(curl.statusCode.intValue) Request-Id: \(curl.getResponseHeaderField(name: "Request-Id")!)")
if success == true {
print("\(json.string(of: "error.message")!)")
}
return
}
print("id = \(json.string(of: "id")!)")
print("status = \(json.string(of: "status")!)")
print("amount = \(json.string(of: "amount")!)")
print("currency = \(json.string(of: "currency")!)")
if json.string(of: "status") == "failed" {
print("Failure reason: \(json.string(of: "failure_reason")!)")
}
if json.string(of: "status") == "pending" {
print("Pending reason: \(json.string(of: "pending_reason")!)")
}
}