Skip to main content
fn update_plan_amount(env: Env, plan_id: u64, new_amount: i128)
Updates the per-period billing amount of an existing plan. The new amount must be positive and must not exceed the plan’s price_ceiling. This allows merchants to adjust pricing without requiring subscribers to re-authorize.

Parameters

NameTypeDescription
plan_idu64The ID of the plan to update.
new_amounti128The new billing amount per period, in stroops.

Authorization

merchant.require_auth();
The merchant address stored on the plan must sign the transaction.

Return value

None (void).

Events emitted

EventTopicsData
plan_updatedplan_id, new_amountUpdated plan details

Error cases

CodeNameDescription
6PlanNotFoundNo plan exists with the given plan_id.
3InvalidAmountnew_amount is zero or negative.
10AmountExceedsCeilingnew_amount exceeds the plan’s price_ceiling.

Examples

import { VowenaClient, NETWORKS, toStroops } from "vowena";

const client = new VowenaClient({
  contractId: NETWORKS.testnet.contractId,
  rpcUrl: NETWORKS.testnet.rpcUrl,
  networkPassphrase: NETWORKS.testnet.networkPassphrase,
});

// Raise the price from 9.99 to 12.99 (within the 14.99 ceiling)
const tx = await client.buildUpdatePlanAmount(
  planId,                   // Plan ID
  toStroops("12.99")        // 129900000n stroops
);

const signedXdr = await signTransaction(tx);
await client.submitTransaction(signedXdr);
Since the token allowance is set against the price_ceiling (not the current amount), updating the amount within the ceiling does not require subscribers to re-authorize. All existing subscriptions will be charged the new amount on their next billing cycle.
If you need to set a price above the current ceiling, you must create a new plan and use the migration flow to move subscribers. This ensures subscribers always have explicit control over their maximum exposure.