Back to APIs

Subscribe to user updates, automate payments, billing and more.

Using our official Stripe integration

Easily subscribe to Stripe webhooks to trigger your jobs.

Create any tasks possible with the Stripe API.

Use io.runTask() and the official SDK or fetch.

Stripe integration docs

Example code using Stripe

Below are some working code examples of how you can use Stripe with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

1
import { SupabaseManagement, Supabase } from "@trigger.dev/supabase";
2
import { Stripe } from "@trigger.dev/stripe";
3
import { TriggerClient } from "@trigger.dev/sdk";
4
5
export const stripe = new Stripe({
6
id: "stripe",
7
apiKey: process.env.STRIPE_API_KEY!,
8
});
9
10
const supabase = new Supabase({
11
id: "supabase",
12
supabaseUrl: process.env.SUPABASE_PUBLIC_URL!,
13
supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY!,
14
});
15
16
// Use OAuth to authenticate with Supabase Management API
17
const supabaseManagement = new SupabaseManagement({
18
id: "supabase-management",
19
});
20
21
// Update a Supabase table when a Stripe account is updated
22
client.defineJob({
23
id: "supabase-stripe-update-database",
24
name: "Supabase: update database when Stripe account is updated",
25
version: "1.0.0",
26
integrations: {
27
stripe,
28
supabase,
29
},
30
trigger: stripe.onAccountUpdated({ connect: true }),
31
run: async (payload, io, ctx) => {
32
const stripeAccountId = payload.id;
33
const { payouts_enabled, charges_enabled, details_submitted } = payload;
34
35
const updatedAt = new Date().toISOString();
36
37
await io.supabase.runTask("update-stripe-account", async (database) => {
38
const { data, error } = await database
39
.from("accounts")
40
.update({
41
payouts_enabled,
42
charges_enabled,
43
details_submitted,
44
updated_at: updatedAt,
45
})
46
.eq("stripe_account_id", stripeAccountId);
47
48
if (error) throw error;
49
50
return data;
51
});
52
},
53
});