Prices via API
This tutorial will guide you through the steps to create and manage prices via Billing APIs.
Create a price
Call Create a price API with the following required fields:
currency
: Specify currency for the price.product_id
: ID of the Product object created with Create a Product API.pricing_model
: Defaults toPER_UNIT
. See Pricing models.billing_type
: Defaults toIN_ADVANCE
. See Billing types.recurring
: Set this object tonull
for one-time charges.recurring.period_unit
: Indicates how often you want to charge your customers for a product or service. Can be one ofDAY
,WEEK
,MONTH
,YEAR
.recurring.period
: Optional. Determines the interval gap based onperiod_unit
. For example, for a bi-monthly billing cycle, specifyperiod
= 2 whereperiod_unit
=MONTH
.
active
: By default, this field is set totrue
, which means the price is available for new purchases. You can set it tofalse
to deactivate the price.
The example code below shows how to create a one-time price using the PER_UNIT
pricing model for the product.
The example code below shows how to create a monthly price using the FLAT
pricing model and apply charges on a per-month basis.
Deactivate a price
You can retire prices you no longer wish to use by setting the active
field to false
in Update a price API request.
Deactivating a price means it can no longer be selected when creating new subscriptions or invoices. Note that it will not affect existing subscriptions or invoices that have used this price.
Manage prices
After creating a price object, you can perform the following actions:
- Update price details such as
description
andmetadata
using Update a Price - Retrieve price details anytime using Retrieve a Price API .
- Retrieve the list of prices you've created using Get list of Prices API.