plan_id.
Parameters
| Name | Type | Description |
|---|---|---|
merchant | Address | The merchant’s Stellar address. Must sign the transaction. |
token | Address | The SEP-41 token contract address (e.g., USDC). |
amount | i128 | Amount charged per billing period, in stroops (7 decimal places). |
period | u64 | Billing period duration in seconds (e.g., 2592000 for 30 days). |
trial_periods | u32 | Number of free trial periods before billing begins. Use 0 for no trial. |
max_periods | u32 | Maximum number of billing periods. Use 0 for unlimited. |
grace_period | u64 | Grace window in seconds after a failed charge before the subscription pauses. |
price_ceiling | i128 | Maximum amount the plan can ever charge per period, in stroops. Protects subscribers from price increases. |
Authorization
Return value
u64 - the newly created plan ID.
Events emitted
| Event | Topics | Data |
|---|---|---|
plan_created | merchant, plan_id | Plan struct |
Error cases
| Code | Name | Description |
|---|---|---|
| 3 | InvalidAmount | amount is zero or negative. |
| 4 | InvalidPeriod | period is zero. |
| 5 | CeilingBelowAmount | price_ceiling is less than amount. |
Examples
- SDK
- Soroban CLI
How stroops work
How stroops work
Stellar tokens use 7 decimal places. The SDK’s When using the CLI, pass the raw stroop value directly.
toStroops() helper converts human-readable amounts: