Skip to main content
Home

Built and signed on GitHub Actions

Wrapper for the Cheddar recurring billing system APIs

This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
82%
Published
2 months ago (0.7.5)

JavaScript Cheddar API wrapper

This module will simplify the process of integrating Cheddar into your existing JavaScript apps.

Table of Contents

Installation

npm i @tivetechnology/cheddar-api

Basic usage

import { Cheddar } from "cheddar";

const cheddar = new Cheddar({
  username: "email@example.com",
  password: "passwordExample",
  productCode: "PRODUCT_CODE",
});

cheddar
  .getPlans()
  .then((plans) => console.log(plans))
  .catch((err) => console.error(err));

// When inside an async function, you can simply await any Cheddar function
const plans = await cheddar.getPlans();

Implemented methods

  • getPlans()
  • getPlan(planCode)
  • getCustomers(getCustomersRequest)
  • getCustomer(customerCode)
  • createCustomer(createCustomerRequest)
  • editCustomerAndSubscription(editCustomerSubscriptionRequest)
  • editCustomer(editCustomerRequest)
  • editSubscription(editSubscriptionRequest)
  • deleteCustomer(customerCode)
  • cancelSubscription(customerCode)
  • addItem(itemQuantityRequest)
  • removeItem(itemQuantityRequest)
  • setItemQuantity(setItemQuantityRequest)
  • addCustomCharge(addCustomChargeRequest)
  • deleteCustomCharge(deleteCustomChargeRequest)
  • createOneTimeInvoice(createOneTimeInvoiceRequest)
  • runOutstandingInvoice(outstandingInvoiceRequest)
  • issueRefund(issueRefundRequest)
  • issueVoid(issueVoidRequest)
  • issueVoidOrRefund(issueVoidRequest)
  • resendInvoiceEmail(issueVoidRequest)
  • getPromotions()
  • getPromotion(promotionCode)

All methods return a promise with the requested data in JSON format.

Running tests

First add a config file (.env) with all your Cheddar credentials:

TEST_USERNAME=
TEST_PASSWORD=
TEST_PRODUCT_CODE=
TEST_PLAN_CODE=
TEST_ITEM_CODE=
TEST_PROMO_CODE=

Now you can install all dependencies and run the tests:

npm install
npm test

WARNING: Only run the tests on a development account to prevent any side effects in production

Credits

Original work was done by Kevin Smith. Ported to typescript by Victor Uvarov.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@tive/cheddar

Import symbol

import * as cheddar from "@tive/cheddar";
or

Import directly with a jsr specifier

import * as cheddar from "jsr:@tive/cheddar";

Add Package

pnpm i jsr:@tive/cheddar
or (using pnpm 10.8 or older)
pnpm dlx jsr add @tive/cheddar

Import symbol

import * as cheddar from "@tive/cheddar";

Add Package

yarn add jsr:@tive/cheddar
or (using Yarn 4.8 or older)
yarn dlx jsr add @tive/cheddar

Import symbol

import * as cheddar from "@tive/cheddar";

Add Package

vlt install jsr:@tive/cheddar

Import symbol

import * as cheddar from "@tive/cheddar";

Add Package

npx jsr add @tive/cheddar

Import symbol

import * as cheddar from "@tive/cheddar";

Add Package

bunx jsr add @tive/cheddar

Import symbol

import * as cheddar from "@tive/cheddar";