Objective-C Requires Chilkat v11.7.0+
Objective-C
Stripe: Review a customer's subscriptions
See more Stripe Examples
List a customer's subscriptions and inspect their items, prices, and seat counts.
Stripe documentation and cURL example
Chilkat Objective-C Downloads
#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;
NSString *customerId = @"cus_FROM_BILLING_ACCOUNT";
CkoStringBuilder *pageSuffix = [[CkoStringBuilder alloc] init];
BOOL more = YES;
NSString *cursor = @"";
while ((more == YES)) {
// curl -X GET "https://api.stripe.com/v1/subscriptions?customer={customerId}&status=all&limit=100" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
[cmd SetString: @"curl -X GET \"https://api.stripe.com/v1/subscriptions?customer=@ID@&status=all&limit=100@CURSOR@\""];
[cmd Append: @" -u \"@KEY@:\""];
[cmd Append: @" -H \"Stripe-Version: 2026-10-28.endive\""];
replaced = [[cmd Replace: @"@CURSOR@" replacement: [pageSuffix GetAsString]] intValue];
replaced = [[cmd Replace: @"@ID@" replacement: customerId] intValue];
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;
}
int i = 0;
int count = [[json SizeOfArray: @"data"] intValue];
while ((i < count)) {
json.I = [NSNumber numberWithInt: i];
NSLog(@"%@%@%@",[json StringOf: @"data[i].id"],@" | ",[json StringOf: @"data[i].status"]);
int j = 0;
while ((j < [[json SizeOfArray: @"data[i].items.data"] intValue])) {
json.J = [NSNumber numberWithInt: j];
NSLog(@"%@%@%@%@%@%@",@" Item ",[json StringOf: @"data[i].items.data[j].id"],@" price ",[json StringOf: @"data[i].items.data[j].price.id"],@" quantity "
,[json StringOf: @"data[i].items.data[j].quantity"]);
j = j + 1;
}
if ([json BoolOf: @"data[i].items.has_more"] == YES) {
NSLog(@"%@",@"Additional items are available via /v1/subscription_items for this subscription.");
}
i = i + 1;
}
more = [json BoolOf: @"has_more"];
if (more == YES) {
NSString *next = [json StringOf: @"data[i].id"];
if ((count < 1) || (next == @"") || (next == cursor)) {
NSLog(@"%@",@"Invalid pagination cursor.");
return;
}
cursor = next;
[pageSuffix SetString: @"&starting_after="];
[pageSuffix Append: cursor];
}
}