{"record":{"id":"c3ff1b3ea320bae2","repo":"toeverything/AFFiNE","slug":"cant-update-onetime-payment-subscription","errorCode":"cant_update_onetime_payment_subscription","errorMessage":"Onetime payment subscription cannot be canceled.","messagePattern":"Onetime payment subscription cannot be canceled\\.","errorType":"exception","errorClass":"CantUpdateOnetimePaymentSubscription","httpStatus":403,"severity":"error","filePath":"packages/backend/server/src/plugins/payment/service.ts","lineNumber":202,"sourceCode":"    return this.mutate(identity, 'resume', idempotencyKey);\n  }\n\n  async updateSubscriptionRecurring(\n    identity: SubscriptionIdentity,\n    recurring: SubscriptionRecurring,\n    idempotencyKey?: string\n  ) {\n    const target = subscriptionTarget(identity);\n    const subscription = await this.command<Subscription>({\n      action: 'update_recurring',\n      actorUserId: target.actor,\n      targetType: target.type,\n      targetId: target.id,\n      plan: identity.plan,\n      recurring,\n      intentId: idempotencyKey ?? randomUUID(),\n    });\n    return normalizeSubscription(subscription);\n  }\n\n  async updateSubscriptionQuantity(\n    identity: SubscriptionIdentity,\n    quantity: number\n  ) {\n    const target = subscriptionTarget(identity);\n    await this.command({\n      action: 'update_quantity',\n      actorUserId: target.actor,\n      targetType: target.type,\n      targetId: target.id,\n      plan: identity.plan,\n      quantity,\n      intentId: randomUUID(),\n    });\n  }\n","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/d897bb3d84099e54a6b3c0bd5f4265f8aa87d190/packages/backend/server/src/plugins/payment/service.ts#L184-L220","documentation":"Thrown by cancelSubscription when the active subscription has no stripeSubscriptionId. Such rows are onetime/lifetime purchases (e.g. Lifetime recurring or onetime variant), which have no recurring Stripe subscription to cancel, so cancellation is meaningless and rejected.","triggerScenarios":"Calling cancelSubscription on a Lifetime Pro purchase or any onetime-variant checkout result; refund flows mistakenly routed through cancel.","commonSituations":"Pricing page offers both monthly and lifetime; UI reuses the subscription settings component and shows Cancel for lifetime rows; test data created from onetime payments.","solutions":["Hide the Cancel action when the subscription has no stripeSubscriptionId (or recurring is 'lifetime' / variant onetime).","For refunds on onetime purchases, use the refund/invoice path, not cancelSubscription.","Copy guidance to users: lifetime access does not renew, so there is nothing to cancel."],"exampleFix":"// before\n{sub.status === 'active' && <CancelButton onClick={() => cancel(identity)} />}\n\n// after\n{sub.status === 'active' && sub.stripeSubscriptionId && (\n  <CancelButton onClick={() => cancel(identity)} />\n)}","handlingStrategy":"validation","validationCode":"const cancellable = Boolean(subscription.stripeSubscriptionId);\nif (!cancellable) throw new Error('Onetime/lifetime purchases cannot be canceled');\nawait svc.cancelSubscription(identity, idempotencyKey);","typeGuard":"function isRecurringSub(s: { stripeSubscriptionId: string | null }): s is { stripeSubscriptionId: string } {\n  return typeof s.stripeSubscriptionId === 'string' && s.stripeSubscriptionId.length > 0;\n}","tryCatchPattern":"catch (e) { if (gqlErrorCode(e) === 'cant_update_onetime_payment_subscription') { hideCancelAction(); showOnetimeNotice(); return; } throw e; }","preventionTips":["Hide cancel/resume for lifetime and onetime-variant purchases.","Route refund requests for onetime payments through the refund flow.","Include recurring vs lifetime in the subscription UI model so the branch is explicit."],"tags":["payment","onetime-payment","lifetime","cancel","subscription"],"backgroundTag":"onetime-payment-unsupported-operation","analyzedSha":"d897bb3d84099e54a6b3c0bd5f4265f8aa87d190","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}