File

apps/recallassess/recallassess-api/src/config/stripe.config.ts

Index

Methods
Accessors

Methods

getDashboardAccountMode
getDashboardAccountMode()

Stripe Dashboard deep links must use /test/ when the API key is test mode. See: https://dashboard.stripe.com/test/... vs https://dashboard.stripe.com/...

Returns : "test" | "live"
getWebhookSecrets
getWebhookSecrets()

One or more signing secrets (comma-separated). Stripe CLI stripe listen emits a new whsec_ each run — append it without removing the Dashboard endpoint secret.

Returns : string[]
hasPublishableKey
hasPublishableKey()
Returns : boolean
isConfigured
isConfigured()

Server-side Stripe API calls (subscriptions, webhooks, Checkout Sessions) only need the secret key. The publishable key is for client-side Stripe.js; missing publishable must not block jobs or webhooks.

Returns : boolean

Accessors

secretKey
getsecretKey()
publishableKey
getpublishableKey()
webhookSecret
getwebhookSecret()
import { optionalEnv } from "@bish-nest/core";
import { Injectable } from "@nestjs/common";

@Injectable()
export class StripeConfig {
  // Stripe API Keys
  get secretKey(): string {
    return optionalEnv("STRIPE_SECRET_KEY", "");
  }

  get publishableKey(): string {
    return optionalEnv("STRIPE_PUBLISHABLE_KEY", "");
  }

  get webhookSecret(): string {
    return optionalEnv("STRIPE_WEBHOOK_SECRET", "");
  }

  /** One or more signing secrets (comma-separated). Stripe CLI `stripe listen` emits a new `whsec_` each run — append it without removing the Dashboard endpoint secret. */
  getWebhookSecrets(): string[] {
    return this.webhookSecret
      .split(",")
      .map((s) => s.trim())
      .filter((s) => s.length > 0);
  }

  /**
   * Server-side Stripe API calls (subscriptions, webhooks, Checkout Sessions) only need the secret key.
   * The publishable key is for client-side Stripe.js; missing publishable must not block jobs or webhooks.
   */
  isConfigured(): boolean {
    return !!this.secretKey;
  }

  hasPublishableKey(): boolean {
    return !!this.publishableKey;
  }

  /**
   * Stripe Dashboard deep links must use `/test/` when the API key is test mode.
   * See: https://dashboard.stripe.com/test/... vs https://dashboard.stripe.com/...
   */
  getDashboardAccountMode(): "test" | "live" {
    const sk = this.secretKey;
    if (sk.startsWith("sk_live_") || sk.startsWith("rk_live_")) {
      return "live";
    }
    return "test";
  }
}

results matching ""

    No results matching ""