---
title: Price Model
description: 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](/integrations/models/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](/integrations/controllers/products) and set the `productId` property on the price.


## Properties
:field-schema{schema="/types/price/price.type"}


## Code Example

::code-group
```typescript [Typescript (SDK)]
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
            }
        )
    }
}
```
```typescript [Typescript]
interface Price {
    id: string
    type: Type
    duration: Duration
    amount: Amount
    productId?: string
    name?: string
    description?: string
}

export function Price(price: YourPrice): Price {
    return {
        id: price.id,
        ... // map other properties
    }
}

enum Type {
    Standalone = "standalone",
    Product = "product"
}

interface Duration {
    amount: number
    unit: Unit
}

enum Unit {
    Month = "month",
    Year = "year"
}

type Amount = FixedAmount | TieredAmount

interface FixedAmount {
    model: Model.Fixed
    currency: string
    unit?: number
    flat?: number
}

interface TieredAmount {
    model: Model.Tiered
    currency: string
    mode: Mode
    tiers: Tier[]
}


enum Model {
    Fixed = "fixed",
    Tiered = "tiered"
}

enum Mode {
    Graduated = "graduated",
    Total = "total"
}

interface Tier {
    unit?: number
    flat?: number
    upTo?: number
}
```
```go [Go]
package models

type Price struct {
    ID        string            `json:"id"`
    Type      Type              `json:"type"`
    Duration  Duration          `json:"duration"`
    Amount    Amount            `json:"amount"`
    ProductID *string           `json:"productId"`
    Name      *string           `json:"name"`
    Description *string         `json:"description"`
}

type Type string
const (
    Standalone Type = "standalone"
    Product Type = "product"
)

type Duration struct {
    Amount int `json:"amount"`
    Unit   Unit `json:"unit"`
}

type Unit string
const (
    Month Unit = "month"
    Year Unit = "year"
)

type Amount interface {
    PricingModel() Model
}

type FixedAmount struct {
    Model    Model  `json:"model"`
    Currency string `json:"currency"`
    Unit     *int   `json:"unit"`
    Flat     *int   `json:"flat"`
}

func (FixedAmount) PricingModel() Model {
    return Fixed
}

type TieredAmount struct {
    Model Model `json:"model"`
    Currency string `json:"currency"`
    Mode Mode `json:"mode"`
    Tiers []Tier `json:"tiers"`
}

func (TieredAmount) PricingModel() Model {
    return Tiered
}

type Model string
const (
    Fixed Model = "fixed"
    Tiered Model = "tiered"
)

type Mode string
const (
    Graduated Mode = "graduated"
    Total Mode = "total"
)

type Tier struct {
    Unit  *int `json:"unit"`
    Flat  *int `json:"flat"`
    UpTo  *int `json:"upTo"`
}

func Price(price YourPrice) Price {
    return Price{
        ID: price.ID,
        ... // map other properties
    }
}

```