Overview
Item sync in Flexprice creates the necessary Chargebee infrastructure (item families, items, and item prices) to support invoice synchronization. This enables Flexprice plans and prices to be represented in Chargebee’s item-based pricing model.Key Concepts
- Item Family: A container for related items in Chargebee (required before syncing plans)
- Item: Represents a chargeable entity (one per price/currency combination)
- Item Price: Defines the pricing model and rates for an item
- One Item Per Currency: Chargebee only allows one item price per currency per item, so we create separate items for each price
Item Family
Overview
An item family is a container that groups related items together in Chargebee. You must create at least one item family in Chargebee before syncing plans.Creating an Item Family
In Chargebee Dashboard:- Go to Products → Item Families
- Click + Add Item Family
- Enter a name (e.g., “Flexprice Charges”)
- Click Save
Item Family Selection
When syncing plans, Flexprice automatically:- Retrieves all item families from Chargebee
- Selects the latest item family (most recently created)
- Uses it for all synced items
Item Sync Process
Plan Sync Flow
When you sync a Flexprice plan to Chargebee:Item Creation
For each price in a plan, Flexprice creates:-
One Item (type:
charge)- ID format:
charge_{uuid} - Name: Same as ID (must be unique)
- Type:
charge(for one-time/recurring charges) - Item Family: Latest item family from Chargebee
- External Name:
{display_name} - {currency}(e.g., “API Calls - USD”)
- ID format:
-
One Item Price (linked to the item)
- ID: Flexprice price ID (for easy mapping)
- Item ID: The created item ID
- External Name:
{display_name} - {currency} - Currency: Price currency
- Pricing Model: Mapped from Flexprice billing model
Why Separate Items Per Price?
Chargebee has a limitation: only one item price per currency per item. To support multiple currencies or multiple prices per plan, we create separate items for each price. Example:- Plan: “Pro Plan” with prices in USD and EUR
- Result: 2 items created (
charge_uuid1for USD,charge_uuid2for EUR)
Item Price Sync
Pricing Model Mapping
Flexprice billing models are mapped to Chargebee pricing models:| Flexprice Billing Model | Flexprice Type | Chargebee Pricing Model |
|---|---|---|
FLAT_FEE | FIXED | flat_fee |
FLAT_FEE | USAGE | per_unit |
PACKAGE | - | package |
TIERED | VOLUME | volume |
TIERED | SLAB | tiered |
Flat Fee / Per Unit Pricing
For flat fee and per unit pricing:price: Amount converted to smallest currency unit (cents for USD, paise for INR)- No tiers required
- Simple fixed pricing
Package Pricing
For package pricing:price: Package price in smallest currency unitperiod: Optional package size (e.g., 10 units per package)- Used for bulk pricing models
Tiered Pricing
For tiered/volume pricing:tiers: Array of tier definitionsstarting_unit: Minimum quantity for this tier (1-based)ending_unit: Maximum quantity for this tier (null for last tier)price: Price per unit in this tier (in smallest currency unit)- Tiers are converted from Flexprice tier format to Chargebee format
Tier Conversion
Flexprice tiers are converted to Chargebee format: Flexprice Tier:unit_amountconverted to smallest currency unit (e.g., $1.00 → 100 cents)up_tobecomesending_unitstarting_unitcalculated from previous tier’sending_unit + 1- First tier always starts at 1
- Last tier has
ending_unit: null
Amount Conversion
Currency Precision
All amounts are converted to the smallest currency unit based on currency precision:| Currency | Precision | Smallest Unit | Example |
|---|---|---|---|
| USD | 2 | Cents | $1.00 → 100 cents |
| EUR | 2 | Cents | €1.00 → 100 cents |
| INR | 2 | Paise | ₹1.00 → 100 paise |
| JPY | 0 | Yen | ¥100 → 100 yen |
Why Convert to Smallest Unit?
Chargebee stores all prices as integers in the smallest currency unit to avoid floating-point precision issues. This ensures accurate calculations and prevents rounding errors.Entity Mapping
Mapping Storage
After syncing items and item prices, Flexprice stores entity mappings: Price → Item Price Mapping:- Entity Type:
item_price - Entity ID: Flexprice price ID
- Provider Entity ID: Chargebee item price ID
- Provider Type:
chargebee
Display Names
External Names
Items and item prices use external names for better invoice display: Format:{display_name} - {currency}
Examples:
- “API Calls - USD”
- “Pro Plan - EUR”
- “Storage - INR”
- Feature name (if price has a meter/feature)
- Meter name (if feature not found)
- Plan name (fallback)
Error Handling
Common Sync Errors
| Error | Cause | Solution |
|---|---|---|
| ”Item family not found” | No item family in Chargebee | Create an item family first |
| ”Item already exists” | Duplicate item ID | Item IDs are auto-generated, should not occur |
| ”Invalid pricing model” | Unsupported billing model | Check billing model mapping |
| ”Currency not supported” | Invalid currency code | Verify currency is supported by Chargebee |
Sync Failure Recovery
When item sync fails:- Partial Sync: Some items may be created even if others fail
- Retry: Re-sync the plan to create missing items
- Manual Cleanup: Remove failed items from Chargebee if needed
- Logs: Check application logs for detailed error messages
Best Practices
Item Family Management
- Single Family: Use one item family for all Flexprice items (simplifies management)
- Naming: Use descriptive names (e.g., “Flexprice Charges”)
- Organization: Group related items in the same family
Price Sync Strategy
- Sync Before Invoicing: Always sync plans before creating invoices
- Currency Separation: Each currency requires a separate item
- Tier Precision: Be aware that tier calculations may have slight differences due to rounding
Testing
- Test Environment: Use Chargebee test mode for development
- Verify Items: Check created items in Chargebee dashboard
- Test Invoices: Create test invoices to verify item prices work correctly
Next Steps
After syncing items:- Verify Items: Check created items in Chargebee dashboard
- Test Invoice Sync: Create a test invoice and sync to Chargebee
- Monitor Mappings: Ensure entity mappings are created correctly
- Go Live: Switch to production when ready

