Subscription Based Pricing API Reference
This page documents the API for the business KPIs module in Pypulate.
Subscription Pricing Module
This module provides functions for calculating subscription-based pricing.
calculate_subscription_price(base_price, features, feature_prices, duration_months=1, discount_rate=0.0)
Calculate subscription price including selected features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_price
|
float
|
Base subscription price |
required |
features
|
list
|
List of selected feature names |
required |
feature_prices
|
dict
|
Dictionary of feature names and their prices |
required |
duration_months
|
int
|
Subscription duration in months |
1
|
discount_rate
|
float
|
Annual discount rate for longer subscriptions |
0.0
|
Returns:
Type | Description |
---|---|
float
|
Total subscription price |
Examples:
>>> features = ['premium', 'api_access']
>>> feature_prices = {'premium': 49.99, 'api_access': 29.99}
>>> calculate_subscription_price(99.99, features, feature_prices)
179.97 # 99.99 + 49.99 + 29.99
>>> calculate_subscription_price(99.99, features, feature_prices,
... duration_months=12, discount_rate=0.10)
1943.68 # (99.99 + 49.99 + 29.99) * 12 * (1 - 0.10)