where('created_at', '>', now()->subMonths(2)) ->where('gateway_type_id', 2) ->whereHas('gateway', function ($q) { $q->whereIn('gateway_key', ['d14dd26a37cecc30fdd65700bfb55b23','d14dd26a47cecc30fdd65700bfb67b34']); }) ->whereJsonContains('meta', ['state' => 'unauthorized']) ->cursor() ->each(function ($token) { try { $stripe = $token->gateway->driver($token->client)->init(); $pm = $stripe->getStripePaymentMethod($token->token); if($pm) { $meta = $token->meta; $meta->state = 'authorized'; $token->meta = $meta; $token->save(); } } catch (\Exception $e) { } }); } } }