toeverything/AFFiNE · error · CustomerPortalCreateFailed

customer_portal_create_failed

customer_portal_create_failed

Error message

Failed to create customer portal session.

What it means

createCustomerPortal catches Stripe billing portal session creation failures, logs them, and rethrows the typed CustomerPortalCreateFailed so callers get a stable error instead of a raw Stripe SDK exception.

Solutions

  1. Check the payment provider (Stripe) configuration and API keys on the server.
  2. Ensure the customer exists in the payment system before creating a portal session.
  3. Retry later; if persistent, inspect server logs for the upstream payment error.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/backend/server/src/plugins/payment/license/controller.ts:273 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/eb5e8d3b7172ee59. Report an issue: GitHub.

Appendix: source

Thrown at packages/backend/server/src/plugins/payment/license/controller.ts:273

    const subscriptionData =
      await this.stripeProvider.stripe.subscriptions.retrieve(
        subscription.externalSubscriptionId,
        {
          expand: ['customer'],
        }
      );

    const customer = subscriptionData.customer as Stripe.Customer;
    try {
      const portal =
        await this.stripeProvider.stripe.billingPortal.sessions.create({
          customer: customer.id,
        });

      return { url: portal.url };
    } catch (e) {
      this.logger.error('Failed to create customer portal.', e);
      throw new CustomerPortalCreateFailed();
    }
  }

  license(subscription: Subscription) {
    return {
      plan: subscription.plan,
      recurring: subscription.recurring,
      quantity: subscription.quantity,
      endAt: subscription.end?.getTime(),
    };
  }
}

View on GitHub (pinned to b4c8548c09)