Skip to content

Commit 47e8b3e

Browse files
committed
feat: add Shopware webhook payload schemas for order events
1 parent 1893d2d commit 47e8b3e

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {Identifier, Name, Schema} from "@code0-tech/hercules";
2+
import {z} from "zod";
3+
import {schemas} from "../generated/shopware-schemas.ts";
4+
5+
export const ShopwareOrderCancelledPayloadSchema = z.object({
6+
data: z.object({
7+
payload: z.object({
8+
order: schemas.Order,
9+
}),
10+
event: z.literal("state_enter.order.state.cancelled"),
11+
}),
12+
source: z.object({
13+
url: z.string(),
14+
appVersion: z.string(),
15+
shopId: z.string(),
16+
eventId: z.string().optional(),
17+
}),
18+
timestamp: z.number().int(),
19+
});
20+
21+
@Identifier("ShopwareOrderCancelledWebhookPayload")
22+
@Name({code: "en-US", content: "ShopwareOrderCancelledWebhookPayload"})
23+
@Schema(ShopwareOrderCancelledPayloadSchema)
24+
export class ShopwareOrderCancelledWebhookPayload {
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {Identifier, Name, Schema} from "@code0-tech/hercules";
2+
import {z} from "zod";
3+
import {schemas} from "../generated/shopware-schemas.ts";
4+
5+
export const ShopwareOrderPaidPayloadSchema = z.object({
6+
data: z.object({
7+
payload: z.object({
8+
order: schemas.Order,
9+
}),
10+
event: z.literal("state_enter.order_transaction.state.paid"),
11+
}),
12+
source: z.object({
13+
url: z.string(),
14+
appVersion: z.string(),
15+
shopId: z.string(),
16+
eventId: z.string().optional(),
17+
}),
18+
timestamp: z.number().int(),
19+
});
20+
21+
@Identifier("ShopwareOrderPaidWebhookPayload")
22+
@Name({code: "en-US", content: "ShopwareOrderPaidWebhookPayload"})
23+
@Schema(ShopwareOrderPaidPayloadSchema)
24+
export class ShopwareOrderPaidWebhookPayload {
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {Identifier, Name, Schema} from "@code0-tech/hercules";
2+
import {z} from "zod";
3+
import {schemas} from "../generated/shopware-schemas.ts";
4+
5+
export const ShopwareOrderPlacedPayloadSchema = z.object({
6+
data: z.object({
7+
payload: z.object({
8+
order: schemas.Order,
9+
}),
10+
event: z.literal("checkout.order.placed"),
11+
}),
12+
source: z.object({
13+
url: z.string(),
14+
appVersion: z.string(),
15+
shopId: z.string(),
16+
eventId: z.string().optional(),
17+
}),
18+
timestamp: z.number().int(),
19+
});
20+
21+
@Identifier("ShopwareOrderPlacedWebhookPayload")
22+
@Name({code: "en-US", content: "ShopwareOrderPlacedWebhookPayload"})
23+
@Schema(ShopwareOrderPlacedPayloadSchema)
24+
export class ShopwareOrderPlacedWebhookPayload {
25+
}

0 commit comments

Comments
 (0)