Deploy Ladill Hosting / deploy (push) Failing after 17s
Shared web hosting extracted from the platform monolith, with CI deploy to /var/www/ladill-hosting matching Bird/Domains/Email. Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Hosting;
|
|
|
|
use App\Jobs\ProvisionHostingOrderJob;
|
|
use App\Models\CustomerHostingOrder;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class HostingOrderFulfillmentService
|
|
{
|
|
/**
|
|
* Approve and queue provisioning. Upstream failures (e.g. Contabo low balance)
|
|
* are handled when {@see ProvisionHostingOrderJob} runs.
|
|
*
|
|
* @return array{fulfilled: bool, reasons: array<int, string>}
|
|
*/
|
|
public function attemptAutoFulfillment(CustomerHostingOrder $order): array
|
|
{
|
|
$order->refresh()->loadMissing('product');
|
|
|
|
if (! $this->isEligibleForAutoFulfillment($order)) {
|
|
return ['fulfilled' => false, 'reasons' => ['Order is not eligible for automatic fulfillment.']];
|
|
}
|
|
|
|
$this->approveAndQueue($order);
|
|
|
|
return ['fulfilled' => true, 'reasons' => []];
|
|
}
|
|
|
|
public function approveAndQueue(CustomerHostingOrder $order): void
|
|
{
|
|
if ($order->status === CustomerHostingOrder::STATUS_APPROVED) {
|
|
ProvisionHostingOrderJob::dispatch($order->fresh());
|
|
|
|
return;
|
|
}
|
|
|
|
$meta = $order->meta ?? [];
|
|
unset($meta['upstream_funds_hold'], $meta['upstream_funds_hold_at'], $meta['provisioning_hold']);
|
|
|
|
$order->update([
|
|
'status' => CustomerHostingOrder::STATUS_APPROVED,
|
|
'approved_at' => now(),
|
|
'approved_by' => null,
|
|
'meta' => $meta,
|
|
]);
|
|
|
|
ProvisionHostingOrderJob::dispatch($order->fresh());
|
|
|
|
Log::info('Hosting order queued for provisioning', [
|
|
'order_id' => $order->id,
|
|
'domain_name' => $order->domain_name,
|
|
]);
|
|
}
|
|
|
|
private function isEligibleForAutoFulfillment(CustomerHostingOrder $order): bool
|
|
{
|
|
return in_array($order->status, [
|
|
CustomerHostingOrder::STATUS_PENDING_APPROVAL,
|
|
CustomerHostingOrder::STATUS_PENDING_PAYMENT,
|
|
], true) || (
|
|
$order->status === CustomerHostingOrder::STATUS_APPROVED
|
|
&& $order->provisioned_at === null
|
|
&& $order->hosting_account_id === null
|
|
&& $order->vps_instance_id === null
|
|
);
|
|
}
|
|
}
|