Sample code for 30+ languages & platforms
Objective-C Requires Chilkat v11.7.0+

Stripe: Show available and pending balances by currency

See more Stripe Examples

Read the available and pending account balances for every currency returned by Stripe.

Stripe documentation and cURL example

Chilkat Objective-C Downloads

Objective-C
#import <NSString.h>
#import <CkoHttpCurl.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>

BOOL success = NO;

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

CkoHttpCurl *curl = [[CkoHttpCurl alloc] init];
CkoStringBuilder *cmd = [[CkoStringBuilder alloc] init];
CkoJsonObject *json = [[CkoJsonObject alloc] init];

int replaced;

//  curl -X GET "https://api.stripe.com/v1/balance" \
//    -u "$STRIPE_API_KEY:" \
//    -H "Stripe-Version: 2026-10-28.endive"
[cmd SetString: @"curl -X GET \"https://api.stripe.com/v1/balance\""];
[cmd Append: @" -u \"@KEY@:\""];
[cmd Append: @" -H \"Stripe-Version: 2026-10-28.endive\""];
replaced = [[cmd Replace: @"@KEY@" replacement: apiKey] intValue];
success = [curl DoYourThing: [cmd GetAsString]];
if (success != YES) {
    NSLog(@"%@%d",@"No HTTP response. Chilkat failure code: ",[curl.FailReason intValue]);
    return;
}

success = [curl GetResponseJson: json];
if (([curl.StatusCode intValue] != 200) || (success != YES)) {
    NSLog(@"%@%d%@%@",@"Stripe HTTP ",[curl.StatusCode intValue],@"  Request-Id: ",[curl GetResponseHeaderField: @"Request-Id"]);
    if (success == YES) {
        NSLog(@"%@",[json StringOf: @"error.message"]);
    }

    return;
}

//  Amounts are integer minor units. Read them as text to preserve large balances.

int availableIndex = 0;
while ((availableIndex < [[json SizeOfArray: @"available"] intValue])) {
    json.I = [NSNumber numberWithInt: availableIndex];
    NSLog(@"%@%@%@%@",@"available: ",[json StringOf: @"available[i].amount"],@" ",[json StringOf: @"available[i].currency"]);
    availableIndex = availableIndex + 1;
}

int pendingIndex = 0;
while ((pendingIndex < [[json SizeOfArray: @"pending"] intValue])) {
    json.I = [NSNumber numberWithInt: pendingIndex];
    NSLog(@"%@%@%@%@",@"pending: ",[json StringOf: @"pending[i].amount"],@" ",[json StringOf: @"pending[i].currency"]);
    pendingIndex = pendingIndex + 1;
}