Hierarchy

  • PaddleSDK

Constructors

  • Example

    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');

    Parameters

    • vendorID: string

      The vendor ID for a Paddle account

    • apiKey: string

      The API key for a Paddle account

    • Optional publicKey: string

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

    • Optional options: Options

    Returns PaddleSDK

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

  • Private

    Type Parameters

    • TResponse

    Parameters

    • response: TResponse[]

    Returns TResponse

  • Private

    Execute a HTTP request

    Type Parameters

    • TResponse

    • TBody extends object = object

    Parameters

    • path: string
    • options: {
          body?: TBody;
          checkoutAPIVersion?: CheckoutAPIVersion;
          form?: boolean;
          headers?: object;
          json?: boolean;
      } = {}
      • Optional body?: TBody

        body parameters / object

      • Optional checkoutAPIVersion?: CheckoutAPIVersion
      • Optional form?: boolean

        serialize the data object to urlencoded format

      • Optional headers?: object

        header parameters

      • Optional json?: boolean

    Returns Promise<TResponse>

  • Create a subscription modifier to dynamically change the subscription payment amount.

    API documentation: https://developer.paddle.com/api-reference/dc2b0c06f0481-create-modifier

    Example

    const result = await client.createSubscriptionModifier(123, 10);
    const result = await client.createSubscriptionModifier(123, 10, { recurring: false, description: 'description' });

    Parameters

    • subscriptionID: number
    • amount: number
    • Optional options: {
          description?: string;
          recurring?: boolean;
      }
      • Optional description?: string
      • Optional recurring?: boolean

    Returns Promise<CreateSubscriptionModifierResponse>

  • Parameters

    • checkoutAPIVersion: CheckoutAPIVersion

    Returns string

  • Get prices

    API documentation: https://developer.paddle.com/api-reference/e268a91845971-get-prices

    Example

    const result = await client.getPrices([123, 456]);
    const result = await client.getPrices([123, 456], { coupons: ['EXAMPLE'], customerCountry: 'GB', customerIp: '127.0.0.1' });

    Parameters

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

    Returns Promise<GetPricesResponse>

  • Get the list of all payments or payments for a subscription plan.

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

    Example

    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);

    Parameters

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

    Returns Promise<GetSubscriptionPaymentsResponse>

  • Get the current list of all users or users for a subscription plan.

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

    Example

    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 });

    Note

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

    Parameters

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

    Returns Promise<GetSubscriptionUsersResponse>

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

    Parameters

    • Optional checkoutAPIVersion: CheckoutAPIVersion

    Returns string

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

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

    Example

    const result = await client.updateSubscriptionPlan(123, { quantity: 2 });
    

    Parameters

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

    Returns Promise<UpdateSubscriptionUserResponse>

  • 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

    Example

    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);

    Parameters

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

      The object with all the parameters sent to the webhook

    Returns boolean

Generated using TypeDoc