Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.7.0+

Stripe: Apply the selected plan or seat change

See more Stripe Examples

Apply an accepted subscription change to the original item and retrieve that item to verify the new price and quantity.

Stripe documentation and cURL example

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
apiKey: PWideChar;
operationId: PWideChar;
curl: HCkHttpCurl;
cmd: HCkStringBuilder;
json: HCkJsonObject;
replaced: Integer;
subscriptionId: PWideChar;
itemId: PWideChar;
priceId: PWideChar;
prorationDate: PWideChar;

begin
success := False;

//  Requires an unlocked Chilkat bundle. See Global Unlock Sample.
//  Supply a restricted sandbox key from merchant-controlled configuration.
apiKey := 'YOUR_STRIPE_TEST_KEY';
//  Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
operationId := 'YOUR_SAVED_OPERATION_UUID';

curl := CkHttpCurl_Create();
cmd := CkStringBuilder_Create();
json := CkJsonObject_Create();

subscriptionId := 'sub_FROM_ACCOUNT';

itemId := 'si_SELECTED_ITEM';

priceId := 'price_FROM_CATALOG';

prorationDate := 'UNIX_SECONDS_FROM_PREVIEW';

//  Use the item, quantity, price, and UTC timestamp accepted by the operator.

//  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}-plan-change" \
//    -d "items[0][id]={itemId}" \
//    -d "items[0][price]={priceId}" \
//    -d "items[0][quantity]=5" \
//    -d "proration_behavior=create_prorations" \
//    -d "proration_date={prorationDate}"
CkStringBuilder_SetString(cmd,'curl -X POST "https://api.stripe.com/v1/subscriptions/@SUB@"');
CkStringBuilder_Append(cmd,' -u "@KEY@:"');
CkStringBuilder_Append(cmd,' -H "Stripe-Version: 2026-10-28.endive"');
CkStringBuilder_Append(cmd,' -H "Idempotency-Key: @OP@-plan-change"');
CkStringBuilder_Append(cmd,' -d "items[0][id]=@ITEM@"');
CkStringBuilder_Append(cmd,' -d "items[0][price]=@PRICE@"');
CkStringBuilder_Append(cmd,' -d "items[0][quantity]=5"');
CkStringBuilder_Append(cmd,' -d "proration_behavior=create_prorations"');
CkStringBuilder_Append(cmd,' -d "proration_date=@DATE@"');
replaced := CkStringBuilder_Replace(cmd,'@SUB@',subscriptionId);
replaced := CkStringBuilder_Replace(cmd,'@ITEM@',itemId);
replaced := CkStringBuilder_Replace(cmd,'@PRICE@',priceId);
replaced := CkStringBuilder_Replace(cmd,'@DATE@',prorationDate);
replaced := CkStringBuilder_Replace(cmd,'@OP@',operationId);
replaced := CkStringBuilder_Replace(cmd,'@KEY@',apiKey);
success := CkHttpCurl_DoYourThing(curl,CkStringBuilder__getAsString(cmd));
if (success <> True) then
  begin
    Memo1.Lines.Add('No HTTP response. Chilkat failure code: ' + IntToStr(CkHttpCurl_getFailReason(curl)));
    Exit;
  end;
success := CkHttpCurl_GetResponseJson(curl,json);
if ((CkHttpCurl_getStatusCode(curl) <> 200) or (success <> True)) then
  begin
    Memo1.Lines.Add('Stripe HTTP ' + IntToStr(CkHttpCurl_getStatusCode(curl)) + '  Request-Id: ' + CkHttpCurl__getResponseHeaderField(curl,'Request-Id'));
    if (success = True) then
      begin
        Memo1.Lines.Add(CkJsonObject__stringOf(json,'error.message'));
      end;
    Exit;
  end;

Memo1.Lines.Add('id = ' + CkJsonObject__stringOf(json,'id'));
Memo1.Lines.Add('status = ' + CkJsonObject__stringOf(json,'status'));

//  curl -X GET "https://api.stripe.com/v1/subscription_items/{itemId}" \
//    -u "$STRIPE_API_KEY:" \
//    -H "Stripe-Version: 2026-10-28.endive"
CkStringBuilder_SetString(cmd,'curl -X GET "https://api.stripe.com/v1/subscription_items/@ITEM@"');
CkStringBuilder_Append(cmd,' -u "@KEY@:"');
CkStringBuilder_Append(cmd,' -H "Stripe-Version: 2026-10-28.endive"');
replaced := CkStringBuilder_Replace(cmd,'@ITEM@',itemId);
replaced := CkStringBuilder_Replace(cmd,'@KEY@',apiKey);
success := CkHttpCurl_DoYourThing(curl,CkStringBuilder__getAsString(cmd));
if (success <> True) then
  begin
    Memo1.Lines.Add('No HTTP response. Chilkat failure code: ' + IntToStr(CkHttpCurl_getFailReason(curl)));
    Exit;
  end;
success := CkHttpCurl_GetResponseJson(curl,json);
if ((CkHttpCurl_getStatusCode(curl) <> 200) or (success <> True)) then
  begin
    Memo1.Lines.Add('Stripe HTTP ' + IntToStr(CkHttpCurl_getStatusCode(curl)) + '  Request-Id: ' + CkHttpCurl__getResponseHeaderField(curl,'Request-Id'));
    if (success = True) then
      begin
        Memo1.Lines.Add(CkJsonObject__stringOf(json,'error.message'));
      end;
    Exit;
  end;

Memo1.Lines.Add('id = ' + CkJsonObject__stringOf(json,'id'));
Memo1.Lines.Add('id = ' + CkJsonObject__stringOf(json,'price.id'));
Memo1.Lines.Add('quantity = ' + CkJsonObject__stringOf(json,'quantity'));

CkHttpCurl_Dispose(curl);
CkStringBuilder_Dispose(cmd);
CkJsonObject_Dispose(json);