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

Stripe: Schedule or undo a period-end cancellation

See more Stripe Examples

Schedule cancellation at the end of the billing period or undo a pending cancellation.

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";
//  Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
NSString *operationId = @"YOUR_SAVED_OPERATION_UUID";

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

int replaced;

NSString *subscriptionId = @"sub_FROM_ACCOUNT";

//  Use false to undo a pending cancellation while the subscription is active.

//  curl -X POST "https://api.stripe.com/v1/subscriptions/{subscriptionId}" \
//    -u "$STRIPE_API_KEY:" \
//    -H "Stripe-Version: 2026-10-28.endive" \
//    -H "Idempotency-Key: {operationId}-period-end" \
//    -d "cancel_at_period_end=true"
[cmd SetString: @"curl -X POST \"https://api.stripe.com/v1/subscriptions/@SUB@\""];
[cmd Append: @" -u \"@KEY@:\""];
[cmd Append: @" -H \"Stripe-Version: 2026-10-28.endive\""];
[cmd Append: @" -H \"Idempotency-Key: @OP@-period-end\""];
[cmd Append: @" -d \"cancel_at_period_end=true\""];
replaced = [[cmd Replace: @"@SUB@" replacement: subscriptionId] intValue];
replaced = [[cmd Replace: @"@OP@" replacement: operationId] 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;
}

NSLog(@"%@%@",@"id = ",[json StringOf: @"id"]);
NSLog(@"%@%@",@"status = ",[json StringOf: @"status"]);

NSLog(@"%@%d",@"Cancel at period end: ",[json BoolOf: @"cancel_at_period_end"]);