You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add `discounts` (prorated seat discount + total), `totals_due_per_period`
(full recurring renewal breakdown), `total_due_per_period`, and top-level
`base_fee` to checkout totals. The top-level totals now reflect only what is
actively being purchased, while `totals_due_per_period` conveys the recurring
charge. Parse the new fields and surface the prorated discount and
renewal totals in the checkout form
Update checkout totals to support the new `totals` shape from the API:
10
+
11
+
- Add `discounts` to `BillingCheckoutTotals` / `BillingCheckoutTotalsJSON`. It exposes a `proration` (a `BillingProrationDiscountDetail` with `amount`, `cycleDaysPassed`, `cycleDaysTotal`, `cyclePassedPercent`) describing the prorated discount applied when adding seats mid-billing-period — i.e. the part of the cycle that has already passed and is not charged — plus a `total` of all discounts.
12
+
- Add `totalsDuePerPeriod` / `totals_due_per_period` (`BillingPerPeriodTotals`) with `subtotal`, `baseFee`, `taxTotal`, `grandTotal`, and `perUnitTotals`: the full renewal charge breakdown covering all seats and the base plan fee, as opposed to the top-level totals which now only cover what is actively being purchased in the current checkout.
13
+
- Add `totalDuePerPeriod` / `total_due_per_period` (money amount) for backwards compatibility.
14
+
- Add `baseFee` / `base_fee` to the top-level totals.
15
+
- Parse all new fields in `billingTotalsFromJSON`.
16
+
- Render the prorated discount line item in `CheckoutForm` when present.
17
+
- Render a renewal subtotal and renewal total section in `CheckoutForm` when `totalsDuePerPeriod` is present.
* Details about a prorated discount applied when adding a seat mid-cycle. The discount covers the part of the
819
+
* billing period that has already passed, so the payer is only charged for the time remaining in the cycle.
820
+
*
821
+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
822
+
*/
823
+
exportinterfaceBillingProrationDiscountDetail{
824
+
amount: BillingMoneyAmount;
825
+
cycleDaysPassed: number;
826
+
cycleDaysTotal: number;
827
+
cyclePassedPercent: number;
828
+
}
829
+
830
+
/**
831
+
* Discounts applied to the checkout, such as prorated discounts for mid-cycle seat additions.
832
+
*
833
+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
834
+
*/
835
+
exportinterfaceBillingCheckoutDiscounts{
836
+
/**
837
+
* The prorated discount for the part of the billing period that has already passed when adding a seat mid-cycle.
838
+
* Unlike the proration credit (which refunds the unused remainder of a plan you already paid for), this discount
839
+
* means you are not charged for the portion of the new seat's cycle that has already elapsed.
840
+
*/
841
+
proration: BillingProrationDiscountDetail|null;
842
+
/**
843
+
* The total of all discounts applied to the checkout.
844
+
*/
845
+
total: BillingMoneyAmount;
846
+
}
847
+
848
+
/**
849
+
* Per-period renewal totals, describing what the subscription renewal charge will look like after the current checkout.
850
+
* Unlike the top-level checkout totals (which only reflect the items actively being purchased),
851
+
* this object contains the full renewal breakdown including all seats and the base plan fee.
852
+
*
853
+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
854
+
*/
855
+
exportinterfaceBillingPerPeriodTotals{
856
+
subtotal: BillingMoneyAmount;
857
+
baseFee: BillingMoneyAmount;
858
+
taxTotal: BillingMoneyAmount;
859
+
grandTotal: BillingMoneyAmount;
860
+
/**
861
+
* Per-unit cost breakdown for the renewal period, covering all units purchased to date
862
+
* (not just the ones being added in this checkout).
863
+
*/
864
+
perUnitTotals?: BillingPerUnitTotal[];
865
+
}
866
+
817
867
/**
818
868
* The `BillingCheckoutTotals` type represents the total costs, taxes, and other pricing details for a checkout session.
819
869
*
820
870
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
821
871
*/
822
872
exportinterfaceBillingCheckoutTotals{
823
873
/**
824
-
* The price of the items or Plan before taxes, credits, or discounts are applied.
874
+
* The price of items actively being purchased in this checkout, before taxes and discounts.
875
+
* When only adding seats mid-cycle, this reflects just the new seats and excludes the base plan fee and
876
+
* seats that were already paid for.
825
877
*/
826
878
subtotal: BillingMoneyAmount;
879
+
/**
880
+
* The base plan fee portion of the totals, before per-unit charges and adjustments.
881
+
*/
882
+
baseFee?: BillingMoneyAmount;
827
883
/**
828
884
* The total amount for the checkout, including taxes and after credits/discounts are applied. This is the final amount due.
* Discounts applied to the checkout, such as prorated discounts for mid-cycle seat additions.
865
+
*
866
+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
867
+
*/
868
+
exportinterfaceBillingCheckoutDiscountsJSON{
869
+
/**
870
+
* The prorated discount for the part of the billing period that has already passed when adding a seat mid-cycle.
871
+
* Unlike the proration credit (which refunds the unused remainder of a plan you already paid for), this discount
872
+
* means you are not charged for the portion of the new seat's cycle that has already elapsed.
* The total of all discounts applied to the checkout.
877
+
*/
878
+
total: BillingMoneyAmountJSON;
879
+
}
880
+
881
+
/**
882
+
* Per-period renewal totals, describing what the subscription renewal charge will look like after the current checkout.
883
+
* Unlike the top-level checkout totals (which only reflect the items actively being purchased),
884
+
* this object contains the full renewal breakdown including all seats and the base plan fee.
885
+
*
886
+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
887
+
*/
888
+
exportinterfaceBillingPerPeriodTotalsJSON{
889
+
subtotal: BillingMoneyAmountJSON;
890
+
base_fee: BillingMoneyAmountJSON;
891
+
tax_total: BillingMoneyAmountJSON;
892
+
grand_total: BillingMoneyAmountJSON;
893
+
/**
894
+
* Per-unit cost breakdown for the renewal period, covering all units purchased to date
895
+
* (not just the ones being added in this checkout).
896
+
*/
897
+
per_unit_totals?: BillingPerUnitTotalJSON[];
898
+
}
899
+
852
900
/**
853
901
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
854
902
*/
855
903
exportinterfaceBillingCheckoutTotalsJSON{
856
904
grand_total: BillingMoneyAmountJSON;
905
+
/**
906
+
* The price of items actively being purchased in this checkout, before taxes and discounts.
907
+
* When only adding seats mid-cycle, this reflects just the new seats and excludes the base plan fee and
908
+
* seats that were already paid for.
909
+
*/
857
910
subtotal: BillingMoneyAmountJSON;
911
+
/**
912
+
* The base plan fee portion of the totals, before per-unit charges and adjustments.
913
+
*/
914
+
base_fee: BillingMoneyAmountJSON;
858
915
tax_total: BillingMoneyAmountJSON;
859
916
/**
860
-
* Per-unit cost breakdown for this checkout (for example, seats).
917
+
* Per-unit cost breakdown for items actively being purchased in this checkout (for example, seats being added).
918
+
* When only adding seats mid-cycle, this only covers the seats being added, not seats already paid for.
919
+
* Omitted when the checkout is not seat-based.
861
920
*/
862
921
per_unit_totals?: BillingPerUnitTotalJSON[];
863
922
total_due_now: BillingMoneyAmountJSON;
923
+
/**
924
+
* Legacy credit field. Kept for backwards compatibility; prefer the unified `credits` breakdown.
0 commit comments