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

Stripe: Find customer records by billing email

See more Stripe Examples

Find all customers with a given billing email, including addresses with a plus sign. Display the internal account reference so the operator can select the right record.

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;

CkoStringBuilder *email = [[CkoStringBuilder alloc] init];
[email SetString: @"billing+east@example.com"];

//  Show every match so the operator can check the internal account reference.

CkoStringBuilder *pageSuffix = [[CkoStringBuilder alloc] init];
BOOL more = YES;
NSString *cursor = @"";
while ((more == YES)) {
    //  curl -X GET "https://api.stripe.com/v1/customers?email={email}&limit=100" \
    //    -u "$STRIPE_API_KEY:" \
    //    -H "Stripe-Version: 2026-10-28.endive"
    [cmd SetString: @"curl -X GET \"https://api.stripe.com/v1/customers?email=@EMAIL@&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: @"@EMAIL@" replacement: [email GetEncoded: @"url_rfc3986" charset: @"utf-8"]] 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].name"],@" | ",[json StringOf: @"data[i].email"],@" | ",[json StringOf: @"data[i].metadata.account_ref"]);
        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];
    }

}