2.1.8 • Published 3 years ago

paddle-webhook-utils v2.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Paddle Webhook Utils

This package consists of TypeScript declarations for Paddle webhook payloads, as well as a utility function to verify these payloads.

Installation

yarn add paddle-webhook-utils

Usage

Example code snippet for an Express app:

import { PaymentRefunded, validatePaddleWebhook } from "paddle-webhook-utils";

app.post("/paddleWebhook", async (req, res) => {
  if (
    validatePaddleWebhook({
      webhookData: req.body,
      publicKey: config.PADDLE_PUBLIC_KEY!,
    })
  ) {
    // handle payload
    if (req.body?.alert_name === "payment_refunded") {
      const prBody = req.body as PaymentRefunded;
      // ...
    }
  }
});

Types available for:

  • Subscription Alerts
    • Subscription Created
    • Subscription Updated
    • Subscription Cancelled
    • Subscription Payment Succeeded
    • Subscription Payment Failed
    • Subscription Payment Refunded
  • One-off purchase Alerts
    • Payment Succeeded
    • Payment Refunded
    • Order Processing Completed

Caveats

The declarations are generated from the JSON schemas provided in Paddle's developer documentation. In the interest of staying true to the provided schemas, I do not plan on modifying the generated types. This is why, for example, you won't see an AlertName enum with all the possible alert names, since the JSON schemas specify alert names as string.

I may add more utility functions in the future if appropriate.

2.1.8

3 years ago

2.1.7

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.0.3

3 years ago