Calculate Discounted Price by Duration API

Calculate custom subscription pricing with duration-based discounts

Pricing

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

QUERY/graphql

Calculate the discounted subscription price for any custom duration. Discounts are automatically applied based on the commitment length.

Authentication:Bearer Token
Required scopes:useradmin

Request Parameters

groupIdInt!Required

The ID of the subscription group.

durationInt!Required

The 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

200Price Calculated Successfully
{
  "data": {
    "calculateDiscountedPriceByDuration": {
      "groupId": "100",
      "duration": 45,
      "originalPrice": 14.99,
      "discountedPrice": 13.49,
      "discountPercent": 10,
      "savings": 1.50,
      "currency": "USD"
    }
  }
}
400Invalid Duration
{
  "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.



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.

Check Coupon Code