Integrations / Payments / Paddle

๐Ÿ“

Paddle

Connect Paddle's webhooks to LogIt and get alerts on every transaction, subscription update, and refund.


Setup

In your Paddle dashboard, go to Developer Tools โ†’ Notifications โ†’ New destination.

Set the URL to https://yourdomain.com/api/webhooks/paddle and subscribe to:

  • transaction.completed
  • subscription.canceled
  • transaction.payment_failed

Install

bash
npm install logit @paddle/paddle-node-sdk

Handler (Next.js App Router)

ts
// app/api/webhooks/paddle/route.ts
import { Paddle, EventName } from "@paddle/paddle-node-sdk";
import { init } from "logit";

const paddle = new Paddle(process.env.PADDLE_API_KEY!);
const logit = init({ token: process.env.LOGIT_API_KEY! });

export async function POST(req: Request) {
  const body = await req.text();
  const signature = req.headers.get("paddle-signature") ?? "";

  const event = await paddle.webhooks.unmarshal(body, process.env.PADDLE_WEBHOOK_SECRET!, signature);

  if (!event) return new Response("Invalid signature", { status: 401 });

  switch (event.eventType) {
    case EventName.TransactionCompleted: {
      const tx = event.data;
      await logit.now("payments", {
        event: "Paddle transaction completed",
        description: `${tx.customData ?? tx.id}`,
        icon: "๐Ÿ“",
        notify: true,
        tags: { currency: tx.currencyCode },
        metadata: { transactionId: tx.id },
      });
      break;
    }
    case EventName.SubscriptionCanceled: {
      const sub = event.data;
      await logit.now("churn", {
        event: "Paddle subscription cancelled",
        icon: "๐Ÿ˜ข",
        notify: true,
        metadata: { subscriptionId: sub.id, customerId: sub.customerId },
      });
      break;
    }
  }

  return new Response("ok");
}

Environment variables

bash
LOGIT_API_KEY=lk_live_xxxxxxxxxxxxxxxx
PADDLE_API_KEY=your_paddle_api_key
PADDLE_WEBHOOK_SECRET=your_webhook_secret

Ready to connect Paddle?

7-day free trial. No credit card required.

Start free