Price Model
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
The unique identifier of the price
'standalone'
'product'
The type of the price. All prices should have the same type.
Describes the billing cycle of the price
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.
ID of the product this price belongs to. type
should be set to 'product'
Customer-facing name of the price. If not provided, a name will be generated based on the amount and duration
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
}
)
}
}
Customer Model
A customer is a user who is being billed for a subscription. This model includes information about the customer, such as their name, email, address, etc.
Subscription Model
A subscription is a recurring payment for a product or service. This model includes information about the subscription, including its status, billing cycle, items, and discounts.