@pwngh/economy-lab
    Preparing search index...

    Variable cancelSubscriptionConst

    cancelSubscription: (
        fields: FieldsOf<K>,
    ) => {
        actor: Principal;
        idempotencyKey: string;
        kind: "cancelSubscription";
        subscriptionId: string;
    } = ...

    Builds a cancelSubscription operation: marks the subscription CANCELED so the worker's renewal sweep stops billing it. It moves no money — the committed transaction is a lifecycle marker with empty legs — and nothing is refunded or prorated; the remainder of the paid period is forfeited. A user actor may cancel only their own subscription (checked against the loaded record); system and operator actors may cancel anyone's. Rejects with UNKNOWN_SUBSCRIPTION when no subscription matches the id or it is already CANCELED — the same answer either way, so probing an id never reveals whether it exists — and with ECONOMY_PAUSED for a user during a maintenance window. Canceling is final for the record; subscribing again opens a fresh one.

    Type Declaration

      • (
            fields: FieldsOf<K>,
        ): {
            actor: Principal;
            idempotencyKey: string;
            kind: "cancelSubscription";
            subscriptionId: string;
        }
      • Parameters

        • fields: FieldsOf<K>

        Returns {
            actor: Principal;
            idempotencyKey: string;
            kind: "cancelSubscription";
            subscriptionId: string;
        }

    const outcome = await economy.submit(cancelSubscription({
    idempotencyKey: idempotencyKey('cancel', 'sub_4f2a'),
    actor: userActor('usr_buyer'),
    subscriptionId: 'sub_4f2a',
    }));