forked from Nixius/authelia
1
0
Fork 0

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
This commit is contained in:
Leopere 2026-03-03 16:00:24 -05:00
parent 159a0b4455
commit 74a24ffe2a
Signed by: colin
SSH Key Fingerprint: SHA256:nRPCQTeMFLdGytxRQmPVK9VXY3/ePKQ5lGRyJhT5DY8
1 changed files with 8 additions and 3 deletions

View File

@ -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",