NuroDev / lemonsqueezy.ts

🍋 JavaScript / TypeScript SDK for the Lemon Squeezy API
https://paka.dev/npm/lemonsqueezy.ts
MIT License
158 stars 17 forks source link

feat: add webhook event constructor #23

Open carstenlebek opened 1 year ago

carstenlebek commented 1 year ago

I have added a webhook event constructor similar to stripe.

import { constructEvent } from "lemonsqueezy.ts";

const event = constructEvent(
    "RAW_REQUEST_BODY",
    "X-Signature HEADER_VALUE",
    "YOUR_WEBHOOK_SECRET"
)

switch (event.type) {
    case "order_created":
        const order = event.data;
        break;
    case "order_refunded":
        const order = event.data;
        break;
    case "subscription_created":
        const subscription = event.data;
        break;
    default:
        break;
}