Dart Requires Chilkat v11.7.0+
Dart
Stripe: Identify the payment for a paid invoice
See more Stripe Examples
List the payments allocated to an invoice and identify a paid charge or PaymentIntent for refund.
Stripe documentation and cURL example
Chilkat Dart Downloads
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 invoiceId = 'in_FROM_BILLING_RECORD';
final pageSuffix = CkStringBuilder();
var more = true;
var cursor = '';
while (more) {
// curl -X GET "https://api.stripe.com/v1/invoice_payments?invoice={invoiceId}&limit=100" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
cmd.setString('curl -X GET "https://api.stripe.com/v1/invoice_payments?invoice=@ID@&limit=100@CURSOR@"');
cmd.append(' -u "@KEY@:"');
cmd.append(' -H "Stripe-Version: 2026-10-28.endive"');
replaced = cmd.replace('@CURSOR@', pageSuffix.getAsString());
replaced = cmd.replace('@ID@', invoiceId);
replaced = cmd.replace('@KEY@', apiKey);
success = true;
try {
curl.doYourThing(cmd.getAsString());
} on ChilkatException {
success = false;
}
if (!success) {
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;
}
var i = 0;
final count = json.sizeOfArray('data');
while (i < count) {
json.i = i;
print('${json.stringOf('data[i].id')} | ${json.stringOf('data[i].status')} | ${json.stringOf('data[i].amount_paid')} | ${json.stringOf('data[i].currency')} | ${json.stringOf('data[i].payment.type')}');
if (json.stringOf('data[i].payment.type') == 'payment_intent') {
print(' PaymentIntent: ${json.stringOf('data[i].payment.payment_intent')}');
}
if (json.stringOf('data[i].payment.type') == 'charge') {
print(' Charge: ${json.stringOf('data[i].payment.charge')}');
}
i++;
}
more = json.boolOf('has_more');
if (more) {
final next = json.stringOf('data[i].id');
if ((count < 1) || ((next == '') || (next == cursor))) {
print('Invalid pagination cursor.');
return;
}
cursor = next;
pageSuffix.setString('&starting_after=');
pageSuffix.append(cursor);
}
}
// Select the paid allocation belonging to the order before issuing its refund.
}