Purchase Product
POST/api/billing/purchase-product
Purchase a product for a lead with standard or custom pricing.
This endpoint supports both recurring subscriptions and one-time charges, with flexible pricing that can use standard tier pricing or custom pricing.
Pricing Modes:
- Standard Pricing: Provide
tier_idto use pricing from database - Custom Pricing: Provide
pricing_tierobject to override pricing
Purchase Types:
- Recurring (monthly/quarterly/yearly): Creates a subscription
- One-time: Creates a charge/invoice
Request Body:
{
"product_id": "uuid",
"lead_id": "uuid",
"tier_id": "product_id_a", // Optional if pricing_tier provided
"payment_method_id": "uuid", // Required for paid products
"pricing_tier": { // Optional custom pricing (overrides tier_id)
"price": 100.00,
"billing_frequency": "monthly",
"setup_fee": 0,
"trial_days": 0,
"trial_price": 0
},
"metadata": {} // Optional
}
Validation:
- Lead must belong to current tenant
- Product must be active
- Either
tier_idORpricing_tiermust be provided payment_method_idrequired if price > 0
Returns:
purchase_type: "subscription" or "charge"pricing_source: "standard" or "custom"pricing_applied: Pricing details that were used- Subscription details (if recurring)
- Transaction/invoice details (if one-time)
Errors:
- 400: Invalid request or product not active
- 404: Product, tier, or lead not found
- 422: Validation error
- 500: Internal error
Request
Responses
- 200
- 422
Successful Response
Validation Error