npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@devoxa/paddle-sdk

v0.4.2

Published

An SDK to interface with the API and webhooks from paddle.com

Downloads

220

Readme

Installation

yarn add @devoxa/paddle-sdk

Usage

:warning: This package does not implement all available webhook events and API routes. It should have the ones required for 90% of subscription based applications, but if you are missing something feel free to add them via a pull request!

import { PaddleSdk, stringifyMetadata } from '@devoxa/paddle-sdk'

// The metadata you want to attach to subscriptions, to link them to your application entities
type PaddleMetadata = { userId: number }

const paddleSdk = new PaddleSdk<PaddleMetadata>({
  baseUrl: 'https://vendors.paddle.com/api', // (Optional) The base URL of the paddle API (e.g. to use the sandbox)
  publicKey: '...', // Your public key from the paddle dashboard
  vendorId: 123, // Your vendor ID from the paddle dashboard
  vendorAuthCode: 'AAA', // Your vendor auth code from the paddle dashboard
  metadataCodec: stringifyMetadata(), // JSON stringify and parse additional order data
})

Available Methods

verifyWebhookEvent(body: any): boolean
parseWebhookEvent(body: any): PaddleSdkSubscriptionCreatedEvent | PaddleSdkSubscriptionUpdatedEvent | ...
async createProductPayLink(data: PaddleSdkCreateProductPayLinkRequest): Promise<PaddleSdkCreateProductPayLinkResponse>
async listSubscriptions(data: PaddleSdkListSubscriptionsRequest): Promise<PaddleSdkListSubscriptionsResponse>
async updateSubscription(data: PaddleSdkUpdateSubscriptionRequest): Promise<PaddleSdkUpdateSubscriptionResponse>
async cancelSubscription(data: PaddleSdkCancelSubscriptionRequest): Promise<PaddleSdkCancelSubscriptionResponse>
async createSubscriptionModifier(data: PaddleSdkCreateSubscriptionModifierRequest): Promise<PaddleSdkCreateSubscriptionModifierResponse>

A note on parsing webhooks:

If you are using parseWebhookEvent on raw events, only enable the following events in your dashboard to prevent ImplementationMissing errors being thrown.

Passthrough Data

During the checkout stage Paddle allows passing additional data to your webhooks in the passthrough strings via either the client-side JavaScript API or the server-side Pay Link API. See the official documentation for more details. It's your responsibility to properly convert your data structures to/from such a string. This project offers you a few such converters in the form of metadata codecs which stringify/parse metadata values to/from passthrough strings:

  • ignoreMetadata is a codec which ignores metadata values. It stringifies any value to an empty string, and parses any string to a null value.
  • passthroughMetadata is a codec which assumes your metadata values are already strings and passes them unmodified.
  • stringifyMetadata is a codec which JSON stringifies/parses your metadata values to/from passthrough strings.
  • encryptMetadata is a wrapper which must be used to decorate any of the above codecs. It applies symmetric encryption to the passthrough strings generated by the wrapped codec to prevent users from tampering with your data.

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT