(customerPortal.customers)
- get - Get Customer
- update - Update Customer
- getPaymentMethods - Get Customer Payment Methods
- addPaymentMethod - Add Customer Payment Method
- deletePaymentMethod - Delete Customer Payment Method
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"] ?? "",
});
// Handle the result
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) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
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.
Scopes: customer_portal:write
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"] ?? "",
}, {});
// Handle the result
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"] ?? "",
}, {});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
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.
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.getPaymentMethods({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {});
for await (const page of result) {
// Handle the page
console.log(page);
}
}
run();
The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalCustomersGetPaymentMethods } from "@polar-sh/sdk/funcs/customerPortalCustomersGetPaymentMethods.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 customerPortalCustomersGetPaymentMethods(polar, {
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
for await (const page of result) {
// Handle the page
console.log(page);
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.CustomerPortalCustomersGetPaymentMethodsRequest | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersGetPaymentMethodsSecurity | ✔️ | 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.CustomerPortalCustomersGetPaymentMethodsResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Add a payment method to the 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.addPaymentMethod({
customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
}, {
confirmationTokenId: "<id>",
setDefault: false,
returnUrl: "https://slight-digestive.info",
});
// Handle the result
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://slight-digestive.info",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
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<operations.CustomerPortalCustomersAddPaymentMethodResponseCustomerPortalCustomersAddPaymentMethod>
Error Type | Status Code | Content Type |
---|---|---|
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Delete a payment method from the authenticated customer.
Scopes: customer_portal:read
customer_portal:write
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) {
throw res.error;
}
const { value: result } = res;
}
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.ResourceNotFound | 404 | application/json |
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4XX, 5XX | */* |