Paddle SDK - v5.0.0
    Preparing search index...

    Class PaddleSDK

    Index

    Constructors

    • Parameters

      • vendorID: string

        The vendor ID for a Paddle account

      • apiKey: string

        The API key for a Paddle account

      • OptionalpublicKey: string

        The public key for a Paddle account used to verify webhooks, only required for verifyWebhookData

      • Optionaloptions: Options

      Returns PaddleSDK

      const client = new PaddleSDK('your-vendor-id', 'your-unique-api-key');
      const client = new PaddleSDK('your-vendor-id', 'your-unique-api-key', 'your-public-key');

    Properties

    apiKey: string

    The API key for a Paddle account

    options?: Options
    publicKey: string

    The public key for a Paddle account used to verify webhooks, only required for verifyWebhookData

    vendorID: string

    The vendor ID for a Paddle account

    Methods

    • Parameters

      • productIDs: number[]
      • Optionaloptions: { coupons?: string[]; customerCountry?: string; customerIp?: string }

      Returns Promise<GetPricesResponse>

      const result = await client.getPrices([123, 456]);
      const result = await client.getPrices([123, 456], { coupons: ['EXAMPLE'], customerCountry: 'GB', customerIp: '127.0.0.1' });
    • Get the list of all payments or payments for a subscription plan.

      API documentation: https://developer.paddle.com/api-reference/80462f27b2011-list-payments

      Parameters

      • Optionaloptions:
            | number
            | {
                from?: Date;
                isOneOffCharge?: boolean;
                isPaid?: boolean;
                planID?: number;
                subscriptionID?: number;
                to?: Date;
            }

      Returns Promise<GetSubscriptionPaymentsResponse>

      const payments = await client.getSubscriptionPayments();
      const payments = await client.getSubscriptionPayments({ subscriptionID: 123 });
      Legacy usage for backwards compatibility: pass planID as a number instead of options object
      const payments = await client.getSubscriptionPayments(123);
    • Get the current list of all users or users for a subscription plan.

      API documentation: https://developer.paddle.com/api-reference/e33e0a714a05d-list-users

      Parameters

      • Optionaloptions: {
            page?: number;
            planID?: string | number;
            resultsPerPage?: number;
            state?: SubscriptionUserState;
            subscriptionID?: number;
        }

      Returns Promise<GetSubscriptionUsersResponse>

      const users = await client.getUsers();
      const users = await client.getUsers({ planID: 123 });
      const users = await client.getUsers({ state: 'active' });
      const users = await client.getUsers({ subscriptionID: 456 });

      If you have a large amount of active users, you will need to create paginated calls to this function.

    • Get the used server URL. Some of the requests go to Checkout server, while most will go to Vendor server.

      Parameters

      • OptionalcheckoutAPIVersion: CheckoutAPIVersion

      Returns string

    • Update subscription details, quantity, price and or currency.

      API documentation: https://developer.paddle.com/api-reference/e3872343dfbba-update-user

      Parameters

      • subscriptionID: number
      • postData: {
            billImmediately?: boolean;
            currency?: string;
            keepModifiers?: boolean;
            passthrough?: string;
            pause?: boolean;
            planID?: number;
            price?: number;
            prorate?: boolean;
            quantity?: number;
        }

      Returns Promise<UpdateSubscriptionUserResponse>

      const result = await client.updateSubscriptionPlan(123, { quantity: 2 });
      
    • Verify a webhook alert data using signature and a public key to validate that it was indeed sent from Paddle.

      For more details: https://paddle.com/docs/reference-verifying-webhooks

      Parameters

      • postData: { p_signature: string } & Record<string, unknown>

        The object with all the parameters sent to the webhook

      Returns boolean

      const client = new PaddleSDK('your-vendor-id', 'your-unique-api-key', 'your-public-key');

      // inside an Express handler which uses express.bodyParser middleware
      const isVerified = client.verifyWebhookData(req.body);