Subscriptions
March 12, 2025 ยท View on GitHub
(subscriptions)
Overview
Available Operations
create
Example Usage
import { OpenBilling } from "open-billing";
const openBilling = new OpenBilling({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const result = await openBilling.subscriptions.create({
status: "past_due",
currencyCode: "NZD",
customerId: "<id>",
addressId: "<id>",
items: [
{
priceId: "<id>",
quantity: "<value>",
},
],
billingDetails: {
paymentTerms: {
paymentInterval: "day",
paymentFrequency: 690.25,
},
enableCheckout: false,
additionalInformation: "<value>",
purchaseOrderNumber: "<value>",
},
});
// Handle the result
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { OpenBillingCore } from "open-billing/core.js";
import { subscriptionsCreate } from "open-billing/funcs/subscriptionsCreate.js";
// Use `OpenBillingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const openBilling = new OpenBillingCore({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const res = await subscriptionsCreate(openBilling, {
status: "past_due",
currencyCode: "NZD",
customerId: "<id>",
addressId: "<id>",
items: [
{
priceId: "<id>",
quantity: "<value>",
},
],
billingDetails: {
paymentTerms: {
paymentInterval: "day",
paymentFrequency: 690.25,
},
enableCheckout: false,
additionalInformation: "<value>",
purchaseOrderNumber: "<value>",
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.SubscriptionCreateRequestBody | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | 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 | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.SubscriptionCreateResponseBody>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SubscriptionCreateResponseBody | 400 | application/json |
| errors.APIError | 4XX, 5XX | */* |
list
Example Usage
import { OpenBilling } from "open-billing";
const openBilling = new OpenBilling({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const result = await openBilling.subscriptions.list({});
// Handle the result
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { OpenBillingCore } from "open-billing/core.js";
import { subscriptionsList } from "open-billing/funcs/subscriptionsList.js";
// Use `OpenBillingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const openBilling = new OpenBillingCore({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const res = await subscriptionsList(openBilling, {});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.SubscriptionListRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | 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 | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.SubscriptionListResponseBody[]>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
cancel
Example Usage
import { OpenBilling } from "open-billing";
const openBilling = new OpenBilling({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const result = await openBilling.subscriptions.cancel({
subscriptionId: "<id>",
requestBody: {},
});
// Handle the result
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { OpenBillingCore } from "open-billing/core.js";
import { subscriptionsCancel } from "open-billing/funcs/subscriptionsCancel.js";
// Use `OpenBillingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const openBilling = new OpenBillingCore({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const res = await subscriptionsCancel(openBilling, {
subscriptionId: "<id>",
requestBody: {},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.SubscriptionCancelSubscriptionRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | 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 | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.SubscriptionCancelSubscriptionResponseBody>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SubscriptionCancelSubscriptionResponseBody | 400 | application/json |
| errors.SubscriptionCancelSubscriptionSubscriptionsResponseBody | 404 | application/json |
| errors.APIError | 4XX, 5XX | */* |
pause
Example Usage
import { OpenBilling } from "open-billing";
const openBilling = new OpenBilling({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const result = await openBilling.subscriptions.pause({
subscriptionId: "<id>",
requestBody: {
onResume: "continue_existing_billing_period",
},
});
// Handle the result
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { OpenBillingCore } from "open-billing/core.js";
import { subscriptionsPause } from "open-billing/funcs/subscriptionsPause.js";
// Use `OpenBillingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const openBilling = new OpenBillingCore({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const res = await subscriptionsPause(openBilling, {
subscriptionId: "<id>",
requestBody: {
onResume: "continue_existing_billing_period",
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.SubscriptionPauseSubscriptionRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | 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 | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.SubscriptionPauseSubscriptionResponseBody>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SubscriptionPauseSubscriptionResponseBody | 400 | application/json |
| errors.SubscriptionPauseSubscriptionSubscriptionsResponseBody | 404 | application/json |
| errors.SubscriptionPauseSubscriptionSubscriptionsResponseResponseBody | 409 | application/json |
| errors.APIError | 4XX, 5XX | */* |
resume
Example Usage
import { OpenBilling } from "open-billing";
const openBilling = new OpenBilling({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const result = await openBilling.subscriptions.resume({
subscriptionId: "<id>",
requestBody: {},
});
// Handle the result
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { OpenBillingCore } from "open-billing/core.js";
import { subscriptionsResume } from "open-billing/funcs/subscriptionsResume.js";
// Use `OpenBillingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const openBilling = new OpenBillingCore({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const res = await subscriptionsResume(openBilling, {
subscriptionId: "<id>",
requestBody: {},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.SubscriptionResumeSubscriptionRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | 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 | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.SubscriptionResumeSubscriptionResponseBody>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SubscriptionResumeSubscriptionResponseBody | 400 | application/json |
| errors.SubscriptionResumeSubscriptionSubscriptionsResponseBody | 404 | application/json |
| errors.APIError | 4XX, 5XX | */* |
activate
Example Usage
import { OpenBilling } from "open-billing";
const openBilling = new OpenBilling({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const result = await openBilling.subscriptions.activate({
subscriptionId: "<id>",
});
// Handle the result
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { OpenBillingCore } from "open-billing/core.js";
import { subscriptionsActivate } from "open-billing/funcs/subscriptionsActivate.js";
// Use `OpenBillingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const openBilling = new OpenBillingCore({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const res = await subscriptionsActivate(openBilling, {
subscriptionId: "<id>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.SubscriptionActivateSubscriptionRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | 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 | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.SubscriptionActivateSubscriptionResponseBody>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SubscriptionActivateSubscriptionResponseBody | 400 | application/json |
| errors.SubscriptionActivateSubscriptionSubscriptionsResponseBody | 404 | application/json |
| errors.APIError | 4XX, 5XX | */* |
update
Example Usage
import { OpenBilling } from "open-billing";
const openBilling = new OpenBilling({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const result = await openBilling.subscriptions.update({
subscriptionId: "<id>",
requestBody: {},
});
// Handle the result
console.log(result);
}
run();
Standalone function
The standalone function version of this method:
import { OpenBillingCore } from "open-billing/core.js";
import { subscriptionsUpdate } from "open-billing/funcs/subscriptionsUpdate.js";
// Use `OpenBillingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const openBilling = new OpenBillingCore({
security: {
bearer: process.env["OPENBILLING_BEARER"] ?? "",
organizationId: process.env["OPENBILLING_ORGANIZATION_ID"] ?? "",
},
});
async function run() {
const res = await subscriptionsUpdate(openBilling, {
subscriptionId: "<id>",
requestBody: {},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.SubscriptionUpdateSubscriptionRequest | :heavy_check_mark: | The request object to use for the request. |
options | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | :heavy_minus_sign: | 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 | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.SubscriptionUpdateSubscriptionResponseBody>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SubscriptionUpdateSubscriptionResponseBody | 400 | application/json |
| errors.SubscriptionUpdateSubscriptionSubscriptionsResponseBody | 404 | application/json |
| errors.APIError | 4XX, 5XX | */* |