Calculate Discounted Price by Duration API
Calculate custom subscription pricing with duration-based discounts
Calculate Discounted Price API
Calculate subscription pricing for any custom duration. Get the discounted price based on the length of subscription commitment.
Custom Duration
Calculate any day count.
Auto Discount
Discount scales with duration.
Flexible
Any number of days.
Endpoint Overview
/graphqlCalculate the discounted subscription price for any custom duration. Discounts are automatically applied based on the commitment length.
Request Parameters
groupIdInt!RequiredThe ID of the subscription group.
durationInt!RequiredThe number of days for the subscription.
GraphQL Query
query calculateDiscountedPriceByDuration($groupId: Int!, $duration: Int!) {
calculateDiscountedPriceByDuration(groupId: $groupId, duration: $duration) {
groupId
duration
originalPrice
discountedPrice
discountPercent
savings
currency
}
}Variables:
{
"groupId": 100,
"duration": 45
}HTTP Request:
curl -X POST https://api.orbnet.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"query": "query calculateDiscountedPriceByDuration($groupId: Int!, $duration: Int!) { calculateDiscountedPriceByDuration(groupId: $groupId, duration: $duration) { discountedPrice discountPercent savings } }",
"variables": {
"groupId": 100,
"duration": 45
}
}'Response
{
"data": {
"calculateDiscountedPriceByDuration": {
"groupId": "100",
"duration": 45,
"originalPrice": 14.99,
"discountedPrice": 13.49,
"discountPercent": 10,
"savings": 1.50,
"currency": "USD"
}
}
}{
"errors": [
{
"message": "Duration must be at least 1 day",
"path": ["calculateDiscountedPriceByDuration"],
"extensions": {
"code": "INVALID_DURATION"
}
}
],
"data": null
}Discount Tiers
1-29 Days
Standard daily rate applies.
30-89 Days
10-15% discount tier.
90-364 Days
20-30% discount tier.
365+ Days
Maximum discount tier.
Use Cases
Custom Plans
Offer non-standard durations.
Prorated Billing
Calculate partial month pricing.
Special Offers
Create limited-time promotions.
Quote Generation
Provide accurate custom quotes.
Related Endpoints
Discount Calculation
Discounts are calculated based on your platform's configured discount tiers. Longer durations receive progressively higher discount percentages.
Apply Promo Codes
Stack additional savings with coupon codes.