Back to jobs

New subscription created in Stripe

Trigger: Webhook

Runs when a new subscription is created in Stripe.

Integrations:

/src/stripeOnSubscriptionCreated

Payments

1
import { TriggerClient } from "@trigger.dev/sdk";
2
import { Stripe } from "@trigger.dev/stripe";
3
4
const client = new TriggerClient({ id: "jobs-showcase" });
5
6
const stripe = new Stripe({
7
id: "stripe",
8
apiKey: process.env.STRIPE_API_KEY!,
9
});
10
11
// This job will run when a new subscription is created in Stripe
12
client.defineJob({
13
id: "stripe-on-subscription-created",
14
name: "Stripe: on subscription created",
15
version: "1.0.0",
16
trigger: stripe.onCustomerSubscriptionCreated(),
17
run: async (payload, io, ctx) => {
18
await io.logger.info("A new subscription was created.");
19
},
20
});
21
22
// These lines can be removed if you don't want to use express
23
import { createExpressServer } from "@trigger.dev/express";
24
createExpressServer(client);