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

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  var success = false;

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

  final curl = CkHttpCurl();
  final cmd = CkStringBuilder();
  final json = CkJsonObject();

  var replaced = 0;

  final 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);
  try {
    curl.doYourThing(cmd.getAsString());
  } on ChilkatException {
    print('No HTTP response. Chilkat failure code: ${curl.failReason}');
    return;
  }

  success = true;
  try {
    curl.getResponseJson(json);
  } on ChilkatException {
    success = false;
  }
  if ((curl.statusCode != 200) || (!success)) {
    print('Stripe HTTP ${curl.statusCode}  Request-Id: ${curl.getResponseHeaderField('Request-Id')}');
    if (success) {
      print(json.stringOf('error.message'));
    }

    return;
  }

  print('id = ${json.stringOf('id')}');
  print('status = ${json.stringOf('status')}');
  print('amount = ${json.stringOf('amount')}');
  print('currency = ${json.stringOf('currency')}');

  if (json.stringOf('status') == 'failed') {
    print('Failure reason: ${json.stringOf('failure_reason')}');
  }

  if (json.stringOf('status') == 'pending') {
    print('Pending reason: ${json.stringOf('pending_reason')}');
  }
}