FabricFabricSDK
Plugins

Stripe

Manage customers, charges, and subscriptions with webhook event handling.

Authentication

TypeDefaultDetails
api_keySecret API key (sk_test_... or sk_live_...)
oauth_2Stripe Connect OAuth

Secret API keys are sent as Authorization: Bearer <key>. Stripe Connect access tokens ship the same way.

Endpoints

PathRiskDescription
customers.getreadGet a customer.
customers.createwriteCreate a customer.
customers.updatewriteUpdate a customer.
charges.getreadGet a charge.
subscriptions.listreadList subscriptions.
subscriptions.getreadGet a subscription.
subscriptions.canceldestructiveCancel a subscription (recoverable via reactivation).

customers.get

Retrieve a customer by ID.

Input:

FieldTypeRequiredDescription
idstringCustomer ID (cus_...)

Output: StripeCustomer

customers.create

Create a new customer.

Input:

FieldTypeDescription
emailstringCustomer email
namestringCustomer name
descriptionstringDescription

Output: StripeCustomer

customers.update

Update an existing customer.

Input:

FieldTypeRequiredDescription
idstringCustomer ID
emailstringNew email
namestringNew name
descriptionstringNew description

Output: StripeCustomer

charges.get

Retrieve a charge by ID.

Input:

FieldTypeRequiredDescription
idstringCharge ID (ch_...)

Output: StripeCharge

subscriptions.list

List subscriptions with optional filters.

Input:

FieldTypeDescription
customerstringFilter by customer ID
statusstringFilter by status
limitnumberMax results

Output: { data: StripeSubscription[]; has_more: boolean }

subscriptions.get

Get a subscription by ID.

Input:

FieldTypeRequiredDescription
idstringSubscription ID (sub_...)

Output: StripeSubscription

subscriptions.cancel

Cancel a subscription at period end.

Input:

FieldTypeRequiredDescription
idstringSubscription ID

Output: StripeSubscription

Usage

import { createFabric } from "@fabricorg/integrations";
import { stripe } from "@fabricorg/integrations/plugins";

const fabric = createFabric({
  plugins: [
    stripe({
      apiKey: process.env.STRIPE_SECRET_KEY,
      webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
    }),
  ],
});

// Create a customer
const customer = await fabric.stripe.api.customers.create({
  email: "alice@example.com",
  name: "Alice Smith",
});

// List active subscriptions
const { data: subs } = await fabric.stripe.api.subscriptions.list({
  customer: customer.id,
  status: "active",
});

Webhooks

Stripe sends event webhooks for payment lifecycle events. The plugin includes verifyStripeSignature for validating webhook signatures.

EventPathDescription
Charge failedcharge.failedA payment attempt failed.
Charge succeededcharge.succeededA payment succeeded.
Subscription deletedsubscription.deletedA subscription was canceled.

Signature verification

import { verifyStripeSignature } from "@fabricorg/integrations/plugins";

const valid = verifyStripeSignature({
  rawBody: requestBody,
  signatureHeader: headers["stripe-signature"],
  secret: process.env.STRIPE_WEBHOOK_SECRET,
});

Webhook payload schema

const StripeEventEnvelopeSchema = z.object({
  id: z.string(),
  type: z.string(),
  created: z.number(),
  livemode: z.boolean(),
  data: z.object({ object: z.unknown() }),
});

Types

interface StripeCustomer {
  id: string;
  email: string | null;
  name: string | null;
  description: string | null;
  created?: number;
  metadata?: Record<string, string>;
}

interface StripeCharge {
  id: string;
  amount: number;
  currency: string;
  customer: string | null;
  status: string;
  paid?: boolean;
  failure_code: string | null;
  failure_message: string | null;
}

interface StripeSubscription {
  id: string;
  customer: string;
  status: string;
  current_period_end?: number;
  cancel_at_period_end?: boolean;
}