Create a record in Prisma when a Stripe webhook is received.
npx inngest-cli init --template github.com/inngest/inngest#examples/prisma-typescript-function
Run a background job using the Prisma ORM and TypeScript to create a new entry in the database when a webhook is received from Stripe.
➡️ Check out the related guide: Running Prisma background jobs
stripe/charge.succeeded
webhook404
and doesn't retry, allowing you to handle the edge caseUse this quickstart with a single CLI command to get started! The CLI will then guide you through running, testing, and deploying to Inngest Cloud.
npx inngest-cli init --template github.com/inngest/inngest#examples/prisma-typescript-function
Next, check out how to 👉 trigger the function.
Below is the annotated function definition (found at inngest.json) to show how the above is defined in config.
{
"name": "Prisma background job",
"description": "Create a record in Prisma when a Stripe webhook is received.",
"tags": ["typescript", "prisma", "stripe"],
"id": "cute-troll-547a93",
"triggers": [
{
/**
* When this event is recieved by Inngest, it will start the function
*/
"event": "stripe/charge.succeeded",
"definition": {
"format": "cue",
"synced": true,
/**
* The file that declares the event schema that your app will send to
* Inngest.
*/
"def": "file://./events/stripe-charge-succeeded.cue"
}
}
],
"steps": {
"step-1": {
/**
* This step defines to "after" block, so will be run as soon as the
* trigger above is received.
*/
"id": "step-1",
/**
* This is the directory where your code will be, including its Dockerfile
*/
"path": "file://./steps/step-1",
"name": "Prisma background job",
"runtime": {
"type": "docker"
}
}
}
}
This function has a single step: steps/step-1
, which is triggered by the stripe/charge.succeeded
event.
Finds the relevant user in the database and creates a new charge record if it could be found.
To receive Stripe events in your Inngest account, you can connect Stripe via OAuth. To do this, create a new Source. This will link your Stripe and Inngest accounts so that we can automatically receive events as they happen.
Alternatively, you can send your own events from your own apps or any webhook and run any function automatically.