Models

Price Model

A price (also known as plan) defines the cost, currency and billing cycle of product or service.

Type

Depending on your app's architecture, prices can belong to a Product or be standalone entities. In both cases, you can start by implementing a standalone Price model, and later refactor it to add products support.

If you implement a product-based price, you will need to create a Products controller and set the productId property on the price.

Properties

idstring
required

The unique identifier of the price

typeenum
required
Possible values

'standalone' 'product'

The type of the price. All prices should have the same type.

durationobject
required

Describes the billing cycle of the price

amountunion
required

Describes the price amount. There are two types of amounts: tiered and fixed. Some apps support both types, but most common pricing model is fixed. All numeric values are in cents (or equivalent minor currency unit), e.g. $1.10 is represented as 110.

productIdstring
recommended

ID of the product this price belongs to. type should be set to 'product'

namestring
recommended

Customer-facing name of the price. If not provided, a name will be generated based on the amount and duration

descriptionstring
optional

Internal description of the price, hidden from the customers

Code Example

import { Integrator } from '@churnkey/sdk'
// export class Price extends Integrator.Price.Product {
export class Price extends Integrator.Price.Standalone {
    constructor(price: YourPrice) {
        super(
            {
                id: price.id,
                ... // map other properties
            }
        )
    }
}