Skip to content

Commit e5fad5d

Browse files
committed
Fix variable overwriting in order to improve logged information.
Add additional logging.
1 parent 8096e3c commit e5fad5d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

api/stripe.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ func (api *API) processStripeSub(ctx context.Context, s *stripe.Subscription) er
9191
Customer: s.Customer.ID,
9292
Status: string(stripe.SubscriptionStatusActive),
9393
})
94-
// Pick the latest active plan and set the user's tier based on that.
9594
subs := it.SubscriptionList().Data
95+
if len(subs) > 1 {
96+
api.staticLogger.Tracef("More than one active subscription detected: %+v", subs)
97+
}
98+
// Pick the latest active plan and set the user's tier based on that.
9699
var mostRecentSub *stripe.Subscription
97100
for _, subsc := range subs {
98101
if mostRecentSub == nil || subsc.Created > mostRecentSub.Created {
@@ -128,9 +131,10 @@ func (api *API) processStripeSub(ctx context.Context, s *stripe.Subscription) er
128131
api.staticLogger.Warnf("Empty subscription ID! User ID '%s', Stripe ID '%s', subscription object '%+v'", u.ID.Hex(), u.StripeID, subs)
129132
continue
130133
}
131-
subsc, err = sub.Cancel(subsc.ID, &p)
134+
cs, err := sub.Cancel(subsc.ID, &p)
132135
if err != nil {
133136
api.staticLogger.Warnf("Failed to cancel sub with id '%s' for user '%s' with Stripe customer id '%s'. Error: '%s'", subsc.ID, u.ID.Hex(), s.Customer.ID, err.Error())
137+
api.staticLogger.Tracef("Sub information returned by Stripe: %+v", cs)
134138
} else {
135139
api.staticLogger.Tracef("Successfully cancelled sub with id '%s' for user '%s' with Stripe customer id '%s'.", subsc.ID, u.ID.Hex(), s.Customer.ID)
136140
}

0 commit comments

Comments
 (0)