| title | update_plan_amount |
|---|---|
| description | Updates the billing amount of an existing plan. The new amount must stay within the price ceiling that subscribers agreed to, so no re-authorization is needed. |
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.
| Name | Type | Description |
|---|---|---|
plan_id |
u64 |
The ID of the plan to update. |
new_amount |
i128 |
The new billing amount per period, in stroops. |
merchant.require_auth();The merchant address stored on the plan must sign the transaction.
None (void).
| Event | Topics | Data |
|---|---|---|
plan_updated |
plan_id, new_amount |
Updated plan details |
| Code | Name | Description |
|---|---|---|
| 6 | PlanNotFound |
No plan exists with the given plan_id. |
| 3 | InvalidAmount |
new_amount is zero or negative. |
| 10 | AmountExceedsCeiling |
new_amount exceeds the plan's price_ceiling. |
```typescript import { VowenaClient, NETWORKS, toStroops } from "@vowena/sdk";
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);
```