@@ -56,26 +56,34 @@ public SubscriptionsService(IPlansRepository plansRepository, IPaymentRepository
5656
5757 if ( ! String . IsNullOrWhiteSpace ( Config . SystemBehaviorConfig . BillingApiBaseUrl ) && ! String . IsNullOrWhiteSpace ( Config . ApiConfig . BackendInternalApikey ) )
5858 {
59- var options = new RestClientOptions ( Config . SystemBehaviorConfig . BillingApiBaseUrl )
59+ try
6060 {
61- MaxTimeout = 200000 // ms
62- } ;
61+ var options = new RestClientOptions ( Config . SystemBehaviorConfig . BillingApiBaseUrl )
62+ {
63+ MaxTimeout = 5000 // ms — fail fast so callers (e.g. Twilio webhooks) don't exceed their own timeouts
64+ } ;
6365
64- var client = new RestClient ( options , configureSerialization : s => s . UseNewtonsoftJson ( ) ) ;
65- var request = new RestRequest ( $ "/api/Billing/GetCurrentPlanForDepartment", Method . Get ) ;
66- request . AddHeader ( "X-API-Key" , Config . ApiConfig . BackendInternalApikey ) ;
67- request . AddHeader ( "Content-Type" , "application/json" ) ;
68- request . AddParameter ( "departmentId" , departmentId , ParameterType . QueryString ) ;
66+ var client = new RestClient ( options , configureSerialization : s => s . UseNewtonsoftJson ( ) ) ;
67+ var request = new RestRequest ( $ "/api/Billing/GetCurrentPlanForDepartment", Method . Get ) ;
68+ request . AddHeader ( "X-API-Key" , Config . ApiConfig . BackendInternalApikey ) ;
69+ request . AddHeader ( "Content-Type" , "application/json" ) ;
70+ request . AddParameter ( "departmentId" , departmentId , ParameterType . QueryString ) ;
6971
70- var response = await client . ExecuteAsync < GetCurrentPlanForDepartmentResult > ( request ) ;
72+ var response = await client . ExecuteAsync < GetCurrentPlanForDepartmentResult > ( request ) ;
7173
72- if ( response . StatusCode == HttpStatusCode . NotFound )
73- return freePlan ;
74+ if ( response . StatusCode == HttpStatusCode . NotFound )
75+ return freePlan ;
7476
75- if ( response . Data == null )
76- return freePlan ;
77+ if ( response . Data == null )
78+ return freePlan ;
7779
78- return response . Data . Data ;
80+ return response . Data . Data ;
81+ }
82+ catch ( Exception ex )
83+ {
84+ Framework . Logging . LogException ( ex ) ;
85+ return freePlan ;
86+ }
7987 }
8088
8189 return freePlan ;
0 commit comments