Cancel
Cancel subscriptions — graceful request, immediate exit, or permissionless finalization.
Cancel
Recur supports three cancel flows:
| Flow | Instruction | Who calls | Effect |
|---|---|---|---|
| Request cancel | request_cancel | Subscriber or merchant | Marks cancel pending; prepaid period honored |
| Subscriber cancel | subscriber_cancel | Subscriber only | Immediate close; forfeits remaining prepaid time |
| Finalize cancel | finalize_cancel | Anyone (permissionless) | Closes PDA after prepaid period elapses |
buildCancelTransaction
Builds a request_cancel instruction. The subscription stays active until the prepaid period ends.
buildSubscriberCancelTransaction
Immediate exit. The subscriber forfeits any remaining prepaid time and the PDA is closed on-chain.
buildFinalizeCancelTransaction
After a request_cancel, once the prepaid period elapses, anyone can call finalize_cancel to close the PDA and reclaim rent. This is permissionless — typically called by the keeper.
cancel (high-level)
Combines build, sign, send, and confirm in one call.
mode | Instruction used | Behavior |
|---|---|---|
"request" | request_cancel | Marks pending; no more payments pulled; PDA closed after period ends |
"instant" | subscriber_cancel | Closes PDA immediately |
Cancel lifecycle
- Subscriber calls
request_cancel→ status becomescancel_pending - Keeper stops pulling payments for this subscription
- Webhook
cancel_requestedfires to merchant - When
last_payment_timestamp + intervalpasses, anyone callsfinalize_cancel - PDA is closed, rent reclaimed, webhook
cancel_finalizedfires