
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
chargebee
Advanced tools
This is the Node.js library for integrating with Chargebee. Sign up for a Chargebee account here.
Please refer to the migration guide if you are migrating from the older versions of chargebee-typescript or chargebee.
Node.js 18 or higher.
Install the beta version of the library with npm:
npm install chargebee@beta
With pnpm:
pnpm add chargebee@beta
With yarn:
yarn add chargebee@beta
The package needs to be configured with your site's API key, which is available under Configure Chargebee Section. Refer here for more details.
If you're using ESM / TypeScript:
import Chargebee from 'chargebee';
const chargebee = new Chargebee({
site: "{{site}}",
apiKey: "{{api-key}}",
});
Or using Common JS module system:
const Chargebee = require('chargebee');
const chargebee = new Chargebee({
site: "{{site}}",
apiKey: "{{api-key}}",
});
try {
const { customer } = await chargebee.customer.create({
email: "john@test.com"
// other params
});
} catch (err) {
// handle error
}
For pagination, offset
is the parameter that is being used. The value used for this parameter must be the value returned for next_offset
parameter in the previous API call.
async function getAllCustomers() {
const allCustomers: Customer[] = [];
let offset: string | undefined = undefined;
do {
const listCustomersReponse = await chargebee.customer.list({
limit: 2,
offset,
first_name: {
is: "John"
}
});
const customers = listCustomersReponse.list.map(
(object) => object.customer
);
allCustomers.push(...customers);
offset = listCustomersReponse.next_offset;
} while (offset);
console.log(allCustomers);
}
const { customer } = await chargebee.customer.create(
{
email: "john@test.com",
cf_host_url: "http://xyz.com" // `cf_host_url` is a custom field in Customer object
},
{
"chargebee-event-email": "all-disabled" // To disable webhooks
}
);
Idempotency keys are passed along with request headers to allow a safe retry of POST requests.
const { customer, isIdempotencyReplayed } = await chargebee.customer.create(
{ email: "john@test.com" },
{
"chargebee-idempotency-key": "eBs7iOFQuR7asUKHfddyxDDerOuF1JtFrLmDI" // Add idempotency key
}
);
console.log("isIdempotencyReplayed: ", isIdempotencyReplayed);
const chargebeeSiteUS = new Chargebee({
apiKey: "{api-key}",
site: "my-site-us"
});
const chargebeeSiteEU = new Chargebee({
apiKey: "{api-key}",
site: "my-site-eu"
});
An attribute api_version
is added to the Event resource, which indicates the API version based on which the event content is structured. In your webhook servers, ensure this api_version
is the same as the API version used by your webhook server's client library.
If you find any bugs or have any questions / feedback, open an issue in this repository or reach out to us on dx@chargebee.com
Chargebee Node SDK v2 is deprecated. If you using v2, follow this guide to migrate to v3.
FAQs
A library for integrating with Chargebee.
The npm package chargebee receives a total of 50,198 weekly downloads. As such, chargebee popularity was classified as popular.
We found that chargebee demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.