Cancelled and no further charges can be processed. Either the subscriber or the merchant who owns the plan can cancel.
Parameters
| Name | Type | Description |
|---|---|---|
caller | Address | The address initiating the cancellation. Must be the subscriber or the merchant. |
sub_id | u64 | The subscription ID to cancel. |
Authorization
caller must be either:
- The subscriber on the subscription, or
- The merchant on the plan the subscription belongs to.
Unauthorized.
Return value
None (void).
Events emitted
| Event | Topics | Data |
|---|---|---|
sub_cancel | subscriber, sub_id | cancelled_at timestamp |
Error cases
| Code | Name | Description |
|---|---|---|
| 8 | SubNotFound | No subscription exists with the given sub_id. |
| 9 | Unauthorized | Caller is neither the subscriber nor the merchant. |
Examples
- SDK
- Soroban CLI
Cancellation does not issue a refund. If the merchant wants to refund remaining time, they should call
refund() separately. The token allowance remains on-chain but becomes irrelevant since the contract will never call transfer_from on a cancelled subscription.