Skip to content

Latest commit

 

History

History
636 lines (473 loc) · 54.6 KB

File metadata and controls

636 lines (473 loc) · 54.6 KB

CustomerPortal.Orders

Overview

Available Operations

list

List orders of the authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.orders.list({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {});

  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 { customerPortalOrdersList } from "@polar-sh/sdk/funcs/customerPortalOrdersList.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalOrdersList(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {});
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("customerPortalOrdersList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalOrdersListRequest ✔️ The request object to use for the request.
security operations.CustomerPortalOrdersListSecurity ✔️ The security requirements 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.CustomerPortalOrdersListResponse>

Errors

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

get

Get an order by ID for the authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.orders.get({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalOrdersGet(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalOrdersGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalOrdersGetRequest ✔️ The request object to use for the request.
security operations.CustomerPortalOrdersGetSecurity ✔️ The security requirements 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.CustomerOrder>

Errors

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

update

Update an order for the authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.orders.update({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
    customerOrderUpdate: {
      billingAddress: {
        country: "US",
      },
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalOrdersUpdate(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
    customerOrderUpdate: {
      billingAddress: {
        country: "US",
      },
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalOrdersUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalOrdersUpdateRequest ✔️ The request object to use for the request.
security operations.CustomerPortalOrdersUpdateSecurity ✔️ The security requirements 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.CustomerOrder>

Errors

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

invoice

Get an order's invoice data.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.orders.invoice({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalOrdersInvoice(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalOrdersInvoice failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalOrdersInvoiceRequest ✔️ The request object to use for the request.
security operations.CustomerPortalOrdersInvoiceSecurity ✔️ The security requirements 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.CustomerOrderInvoice>

Errors

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

generateInvoice

Trigger generation of an order's invoice.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.orders.generateInvoice({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalOrdersGenerateInvoice(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalOrdersGenerateInvoice failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalOrdersGenerateInvoiceRequest ✔️ The request object to use for the request.
security operations.CustomerPortalOrdersGenerateInvoiceSecurity ✔️ The security requirements 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<any>

Errors

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

receipt

Get a presigned URL to download an order's receipt PDF.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.orders.receipt({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalOrdersReceipt(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalOrdersReceipt failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalOrdersReceiptRequest ✔️ The request object to use for the request.
security operations.CustomerPortalOrdersReceiptSecurity ✔️ The security requirements 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.CustomerOrderReceipt>

Errors

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

getPaymentStatus

Get the current payment status for an order.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.orders.getPaymentStatus({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalOrdersGetPaymentStatus(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalOrdersGetPaymentStatus failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalOrdersGetPaymentStatusRequest ✔️ The request object to use for the request.
security operations.CustomerPortalOrdersGetPaymentStatusSecurity ✔️ The security requirements 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.CustomerOrderPaymentStatus>

Errors

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

confirmRetryPayment

Confirm a retry payment using a Stripe confirmation token.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.orders.confirmRetryPayment({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
    customerOrderConfirmPayment: {},
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalOrdersConfirmRetryPayment(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<value>",
    customerOrderConfirmPayment: {},
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalOrdersConfirmRetryPayment failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalOrdersConfirmRetryPaymentRequest ✔️ The request object to use for the request.
security operations.CustomerPortalOrdersConfirmRetryPaymentSecurity ✔️ The security requirements 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.CustomerOrderPaymentConfirmation>

Errors

Error Type Status Code Content Type
errors.ResourceNotFound 404 application/json
errors.PaymentAlreadyInProgress 409 application/json
errors.OrderNotEligibleForRetry 422 application/json
errors.ManualRetryLimitExceeded 429 application/json
errors.SDKError 4XX, 5XX */*