Skip to content

Latest commit

 

History

History
406 lines (296 loc) · 29.8 KB

File metadata and controls

406 lines (296 loc) · 29.8 KB

CheckoutLinks

Overview

Available Operations

  • list - List Checkout Links
  • create - Create Checkout Link
  • get - Get Checkout Link
  • delete - Delete Checkout Link
  • update - Update Checkout Link

list

List checkout links.

Scopes: checkout_links:read checkout_links:write

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.checkoutLinks.list({
    organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
  });

  for await (const page of result) {
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { checkoutLinksList } from "@polar-sh/sdk/funcs/checkoutLinksList.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await checkoutLinksList(polar, {
    organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
  });
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("checkoutLinksList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CheckoutLinksListRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CheckoutLinksListResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

create

Create a checkout link.

Scopes: checkout_links:write

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.checkoutLinks.create({
    paymentProcessor: "stripe",
    allowDiscountCodes: true,
    requireBillingAddress: false,
    productPriceId: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { checkoutLinksCreate } from "@polar-sh/sdk/funcs/checkoutLinksCreate.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await checkoutLinksCreate(polar, {
    paymentProcessor: "stripe",
    allowDiscountCodes: true,
    requireBillingAddress: false,
    productPriceId: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("checkoutLinksCreate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.CheckoutLinkCreate ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CheckoutLink>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get

Get a checkout link by ID.

Scopes: checkout_links:read checkout_links:write

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.checkoutLinks.get({
    id: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { checkoutLinksGet } from "@polar-sh/sdk/funcs/checkoutLinksGet.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await checkoutLinksGet(polar, {
    id: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("checkoutLinksGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CheckoutLinksGetRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CheckoutLink>

Errors

Error Type Status Code Content Type
errors.ResourceNotFound 404 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

delete

Delete a checkout link.

Scopes: checkout_links:write

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  await polar.checkoutLinks.delete({
    id: "<value>",
  });


}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { checkoutLinksDelete } from "@polar-sh/sdk/funcs/checkoutLinksDelete.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await checkoutLinksDelete(polar, {
    id: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("checkoutLinksDelete failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CheckoutLinksDeleteRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<void>

Errors

Error Type Status Code Content Type
errors.ResourceNotFound 404 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

update

Update a checkout link.

Scopes: checkout_links:write

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.checkoutLinks.update({
    id: "<value>",
    checkoutLinkUpdate: {},
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { checkoutLinksUpdate } from "@polar-sh/sdk/funcs/checkoutLinksUpdate.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await checkoutLinksUpdate(polar, {
    id: "<value>",
    checkoutLinkUpdate: {},
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("checkoutLinksUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CheckoutLinksUpdateRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CheckoutLink>

Errors

Error Type Status Code Content Type
errors.ResourceNotFound 404 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*