@@ -26,6 +26,7 @@ type BillingAccessResponse = {
2626 subscription_seats ?: number | null ;
2727 seats ?: number | null ;
2828 quantity ?: number | null ;
29+ next_billed_at ?: string | null ;
2930} ;
3031
3132type PaddlePricesResponse = Record < string , string > ;
@@ -207,6 +208,25 @@ export default function ChangePlansPage() {
207208 setPendingSeats ( ( prev ) => prev + 1 ) ;
208209 } ;
209210
211+ function buildPreviewMessage ( previewData : any , nextBillingDate ?: string ) : string | null {
212+ if ( ! previewData ) return null ;
213+
214+ const hasImmediateCharge = Boolean ( previewData ?. immediate_transaction ) ;
215+ const amount = extractPreviewAmount ( previewData ) ;
216+
217+ if ( hasImmediateCharge && amount !== null ) {
218+ return `You will be charged ${ toCurrency ( amount ) } today.` ;
219+ }
220+
221+ if ( nextBillingDate ) {
222+ const date = new Date ( nextBillingDate ) ;
223+ const formatted = date . toLocaleDateString ( undefined , { dateStyle : "medium" } ) ;
224+ return `Your plan will change on ${ formatted } . No charge today.` ;
225+ }
226+
227+ return "This change will take effect on your next billing date. No charge today." ;
228+ }
229+
210230 const handlePlanSelect = async ( planKey : string ) => {
211231 if ( mode !== "plan" || actionsBlocked || planKey === currentPlanKey ) {
212232 return ;
@@ -232,7 +252,7 @@ export default function ChangePlansPage() {
232252 const amount = extractPreviewAmount ( preview ) ;
233253 setPreviewData ( preview ) ;
234254 setPreviewMessage (
235- amount === null ? null : `You will be charged ${ toCurrency ( amount ) } today.` ,
255+ buildPreviewMessage ( preview , billing ?. next_billed_at )
236256 ) ;
237257 setSummaryMessage (
238258 `Plan change: ${ currentPlanKey || "current" } → ${ planKey } (${ currentSeats } seats).` ,
@@ -257,7 +277,7 @@ export default function ChangePlansPage() {
257277 const amount = extractPreviewAmount ( preview ) ;
258278 setPreviewData ( preview ) ;
259279 setPreviewMessage (
260- amount === null ? null : `You will be charged ${ toCurrency ( amount ) } today.` ,
280+ buildPreviewMessage ( preview , billing ?. next_billed_at )
261281 ) ;
262282 } else {
263283 const selected = STATIC_PLANS . find ( ( plan ) => plan . key === selectedPlanKey ) ;
@@ -275,7 +295,7 @@ export default function ChangePlansPage() {
275295 const amount = extractPreviewAmount ( preview ) ;
276296 setPreviewData ( preview ) ;
277297 setPreviewMessage (
278- amount === null ? null : `You will be charged ${ toCurrency ( amount ) } today.` ,
298+ buildPreviewMessage ( preview , billing ?. next_billed_at )
279299 ) ;
280300 setSummaryMessage (
281301 `Plan change: ${ currentPlanKey || "current" } → ${ selectedPlanKey } (${ currentSeats } seats).` ,
0 commit comments