wasChanged('status') || $order->status !== 'paid') { return; } if ($order->type !== 'upgrade') { return; } try { app(ApplyPlanChange::class)->forOrder($order); } catch (Throwable $e) { // Never allowed to fail the write that marked the order paid. That // write is the record that money changed hands, and undoing it over // a plan change would erase the payment and leave nothing to retry // from. A change that did not land is loud in its own right: the // order stays unconsumed and the contract still says the old // package, both of which somebody can see. Log::error('Failed to apply the plan change a paid order bought.', [ 'order_id' => $order->id, 'plan' => $order->plan, 'error' => $e->getMessage(), ]); } } }