Skip to content

Commit 7721dd7

Browse files
authored
Merge pull request #3650 from bakaphp/hotfix-status-expire-message
fix remainFlow and est check to expire
2 parents 0d7ec74 + 6422f7f commit 7721dd7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

app/Console/Commands/Connectors/ESim/SyncEsimWithProviderCommand.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,18 @@ private function formatCmLinkResponse(Message $message, array $response, Custome
211211
$iccid = $message->message['data']['iccid'] ?? null;
212212
$userPlans = $cmLinkCustomerService->getUserPlans($iccid);
213213
$estTimezone = 'America/New_York';
214+
$nowInEST = Carbon::now()->setTimezone($estTimezone);
214215

215216
$activePlan = null;
216217
if ($iccid && ! empty($userPlans['userDataBundles'])) {
217218
foreach ($userPlans['userDataBundles'] as $plan) {
218219
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+
}
221226
}
222227
$activePlan = $plan;
223228
break;
@@ -256,7 +261,9 @@ private function formatCmLinkResponse(Message $message, array $response, Custome
256261

257262
if ($iccid && $isActive) {
258263
// 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+
}
260267
} elseif ($isActive == false && $remainingData <= 0) {
261268
$remainingData = $totalBytesData;
262269
}
@@ -306,7 +313,6 @@ private function formatCmLinkResponse(Message $message, array $response, Custome
306313
if ($expirationDate == null) {
307314
$expired = false;
308315
} else {
309-
$nowInEST = Carbon::now()->setTimezone($estTimezone);
310316
$expired = $nowInEST->greaterThan($expirationDate);
311317
}
312318

0 commit comments

Comments
 (0)