Stripe
Manage customers, charges, and subscriptions with webhook event handling.
Authentication
| Type | Default | Details |
|---|---|---|
api_key | ✅ | Secret API key (sk_test_... or sk_live_...) |
oauth_2 | Stripe Connect OAuth |
Secret API keys are sent as Authorization: Bearer <key>. Stripe Connect access tokens ship the same way.
Endpoints
| Path | Risk | Description |
|---|---|---|
customers.get | read | Get a customer. |
customers.create | write | Create a customer. |
customers.update | write | Update a customer. |
charges.get | read | Get a charge. |
subscriptions.list | read | List subscriptions. |
subscriptions.get | read | Get a subscription. |
subscriptions.cancel | destructive | Cancel a subscription (recoverable via reactivation). |
customers.get
Retrieve a customer by ID.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Customer ID (cus_...) |
Output: StripeCustomer
customers.create
Create a new customer.
Input:
| Field | Type | Description |
|---|---|---|
email | string | Customer email |
name | string | Customer name |
description | string | Description |
Output: StripeCustomer
customers.update
Update an existing customer.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Customer ID |
email | string | New email | |
name | string | New name | |
description | string | New description |
Output: StripeCustomer
charges.get
Retrieve a charge by ID.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Charge ID (ch_...) |
Output: StripeCharge
subscriptions.list
List subscriptions with optional filters.
Input:
| Field | Type | Description |
|---|---|---|
customer | string | Filter by customer ID |
status | string | Filter by status |
limit | number | Max results |
Output: { data: StripeSubscription[]; has_more: boolean }
subscriptions.get
Get a subscription by ID.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Subscription ID (sub_...) |
Output: StripeSubscription
subscriptions.cancel
Cancel a subscription at period end.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Subscription 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.
| Event | Path | Description |
|---|---|---|
| Charge failed | charge.failed | A payment attempt failed. |
| Charge succeeded | charge.succeeded | A payment succeeded. |
| Subscription deleted | subscription.deleted | A 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;
}