Deploy Ladill Mini / deploy (push) Successful in 23s
Staff-facing counter register at pos.ladill.com with catalog cart, cash and MoMo/card checkout via Ladill Pay, CRM timeline/import, invoice prefill, and Merchant catalog import. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Pos;
|
|
|
|
use App\Models\PosSale;
|
|
use App\Services\Crm\CrmClient;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class PosTimelineService
|
|
{
|
|
public function pushPaidSale(PosSale $sale): void
|
|
{
|
|
if ($sale->status !== PosSale::STATUS_PAID) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
CrmClient::for($sale->owner_ref)->pushTimeline([
|
|
'event' => 'order.paid',
|
|
'title' => 'POS sale '.$sale->reference,
|
|
'external_id' => (string) $sale->id,
|
|
'amount_minor' => (int) $sale->total_minor,
|
|
'currency' => (string) $sale->currency,
|
|
'url' => route('pos.sales.show', $sale),
|
|
'customer_id' => $sale->crm_customer_id,
|
|
'customer_email' => $sale->customer_email,
|
|
'customer_phone' => $sale->customer_phone,
|
|
'customer_name' => $sale->customer_name,
|
|
'description' => ucfirst($sale->payment_method).' payment at register',
|
|
'occurred_at' => ($sale->paid_at ?? now())->toIso8601String(),
|
|
]);
|
|
} catch (\Throwable $e) {
|
|
Log::info('CRM timeline push skipped for POS sale', [
|
|
'sale_id' => $sale->id,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
}
|
|
}
|
|
}
|