From 74a24ffe2a8f409fdc58322eebcdcc3abc3011c1 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 3 Mar 2026 16:00:24 -0500 Subject: [PATCH] Fix subscription status not showing Expiring for cancel_at_period_end subs - Also check sub.CancelAt > 0 (handles explicit cancel_at date, not just period-end) - Fall back to item CurrentPeriodEnd for the display date since current_period_end moved off the top-level Subscription object in stripe-go v84 Made-with: Cursor --- docker/ss-atlas/internal/stripe/client.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/ss-atlas/internal/stripe/client.go b/docker/ss-atlas/internal/stripe/client.go index a5c0225..20ea8ce 100644 --- a/docker/ss-atlas/internal/stripe/client.go +++ b/docker/ss-atlas/internal/stripe/client.go @@ -93,10 +93,15 @@ func (c *Client) GetCustomerSubscriptionStatus(customerID string) *SubscriptionS sub := iter.Subscription() log.Printf("stripe: customer=%s sub=%s cancel_at_period_end=%v cancel_at=%d", customerID, sub.ID, sub.CancelAtPeriodEnd, sub.CancelAt) - if sub.CancelAtPeriodEnd { + if sub.CancelAtPeriodEnd || sub.CancelAt > 0 { + // Prefer explicit cancel_at; fall back to current_period_end from the first item + endTs := sub.CancelAt + if endTs == 0 && sub.Items != nil && len(sub.Items.Data) > 0 { + endTs = sub.Items.Data[0].CurrentPeriodEnd + } var cancelAt string - if sub.CancelAt > 0 { - cancelAt = time.Unix(sub.CancelAt, 0).Format("Jan 2, 2006") + if endTs > 0 { + cancelAt = time.Unix(endTs, 0).Format("Jan 2, 2006") } return &SubscriptionStatus{ Label: "Expiring",