- get - Get Customer
- update - Update Customer
- listPaymentMethods - List Customer Payment Methods
- addPaymentMethod - Add Customer Payment Method
- confirmPaymentMethod - Confirm Customer Payment Method
- deletePaymentMethod - Delete Customer Payment Method
- requestEmailUpdate - Request Email Change
- checkEmailUpdate - Check Email Change Token
- verifyEmailUpdate - Verify Email Change
Get authenticated customer.
Scopes: customer_portal:read customer_portal:write
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
const result = await polar.customerPortal.customers.get({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersGet } from "@polar-sh/sdk/funcs/customerPortalCustomersGet.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 customerPortalCustomersGet(polar, {
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("customerPortalCustomersGet failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
security |
operations.CustomerPortalCustomersGetSecurity | ✔️ | 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. |
Promise<components.CustomerPortalCustomer>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |
Update authenticated customer.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
const result = await polar.customerPortal.customers.update({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
billingAddress: {
country: "US",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersUpdate } from "@polar-sh/sdk/funcs/customerPortalCustomersUpdate.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 customerPortalCustomersUpdate(polar, {
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
billingAddress: {
country: "US",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("customerPortalCustomersUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.CustomerPortalCustomerUpdate | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersUpdateSecurity | ✔️ | 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. |
Promise<components.CustomerPortalCustomer>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Get saved payment methods of the authenticated customer.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
const result = await polar.customerPortal.customers.listPaymentMethods({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {});
for await (const page of result) {
console.log(page);
}
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersListPaymentMethods } from "@polar-sh/sdk/funcs/customerPortalCustomersListPaymentMethods.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 customerPortalCustomersListPaymentMethods(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("customerPortalCustomersListPaymentMethods failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CustomerPortalCustomersListPaymentMethodsRequest | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersListPaymentMethodsSecurity | ✔️ | 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. |
Promise<operations.CustomerPortalCustomersListPaymentMethodsResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Add a payment method to the authenticated customer.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
const result = await polar.customerPortal.customers.addPaymentMethod({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
confirmationTokenId: "<id>",
setDefault: false,
returnUrl: "https://yearly-custom.net/",
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersAddPaymentMethod } from "@polar-sh/sdk/funcs/customerPortalCustomersAddPaymentMethod.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 customerPortalCustomersAddPaymentMethod(polar, {
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
confirmationTokenId: "<id>",
setDefault: false,
returnUrl: "https://yearly-custom.net/",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("customerPortalCustomersAddPaymentMethod failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.CustomerPaymentMethodCreate | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersAddPaymentMethodSecurity | ✔️ | 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. |
Promise<components.CustomerPaymentMethodCreateResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.PaymentMethodSetupFailed | 400 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Confirm a payment method for the authenticated customer.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
const result = await polar.customerPortal.customers.confirmPaymentMethod({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
setupIntentId: "<id>",
setDefault: true,
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersConfirmPaymentMethod } from "@polar-sh/sdk/funcs/customerPortalCustomersConfirmPaymentMethod.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 customerPortalCustomersConfirmPaymentMethod(polar, {
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
setupIntentId: "<id>",
setDefault: true,
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("customerPortalCustomersConfirmPaymentMethod failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.CustomerPaymentMethodConfirm | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersConfirmPaymentMethodSecurity | ✔️ | 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. |
Promise<components.CustomerPaymentMethodCreateResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.CustomerNotReady | 400 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Delete a payment method from the authenticated customer.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
await polar.customerPortal.customers.deletePaymentMethod({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
id: "<id>",
});
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersDeletePaymentMethod } from "@polar-sh/sdk/funcs/customerPortalCustomersDeletePaymentMethod.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 customerPortalCustomersDeletePaymentMethod(polar, {
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
id: "<id>",
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("customerPortalCustomersDeletePaymentMethod failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CustomerPortalCustomersDeletePaymentMethodRequest | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersDeletePaymentMethodSecurity | ✔️ | 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. |
Promise<void>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.PaymentMethodInUseByActiveSubscription | 400 | application/json |
| errors.ResourceNotFound | 404 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Request an email change for the authenticated customer.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
const result = await polar.customerPortal.customers.requestEmailUpdate({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
email: "Tommie_Larkin78@gmail.com",
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersRequestEmailUpdate } from "@polar-sh/sdk/funcs/customerPortalCustomersRequestEmailUpdate.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 customerPortalCustomersRequestEmailUpdate(polar, {
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
email: "Tommie_Larkin78@gmail.com",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("customerPortalCustomersRequestEmailUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.CustomerEmailUpdateRequest | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersRequestEmailUpdateSecurity | ✔️ | 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. |
Promise<any>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Check if an email change verification token is still valid.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
await polar.customerPortal.customers.checkEmailUpdate({
token: "<value>",
});
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersCheckEmailUpdate } from "@polar-sh/sdk/funcs/customerPortalCustomersCheckEmailUpdate.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 customerPortalCustomersCheckEmailUpdate(polar, {
token: "<value>",
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("customerPortalCustomersCheckEmailUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CustomerPortalCustomersCheckEmailUpdateRequest | ✔️ | 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. |
Promise<void>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Verify an email change using the token from the verification email.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar();
async function run() {
const result = await polar.customerPortal.customers.verifyEmailUpdate({
token: "<value>",
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersVerifyEmailUpdate } from "@polar-sh/sdk/funcs/customerPortalCustomersVerifyEmailUpdate.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 customerPortalCustomersVerifyEmailUpdate(polar, {
token: "<value>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("customerPortalCustomersVerifyEmailUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.CustomerEmailUpdateVerifyRequest | ✔️ | 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. |
Promise<components.CustomerEmailUpdateVerifyResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |