# BillingService

- File ID: file:13phiik:billingservice-cs
- Path: NexusReader.Infrastructure/Services/BillingService.cs
- Role: service
- Layer: infrastructure

## Purpose

Implements billing-related reactions (subscription updated/deleted) tying Stripe product events to local user subscription plan and token limits.

## Key Details

Two primary runtime entrypoints react to Stripe subscription events: update maps product IDs to local plans with branching and fallbacks; delete resets user to Free plan. Both perform DB reads for plan records and persist user updates via UserManager, with extensive logging and exception handling.

## Symbols

- BillingService: Implements billing-related reactions (subscription updated/deleted) tying Stripe product events to local user subscription plan and token limits.
- HandleSubscriptionUpdatedAsync(): Handle a Stripe subscription update: map Stripe product id to a local SubscriptionPlan, update the user's plan and AI token limit, and persist via UserManager.
- HandleSubscriptionDeletedAsync(): Handle a Stripe subscription deletion: reset the user's subscription to the Free plan and restore its AI token limit, persisting via UserManager.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Data.Persistence/AppDbContext
- dependency-target: NexusReader.Domain.Entities/SubscriptionPlan
- dependency-target: NexusReader.Application.Abstractions.Services/IBillingService
- dependency-target: NexusReader.Infrastructure/Configuration/StripeSettings
- call-target: NexusReader.Domain.Entities/SubscriptionPlan
- call-target: NexusReader.Infrastructure/Configuration/StripeSettings
- call-target: NexusReader.Data.Persistence/AppDbContext
- call-target: NexusReader.Domain.Entities/SubscriptionPlan
- call-target: NexusReader.Data.Persistence/AppDbContext
- interaction-target: var user = await _userManager.FindByEmailAsync(customerEmail);
- interaction-target: return Result.Fail(result.Errors.Select(e => e.Description).FirstOrDefault() ?? "Failed to update user profile.");
- interaction-target: var user = await _userManager.FindByEmailAsync(customerEmail);
- interaction-target: return Result.Fail(result.Errors.Select(e => e.Description).FirstOrDefault() ?? "Failed to reset user to free tier.");

## Coverage

- Symbols: 3
- Executable symbols: 2
- Executable symbols with control flow: 2
- Grounded edges: 3
- Unresolved references: 13
- Control-flow fragments: 2
- Unresolved jumps: 5
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 4

## Control Flow Fragments

- HandleSubscriptionUpdatedAsync: 73 nodes, 83 edges, 3 jumps, 0 unsupported constructs
- HandleSubscriptionDeletedAsync: 47 nodes, 51 edges, 2 jumps, 0 unsupported constructs

## Diagrams

### BillingService Neighborhood

```mermaid
flowchart LR
    class_11gdjq4_billingservice("BillingService")
    file_13phiik_billingservice_cs("BillingService")
    method_174nry_handlesubscriptiondeletedasync[["HandleSubscriptionDeletedAsync()"]]
    method_1ctlycb_handlesubscriptionupdatedasync[["HandleSubscriptionUpdatedAsync()"]]
```

### BillingService Execution Overview

```mermaid
flowchart TD
    class_11gdjq4_billingservice("BillingService")
    method_174nry_handlesubscriptiondeletedasync[["HandleSubscriptionDeletedAsync()"]]
    method_1ctlycb_handlesubscriptionupdatedasync[["HandleSubscriptionUpdatedAsync()"]]
    unresolved_unresolved_13nkcv8_interaction_target{"Unresolved: return Result.Fail(result.Errors.Select(e => e.Description).FirstOrDefault() ?? \\"Failed to update user profile.\\");"}
    unresolved_unresolved_1a2iojd_call_target{"Unresolved: SubscriptionPlans.FirstOrDefaultAsync"}
    unresolved_unresolved_1a3pyvg_interaction_target{"Unresolved: return Result.Fail(result.Errors.Select(e => e.Description).FirstOrDefault() ?? \\"Failed to reset user to free tier.\\");"}
    unresolved_unresolved_1p70858_call_target{"Unresolved: FreeName (static property)"}
    unresolved_unresolved_1vyek1g_call_target{"Unresolved: SubscriptionPlans.FirstOrDefaultAsync"}
    unresolved_unresolved_jsmstp_call_target{"Unresolved: FreeName (static property)"}
    unresolved_unresolved_rn7bsb_interaction_target{"Unresolved: var user = await _userManager.FindByEmailAsync(customerEmail);"}
    unresolved_unresolved_y7wf8y_call_target{"Unresolved: ProProductId/BasicProductId/FreeProductId (property access)"}
    class_11gdjq4_billingservice -->|contains| method_174nry_handlesubscriptiondeletedasync
    class_11gdjq4_billingservice -->|contains| method_1ctlycb_handlesubscriptionupdatedasync
    class_11gdjq4_billingservice -->|unresolved interaction| unresolved_unresolved_13nkcv8_interaction_target
    class_11gdjq4_billingservice -->|unresolved interaction| unresolved_unresolved_1a3pyvg_interaction_target
    class_11gdjq4_billingservice -->|unresolved interaction| unresolved_unresolved_rn7bsb_interaction_target
    class_11gdjq4_billingservice -->|unresolved interaction| unresolved_unresolved_rn7bsb_interaction_target
    method_174nry_handlesubscriptiondeletedasync -->|unresolved call| unresolved_unresolved_1p70858_call_target
    method_174nry_handlesubscriptiondeletedasync -->|unresolved call| unresolved_unresolved_1vyek1g_call_target
    method_1ctlycb_handlesubscriptionupdatedasync -->|unresolved call| unresolved_unresolved_1a2iojd_call_target
    method_1ctlycb_handlesubscriptionupdatedasync -->|unresolved call| unresolved_unresolved_jsmstp_call_target
    method_1ctlycb_handlesubscriptionupdatedasync -->|unresolved call| unresolved_unresolved_y7wf8y_call_target
```

### HandleSubscriptionUpdatedAsync() Control Flow

_Warnings: diagram method_1ctlycb_handlesubscriptionupdatedasync__fragment_diagram exceeds preferred complexity thresholds (73 nodes, 83 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_1ctlycb_handlesubscriptionupdatedasync__call_43_FreeName_static_property_[["FreeName (static property)"]]
    method_1ctlycb_handlesubscriptionupdatedasync__call_46_ProProductId_BasicProductId_FreeProductId_property_access_[["ProProductId/BasicProductId/FreeProductId (property access)"]]
    method_1ctlycb_handlesubscriptionupdatedasync__call_62_SubscriptionPlans_FirstOrDefaultAsync[["SubscriptionPlans.FirstOrDefaultAsync"]]
    method_1ctlycb_handlesubscriptionupdatedasync__action_34_handlesubscriptionupdatedasync_try_34_0__try("Begins protected execution")
    method_1ctlycb_handlesubscriptionupdatedasync__action_34_try_catch_34__linear("Surrounds whole operation with try/catch")
    method_1ctlycb_handlesubscriptionupdatedasync__action_36_external_read_36__linear("Load user by email")
    method_1ctlycb_handlesubscriptionupdatedasync__action_36_handlesubscriptionupdatedasync_await_36_2__await[["Waits for async work"]]
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__condition{"user == null"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__false("return-fail")
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__true("log-warning")
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__condition{"user == null"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__false("false")
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__true("true")
    method_1ctlycb_handlesubscriptionupdatedasync__action_39_handlesubscriptionupdatedasync_log_39_4__linear("Logs runtime state")
    method_1ctlycb_handlesubscriptionupdatedasync__action_39_log_39__linear("Informational and warning logs")
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__condition{"Map stripeProductId to target plan and token limit"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__false("false")
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__true("true")
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__condition{"stripeProductId == _stripeSettings.ProProductId"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__false("false")
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__true("true")
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__condition{"stripeProductId == _stripeSettings.BasicProductId"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__false("false")
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__true("true")
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__condition{"Falls back to alternate path"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__false("otherwise")
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__true("fallback")
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__condition{"!string.IsNullOrEmpty(stripeProductId) && stripeProductId != _stripeSettings.FreeProductId"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__false("false")
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__true("true")
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__condition{"Falls back to alternate path"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__false("otherwise")
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__true("fallback")
    method_1ctlycb_handlesubscriptionupdatedasync__action_58_handlesubscriptionupdatedasync_log_58_11__linear("Logs runtime state")
    method_1ctlycb_handlesubscriptionupdatedasync__action_61_db_read_61__linear("Read SubscriptionPlan entity")
    method_1ctlycb_handlesubscriptionupdatedasync__action_61_handlesubscriptionupdatedasync_await_61_12__await[["Waits for async work"]]
    method_1ctlycb_handlesubscriptionupdatedasync__action_62_handlesubscriptionupdatedasync_await_62_13__await[["Waits for async work"]]
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__condition{"plan != null"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__false("false")
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__true("true")
    method_1ctlycb_handlesubscriptionupdatedasync__action_65_persistence_write_65__linear("Apply plan and token limit to user object")
    method_1ctlycb_handlesubscriptionupdatedasync__action_69_external_write_69__linear("Persist user changes")
    method_1ctlycb_handlesubscriptionupdatedasync__action_69_handlesubscriptionupdatedasync_await_69_15__await[["Waits for async work"]]
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__condition{"Handle update failure"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__false("false")
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__true("true")
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__condition{"!result.Succeeded"}
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__false("false")
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__merge("merge")
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__true("true")
    method_1ctlycb_handlesubscriptionupdatedasync__action_72_handlesubscriptionupdatedasync_log_72_17__linear("Logs runtime state")
    method_1ctlycb_handlesubscriptionupdatedasync__action_73_handlesubscriptionupdatedasync_mapping_73_18__linear("Maps data or transforms shape")
    method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_mapping_74_20__linear("Maps data or transforms shape")
    method_1ctlycb_handlesubscriptionupdatedasync__action_79_handlesubscriptionupdatedasync_catch_79_23__catch("catch Exception ex")
    method_1ctlycb_handlesubscriptionupdatedasync__action_81_handlesubscriptionupdatedasync_log_81_24__linear("Logs runtime state")
    method_1ctlycb_handlesubscriptionupdatedasync__entry(["HandleSubscriptionUpdatedAsync entry"])
    method_1ctlycb_handlesubscriptionupdatedasync__action_36_handlesubscriptionupdatedasync_repository_read_36_1__linear[("Reads repository or persistence state")]
    method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_repository_read_74_19__linear[("Reads repository or persistence state")]
    method_1ctlycb_handlesubscriptionupdatedasync__action_40_handlesubscriptionupdatedasync_return_40_5__return(["Returns result"])
    method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_return_74_21__return(["Returns result"])
    method_1ctlycb_handlesubscriptionupdatedasync__action_77_handlesubscriptionupdatedasync_return_77_22__return(["Returns result"])
    method_1ctlycb_handlesubscriptionupdatedasync__action_77_return_77__return(["Return success"])
    method_1ctlycb_handlesubscriptionupdatedasync__action_82_handlesubscriptionupdatedasync_return_82_25__return(["Returns result"])
    method_1ctlycb_handlesubscriptionupdatedasync__action_34_handlesubscriptionupdatedasync_try_34_0__try -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_36_handlesubscriptionupdatedasync_await_36_2__await
    method_1ctlycb_handlesubscriptionupdatedasync__action_34_try_catch_34__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_34_handlesubscriptionupdatedasync_try_34_0__try
    method_1ctlycb_handlesubscriptionupdatedasync__action_36_external_read_36__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__condition
    method_1ctlycb_handlesubscriptionupdatedasync__action_36_handlesubscriptionupdatedasync_await_36_2__await -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_36_handlesubscriptionupdatedasync_repository_read_36_1__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_36_handlesubscriptionupdatedasync_repository_read_36_1__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_36_external_read_36__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__condition -->|return-fail| method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__condition -->|log-warning| method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__condition
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_37_guard_clause_37__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__condition -->|false| method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__condition -->|true| method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_39_handlesubscriptionupdatedasync_log_39_4__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_37_handlesubscriptionupdatedasync_branch_37_3__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_39_handlesubscriptionupdatedasync_log_39_4__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_39_log_39__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_39_log_39__linear -->|return| method_1ctlycb_handlesubscriptionupdatedasync__action_40_handlesubscriptionupdatedasync_return_40_5__return
    method_1ctlycb_handlesubscriptionupdatedasync__action_40_handlesubscriptionupdatedasync_return_40_5__return -->|read default Free plan name| method_1ctlycb_handlesubscriptionupdatedasync__call_43_FreeName_static_property_
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__condition -->|false| method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__condition -->|true| method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__condition
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__condition -->|false| method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__condition -->|true| method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__merge -->|compare incoming stripeProductId to configured product ids| method_1ctlycb_handlesubscriptionupdatedasync__call_46_ProProductId_BasicProductId_FreeProductId_property_access_
    method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_46_handlesubscriptionupdatedasync_branch_46_6__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__condition -->|false| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__condition -->|true| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__merge -->|fallback| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__condition
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__condition -->|otherwise| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__condition -->|fallback| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_branch_51_7__condition
    method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__condition -->|false| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__condition -->|true| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_58_handlesubscriptionupdatedasync_log_58_11__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__condition -->|otherwise| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__condition -->|fallback| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_branch_56_9__condition
    method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_56_handlesubscriptionupdatedasync_fallback_56_10__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_58_handlesubscriptionupdatedasync_log_58_11__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_61_handlesubscriptionupdatedasync_await_61_12__await
    method_1ctlycb_handlesubscriptionupdatedasync__action_61_db_read_61__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_62_handlesubscriptionupdatedasync_await_62_13__await
    method_1ctlycb_handlesubscriptionupdatedasync__action_61_handlesubscriptionupdatedasync_await_61_12__await -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_61_db_read_61__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_62_handlesubscriptionupdatedasync_await_62_13__await -->|predicate p => p.PlanName == targetPlanName| method_1ctlycb_handlesubscriptionupdatedasync__call_62_SubscriptionPlans_FirstOrDefaultAsync
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__condition -->|false| method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__condition -->|true| method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_65_persistence_write_65__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_65_persistence_write_65__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_69_handlesubscriptionupdatedasync_await_69_15__await
    method_1ctlycb_handlesubscriptionupdatedasync__action_69_external_write_69__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__condition
    method_1ctlycb_handlesubscriptionupdatedasync__action_69_handlesubscriptionupdatedasync_await_69_15__await -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_69_external_write_69__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__condition -->|false| method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__condition -->|true| method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__condition
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_70_branch_70__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__condition -->|false| method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__false
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__condition -->|true| method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__true
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__false -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__merge -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_72_handlesubscriptionupdatedasync_log_72_17__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__true -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_70_handlesubscriptionupdatedasync_branch_70_16__merge
    method_1ctlycb_handlesubscriptionupdatedasync__action_72_handlesubscriptionupdatedasync_log_72_17__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_73_handlesubscriptionupdatedasync_mapping_73_18__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_73_handlesubscriptionupdatedasync_mapping_73_18__linear -->|return| method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_return_74_21__return
    method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_mapping_74_20__linear -->|return| method_1ctlycb_handlesubscriptionupdatedasync__action_77_handlesubscriptionupdatedasync_return_77_22__return
    method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_repository_read_74_19__linear -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_mapping_74_20__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_return_74_21__return -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_74_handlesubscriptionupdatedasync_repository_read_74_19__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_77_handlesubscriptionupdatedasync_return_77_22__return -->|return| method_1ctlycb_handlesubscriptionupdatedasync__action_77_return_77__return
    method_1ctlycb_handlesubscriptionupdatedasync__action_77_return_77__return -->|exception| method_1ctlycb_handlesubscriptionupdatedasync__action_79_handlesubscriptionupdatedasync_catch_79_23__catch
    method_1ctlycb_handlesubscriptionupdatedasync__action_79_handlesubscriptionupdatedasync_catch_79_23__catch -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_81_handlesubscriptionupdatedasync_log_81_24__linear
    method_1ctlycb_handlesubscriptionupdatedasync__action_81_handlesubscriptionupdatedasync_log_81_24__linear -->|return| method_1ctlycb_handlesubscriptionupdatedasync__action_82_handlesubscriptionupdatedasync_return_82_25__return
    method_1ctlycb_handlesubscriptionupdatedasync__call_43_FreeName_static_property_ -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_46_branch_46__condition
    method_1ctlycb_handlesubscriptionupdatedasync__call_46_ProProductId_BasicProductId_FreeProductId_property_access_ -->|fallback| method_1ctlycb_handlesubscriptionupdatedasync__action_51_handlesubscriptionupdatedasync_fallback_51_8__condition
    method_1ctlycb_handlesubscriptionupdatedasync__call_62_SubscriptionPlans_FirstOrDefaultAsync -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_63_handlesubscriptionupdatedasync_branch_63_14__condition
    method_1ctlycb_handlesubscriptionupdatedasync__entry -->|next| method_1ctlycb_handlesubscriptionupdatedasync__action_34_try_catch_34__linear
```

### HandleSubscriptionDeletedAsync() Control Flow

_Warnings: diagram method_174nry_handlesubscriptiondeletedasync__fragment_diagram exceeds preferred complexity thresholds (47 nodes, 51 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_174nry_handlesubscriptiondeletedasync__call_98_FreeName_static_property_[["FreeName (static property)"]]
    method_174nry_handlesubscriptiondeletedasync__call_98_SubscriptionPlans_FirstOrDefaultAsync[["SubscriptionPlans.FirstOrDefaultAsync"]]
    method_174nry_handlesubscriptiondeletedasync__action_101_persistence_write_101__linear("Reset user's SubscriptionPlanId and AITokenLimit")
    method_174nry_handlesubscriptiondeletedasync__action_105_external_write_105__linear("Persist user changes")
    method_174nry_handlesubscriptiondeletedasync__action_105_handlesubscriptiondeletedasync_await_105_9__await[["Waits for async work"]]
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__condition{"Handle update failure"}
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__false("false")
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__merge("merge")
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__true("true")
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__condition{"!result.Succeeded"}
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__false("false")
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__merge("merge")
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__true("true")
    method_174nry_handlesubscriptiondeletedasync__action_108_handlesubscriptiondeletedasync_log_108_11__linear("Logs runtime state")
    method_174nry_handlesubscriptiondeletedasync__action_109_handlesubscriptiondeletedasync_mapping_109_12__linear("Maps data or transforms shape")
    method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_mapping_110_14__linear("Maps data or transforms shape")
    method_174nry_handlesubscriptiondeletedasync__action_115_handlesubscriptiondeletedasync_catch_115_17__catch("catch Exception ex")
    method_174nry_handlesubscriptiondeletedasync__action_117_handlesubscriptiondeletedasync_log_117_18__linear("Logs runtime state")
    method_174nry_handlesubscriptiondeletedasync__action_88_handlesubscriptiondeletedasync_try_88_0__try("Begins protected execution")
    method_174nry_handlesubscriptiondeletedasync__action_88_try_catch_88__linear("Surrounds operation with try/catch")
    method_174nry_handlesubscriptiondeletedasync__action_90_external_read_90__linear("Load user by email")
    method_174nry_handlesubscriptiondeletedasync__action_90_handlesubscriptiondeletedasync_await_90_2__await[["Waits for async work"]]
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__condition{"user == null"}
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__false("return-fail")
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__merge("merge")
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__true("log-warning")
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__condition{"user == null"}
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__false("false")
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__merge("merge")
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__true("true")
    method_174nry_handlesubscriptiondeletedasync__action_93_handlesubscriptiondeletedasync_log_93_4__linear("Logs runtime state")
    method_174nry_handlesubscriptiondeletedasync__action_93_log_93__linear("Warning and error logs")
    method_174nry_handlesubscriptiondeletedasync__action_97_db_read_97__linear("Fetch Free SubscriptionPlan")
    method_174nry_handlesubscriptiondeletedasync__action_97_handlesubscriptiondeletedasync_await_97_6__await[["Waits for async work"]]
    method_174nry_handlesubscriptiondeletedasync__action_98_handlesubscriptiondeletedasync_await_98_7__await[["Waits for async work"]]
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__condition{"freePlan != null"}
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__false("false")
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__merge("merge")
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__true("true")
    method_174nry_handlesubscriptiondeletedasync__entry(["HandleSubscriptionDeletedAsync entry"])
    method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_repository_read_110_13__linear[("Reads repository or persistence state")]
    method_174nry_handlesubscriptiondeletedasync__action_90_handlesubscriptiondeletedasync_repository_read_90_1__linear[("Reads repository or persistence state")]
    method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_return_110_15__return(["Returns result"])
    method_174nry_handlesubscriptiondeletedasync__action_113_handlesubscriptiondeletedasync_return_113_16__return(["Returns result"])
    method_174nry_handlesubscriptiondeletedasync__action_113_return_113__return(["Return success"])
    method_174nry_handlesubscriptiondeletedasync__action_118_handlesubscriptiondeletedasync_return_118_19__return(["Returns result"])
    method_174nry_handlesubscriptiondeletedasync__action_94_handlesubscriptiondeletedasync_return_94_5__return(["Returns result"])
    method_174nry_handlesubscriptiondeletedasync__action_101_persistence_write_101__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_105_handlesubscriptiondeletedasync_await_105_9__await
    method_174nry_handlesubscriptiondeletedasync__action_105_external_write_105__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__condition
    method_174nry_handlesubscriptiondeletedasync__action_105_handlesubscriptiondeletedasync_await_105_9__await -->|next| method_174nry_handlesubscriptiondeletedasync__action_105_external_write_105__linear
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__condition -->|false| method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__false
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__condition -->|true| method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__true
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__false -->|next| method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__merge
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__merge -->|next| method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__condition
    method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__true -->|next| method_174nry_handlesubscriptiondeletedasync__action_106_branch_106__merge
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__condition -->|false| method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__false
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__condition -->|true| method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__true
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__false -->|next| method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__merge
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__merge -->|next| method_174nry_handlesubscriptiondeletedasync__action_108_handlesubscriptiondeletedasync_log_108_11__linear
    method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__true -->|next| method_174nry_handlesubscriptiondeletedasync__action_106_handlesubscriptiondeletedasync_branch_106_10__merge
    method_174nry_handlesubscriptiondeletedasync__action_108_handlesubscriptiondeletedasync_log_108_11__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_109_handlesubscriptiondeletedasync_mapping_109_12__linear
    method_174nry_handlesubscriptiondeletedasync__action_109_handlesubscriptiondeletedasync_mapping_109_12__linear -->|return| method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_return_110_15__return
    method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_mapping_110_14__linear -->|return| method_174nry_handlesubscriptiondeletedasync__action_113_handlesubscriptiondeletedasync_return_113_16__return
    method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_repository_read_110_13__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_mapping_110_14__linear
    method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_return_110_15__return -->|next| method_174nry_handlesubscriptiondeletedasync__action_110_handlesubscriptiondeletedasync_repository_read_110_13__linear
    method_174nry_handlesubscriptiondeletedasync__action_113_handlesubscriptiondeletedasync_return_113_16__return -->|return| method_174nry_handlesubscriptiondeletedasync__action_113_return_113__return
    method_174nry_handlesubscriptiondeletedasync__action_113_return_113__return -->|exception| method_174nry_handlesubscriptiondeletedasync__action_115_handlesubscriptiondeletedasync_catch_115_17__catch
    method_174nry_handlesubscriptiondeletedasync__action_115_handlesubscriptiondeletedasync_catch_115_17__catch -->|next| method_174nry_handlesubscriptiondeletedasync__action_117_handlesubscriptiondeletedasync_log_117_18__linear
    method_174nry_handlesubscriptiondeletedasync__action_117_handlesubscriptiondeletedasync_log_117_18__linear -->|return| method_174nry_handlesubscriptiondeletedasync__action_118_handlesubscriptiondeletedasync_return_118_19__return
    method_174nry_handlesubscriptiondeletedasync__action_88_handlesubscriptiondeletedasync_try_88_0__try -->|next| method_174nry_handlesubscriptiondeletedasync__action_90_handlesubscriptiondeletedasync_await_90_2__await
    method_174nry_handlesubscriptiondeletedasync__action_88_try_catch_88__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_88_handlesubscriptiondeletedasync_try_88_0__try
    method_174nry_handlesubscriptiondeletedasync__action_90_external_read_90__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__condition
    method_174nry_handlesubscriptiondeletedasync__action_90_handlesubscriptiondeletedasync_await_90_2__await -->|next| method_174nry_handlesubscriptiondeletedasync__action_90_handlesubscriptiondeletedasync_repository_read_90_1__linear
    method_174nry_handlesubscriptiondeletedasync__action_90_handlesubscriptiondeletedasync_repository_read_90_1__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_90_external_read_90__linear
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__condition -->|return-fail| method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__false
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__condition -->|log-warning| method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__true
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__false -->|next| method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__merge
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__merge -->|next| method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__condition
    method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__true -->|next| method_174nry_handlesubscriptiondeletedasync__action_91_guard_clause_91__merge
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__condition -->|false| method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__false
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__condition -->|true| method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__true
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__false -->|next| method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__merge
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__merge -->|next| method_174nry_handlesubscriptiondeletedasync__action_93_log_93__linear
    method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__true -->|next| method_174nry_handlesubscriptiondeletedasync__action_91_handlesubscriptiondeletedasync_branch_91_3__merge
    method_174nry_handlesubscriptiondeletedasync__action_93_handlesubscriptiondeletedasync_log_93_4__linear -->|return| method_174nry_handlesubscriptiondeletedasync__action_94_handlesubscriptiondeletedasync_return_94_5__return
    method_174nry_handlesubscriptiondeletedasync__action_93_log_93__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_93_handlesubscriptiondeletedasync_log_93_4__linear
    method_174nry_handlesubscriptiondeletedasync__action_94_handlesubscriptiondeletedasync_return_94_5__return -->|next| method_174nry_handlesubscriptiondeletedasync__action_97_handlesubscriptiondeletedasync_await_97_6__await
    method_174nry_handlesubscriptiondeletedasync__action_97_db_read_97__linear -->|next| method_174nry_handlesubscriptiondeletedasync__action_98_handlesubscriptiondeletedasync_await_98_7__await
    method_174nry_handlesubscriptiondeletedasync__action_97_handlesubscriptiondeletedasync_await_97_6__await -->|next| method_174nry_handlesubscriptiondeletedasync__action_97_db_read_97__linear
    method_174nry_handlesubscriptiondeletedasync__action_98_handlesubscriptiondeletedasync_await_98_7__await -->|read Free plan name to find DB record| method_174nry_handlesubscriptiondeletedasync__call_98_FreeName_static_property_
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__condition -->|false| method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__false
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__condition -->|true| method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__true
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__false -->|next| method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__merge
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__merge -->|next| method_174nry_handlesubscriptiondeletedasync__action_101_persistence_write_101__linear
    method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__true -->|next| method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__merge
    method_174nry_handlesubscriptiondeletedasync__call_98_FreeName_static_property_ -->|predicate p => p.PlanName == SubscriptionPlan.FreeName| method_174nry_handlesubscriptiondeletedasync__call_98_SubscriptionPlans_FirstOrDefaultAsync
    method_174nry_handlesubscriptiondeletedasync__call_98_SubscriptionPlans_FirstOrDefaultAsync -->|next| method_174nry_handlesubscriptiondeletedasync__action_99_handlesubscriptiondeletedasync_branch_99_8__condition
    method_174nry_handlesubscriptiondeletedasync__entry -->|next| method_174nry_handlesubscriptiondeletedasync__action_88_try_catch_88__linear
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 5 unresolved jumps.
- Warning: control-flow: diagram method_1ctlycb_handlesubscriptionupdatedasync__fragment_diagram exceeds preferred complexity thresholds (73 nodes, 83 edges).
- Warning: control-flow: diagram method_174nry_handlesubscriptiondeletedasync__fragment_diagram exceeds preferred complexity thresholds (47 nodes, 51 edges).
