@@ -211,13 +211,18 @@ private function formatCmLinkResponse(Message $message, array $response, Custome
211
211
$ iccid = $ message ->message ['data ' ]['iccid ' ] ?? null ;
212
212
$ userPlans = $ cmLinkCustomerService ->getUserPlans ($ iccid );
213
213
$ estTimezone = 'America/New_York ' ;
214
+ $ nowInEST = Carbon::now ()->setTimezone ($ estTimezone );
214
215
215
216
$ activePlan = null ;
216
217
if ($ iccid && ! empty ($ userPlans ['userDataBundles ' ])) {
217
218
foreach ($ userPlans ['userDataBundles ' ] as $ plan ) {
218
219
if ($ plan ['status ' ] == 3 ) {
219
- if (! empty ($ plan ['expireTime ' ]) && Carbon::parse ($ plan ['expireTime ' ])->isPast ()) {
220
- continue ;
220
+ if (! empty ($ plan ['expireTime ' ])) {
221
+ //Convert the expireTime to EST timezone before comparison
222
+ $ expireTimeInEST = Carbon::parse ($ plan ['expireTime ' ])->setTimezone ($ estTimezone );
223
+ if ($ nowInEST ->greaterThan ($ expireTimeInEST )) {
224
+ continue ;
225
+ }
221
226
}
222
227
$ activePlan = $ plan ;
223
228
break ;
@@ -256,7 +261,9 @@ private function formatCmLinkResponse(Message $message, array $response, Custome
256
261
257
262
if ($ iccid && $ isActive ) {
258
263
// Convert remainFlow to bytes - assuming it's in MB
259
- $ remainingData = (float )$ activePlan ['remainFlow ' ] * 1024 * 1024 ; // Convert MB to bytes
264
+ if (isset ($ activePlan ['remainFlow ' ])) {
265
+ $ remainingData = (float )$ activePlan ['remainFlow ' ] * 1024 * 1024 ; // Convert MB to bytes
266
+ }
260
267
} elseif ($ isActive == false && $ remainingData <= 0 ) {
261
268
$ remainingData = $ totalBytesData ;
262
269
}
@@ -306,7 +313,6 @@ private function formatCmLinkResponse(Message $message, array $response, Custome
306
313
if ($ expirationDate == null ) {
307
314
$ expired = false ;
308
315
} else {
309
- $ nowInEST = Carbon::now ()->setTimezone ($ estTimezone );
310
316
$ expired = $ nowInEST ->greaterThan ($ expirationDate );
311
317
}
312
318
0 commit comments