-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it easier to get started with webhooks by:
1. Providing the config for mandatory webhook topics 2. Adding a product create webhook, so partners can see a webhook trigger when pressing "generte a product" 3. Separating each webhook topic into it's own URL
- Loading branch information
1 parent
93b9952
commit 3bf02fb
Showing
8 changed files
with
110 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { ActionFunctionArgs } from "@remix-run/node"; | ||
import { authenticate } from "~/shopify.server"; | ||
import db from "~/db.server"; | ||
|
||
export const action = async ({ request }: ActionFunctionArgs) => { | ||
const { shop, session } = await authenticate.webhook(request); | ||
|
||
// Webhook requests can trigger after an app is uninstalled. | ||
// If the app is already uninstalled, the session may be undefined. | ||
if (session) { | ||
db.session.deleteMany({ where: { shop } }); | ||
} | ||
|
||
return new Response(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { ActionFunctionArgs } from "@remix-run/node"; | ||
import { authenticate } from "~/shopify.server"; | ||
|
||
export const action = async ({ request }: ActionFunctionArgs) => { | ||
const { session } = await authenticate.webhook(request); | ||
|
||
// Webhook requests can trigger after an app is uninstalled | ||
// If the app is already uninstalled, the session may be undefined. | ||
if (!session) { | ||
throw new Response(); | ||
} | ||
|
||
// Implement handling of mandatory compliance topics | ||
// See: https://shopify.dev/docs/apps/build/privacy-law-compliance | ||
console.log("Received customers data_request webhook"); | ||
|
||
return new Response(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { ActionFunctionArgs } from "@remix-run/node"; | ||
import { authenticate } from "~/shopify.server"; | ||
|
||
export const action = async ({ request }: ActionFunctionArgs) => { | ||
const {session} = await authenticate.webhook(request); | ||
|
||
// Webhook requests can trigger after an app is uninstalled | ||
// If the app is already uninstalled, the session may be undefined. | ||
if (!session) { | ||
throw new Response(); | ||
} | ||
|
||
// Implement handling of mandatory compliance topics | ||
// See: https://shopify.dev/docs/apps/build/privacy-law-compliance | ||
console.log("Received customers redact webhook"); | ||
|
||
return new Response(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { ActionFunctionArgs } from "@remix-run/node"; | ||
import { authenticate } from "~/shopify.server"; | ||
|
||
export const action = async ({ request }: ActionFunctionArgs) => { | ||
const { session, payload } = await authenticate.webhook(request); | ||
|
||
// Webhook requests can trigger after an app is uninstalled | ||
// If the app is already uninstalled, the session may be undefined. | ||
if (!session) { | ||
return new Response() | ||
} | ||
|
||
console.log("Received products create webhook"); | ||
console.log(JSON.stringify(payload)); | ||
|
||
return new Response(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { ActionFunctionArgs } from "@remix-run/node"; | ||
import { authenticate } from "~/shopify.server"; | ||
|
||
export const action = async ({ request }: ActionFunctionArgs) => { | ||
const { session } = await authenticate.webhook(request); | ||
|
||
// SHOP_REDACT will be fired up to 48 hours after app is uninstalled | ||
// Therefore, for SHOP_REDACT we expect the admin to be undefined | ||
if (!session) { | ||
return new Response("", { status: 400 }); | ||
} | ||
|
||
// Implement handling of mandatory compliance topics | ||
// See: https://shopify.dev/docs/apps/build/privacy-law-compliance | ||
console.log("Received shop redact webhook"); | ||
|
||
return new Response(); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters