Sample code for 30+ languages & platforms
Rust 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 Rust Downloads

Rust
let mut success = false;

// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
let api_key = "YOUR_STRIPE_TEST_KEY".to_string();
// Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
let operation_id = "YOUR_SAVED_OPERATION_UUID".to_string();

let curl = chilkat::HttpCurl::new();
let cmd = chilkat::StringBuilder::new();
let json = chilkat::JsonObject::new();

let subscription_id = "sub_FROM_ACCOUNT".to_string();

let item_id = "si_SELECTED_ITEM".to_string();

let price_id = "price_FROM_CATALOG".to_string();

let proration_date = "UNIX_SECONDS_FROM_PREVIEW".to_string();

// 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}"
let _ = cmd.set_string("curl -X POST \"https://api.stripe.com/v1/subscriptions/@SUB@\"");
let _ = cmd.append(" -u \"@KEY@:\"");
let _ = cmd.append(" -H \"Stripe-Version: 2026-10-28.endive\"");
let _ = cmd.append(" -H \"Idempotency-Key: @OP@-plan-change\"");
let _ = cmd.append(" -d \"items[0][id]=@ITEM@\"");
let _ = cmd.append(" -d \"items[0][price]=@PRICE@\"");
let _ = cmd.append(" -d \"items[0][quantity]=5\"");
let _ = cmd.append(" -d \"proration_behavior=create_prorations\"");
let _ = cmd.append(" -d \"proration_date=@DATE@\"");
let _ = cmd.replace("@SUB@", &subscription_id);
let _ = cmd.replace("@ITEM@", &item_id);
let _ = cmd.replace("@PRICE@", &price_id);
let _ = cmd.replace("@DATE@", &proration_date);
let _ = cmd.replace("@OP@", &operation_id);
let _ = cmd.replace("@KEY@", &api_key);
success = curl.do_your_thing(&cmd.get_as_string().unwrap_or_default()).is_ok();
if !success {
    println!("No HTTP response. Chilkat failure code: {}", curl.fail_reason());
    return;
}

success = curl.get_response_json(&json).is_ok();
if (curl.status_code() != 200) || (!success) {
    println!("Stripe HTTP {}  Request-Id: {}", curl.status_code(), curl.get_response_header_field("Request-Id").unwrap_or_default());
    if success {
        println!("{}", json.string_of("error.message").unwrap_or_default());
    }

    return;
}

println!("id = {}", json.string_of("id").unwrap_or_default());
println!("status = {}", json.string_of("status").unwrap_or_default());

// curl -X GET "https://api.stripe.com/v1/subscription_items/{itemId}" \
//   -u "$STRIPE_API_KEY:" \
//   -H "Stripe-Version: 2026-10-28.endive"
let _ = cmd.set_string("curl -X GET \"https://api.stripe.com/v1/subscription_items/@ITEM@\"");
let _ = cmd.append(" -u \"@KEY@:\"");
let _ = cmd.append(" -H \"Stripe-Version: 2026-10-28.endive\"");
let _ = cmd.replace("@ITEM@", &item_id);
let _ = cmd.replace("@KEY@", &api_key);
success = curl.do_your_thing(&cmd.get_as_string().unwrap_or_default()).is_ok();
if !success {
    println!("No HTTP response. Chilkat failure code: {}", curl.fail_reason());
    return;
}

success = curl.get_response_json(&json).is_ok();
if (curl.status_code() != 200) || (!success) {
    println!("Stripe HTTP {}  Request-Id: {}", curl.status_code(), curl.get_response_header_field("Request-Id").unwrap_or_default());
    if success {
        println!("{}", json.string_of("error.message").unwrap_or_default());
    }

    return;
}

println!("id = {}", json.string_of("id").unwrap_or_default());
println!("id = {}", json.string_of("price.id").unwrap_or_default());
println!("quantity = {}", json.string_of("quantity").unwrap_or_default());