@@ -188,12 +188,29 @@ public async Task CancelSubscriptionAsync(int userId)
188188 var provider = GetProviderForUser ( user ) ;
189189 await provider . CancelSubscriptionAsync ( user . PaymentSubscriptionId ) ;
190190
191- user . CancelAtPeriodEnd = true ;
191+ // For incomplete subscriptions (abandoned payments), do a full reset
192+ // since the subscription was never activated
193+ if ( user . SubscriptionStatus == "incomplete" )
194+ {
195+ _logger . LogInformation (
196+ "Clearing incomplete subscription {SubscriptionId} for user {UserId}" ,
197+ user . PaymentSubscriptionId , userId ) ;
198+
199+ user . PaymentSubscriptionId = null ;
200+ user . SubscriptionStatus = "none" ;
201+ user . CancelAtPeriodEnd = false ;
202+ // Keep the user on their current plan (don't change it)
203+ }
204+ else
205+ {
206+ // For active subscriptions, mark for cancellation at period end
207+ user . CancelAtPeriodEnd = true ;
208+ _logger . LogInformation ( "Subscription {SubscriptionId} marked for cancellation for user {UserId}" ,
209+ user . PaymentSubscriptionId , userId ) ;
210+ }
211+
192212 user . UpdatedAt = DateTime . UtcNow ;
193213 await _db . SaveChangesAsync ( ) ;
194-
195- _logger . LogInformation ( "Subscription {SubscriptionId} marked for cancellation for user {UserId}" ,
196- user . PaymentSubscriptionId , userId ) ;
197214 }
198215
199216 /// <inheritdoc />
0 commit comments