From 7c20cf705ae30c64f6c08ba867f5b9c52fa161fe Mon Sep 17 00:00:00 2001 From: isaacclad Date: Wed, 15 Jul 2026 13:23:29 +0000 Subject: [PATCH] Frame POS checkout sheet for till operators. Use operator-facing copy and merchant email so Card/MoMo checkout is for staff handing the screen to a customer, not self-serve buyers. --- .../Controllers/Pos/RegisterController.php | 2 +- app/Http/Controllers/Pos/TicketController.php | 2 +- app/Services/Pos/PosSaleService.php | 21 +++++-- .../partials/payment-checkout-host.blade.php | 1 + .../views/partials/paystack-sheet.blade.php | 59 +++++++++++++------ resources/views/pos/payment-return.blade.php | 4 +- 6 files changed, 64 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/Pos/RegisterController.php b/app/Http/Controllers/Pos/RegisterController.php index a851dc8..9e00af4 100644 --- a/app/Http/Controllers/Pos/RegisterController.php +++ b/app/Http/Controllers/Pos/RegisterController.php @@ -186,7 +186,7 @@ class RegisterController extends Controller return redirect() ->route('pos.sales.show', $sale) ->with('checkout_url', $result['checkout_url']) - ->with('success', 'Complete the payment to finish this sale.'); + ->with('success', 'Payment sheet ready — hand the device to the customer for card or MoMo.'); } catch (RuntimeException $e) { return back()->withInput()->with('error', $e->getMessage()); } diff --git a/app/Http/Controllers/Pos/TicketController.php b/app/Http/Controllers/Pos/TicketController.php index e9e4388..40f7e1a 100644 --- a/app/Http/Controllers/Pos/TicketController.php +++ b/app/Http/Controllers/Pos/TicketController.php @@ -237,7 +237,7 @@ class TicketController extends Controller return redirect() ->route('pos.tickets.show', $sale) ->with('checkout_url', $result['checkout_url']) - ->with('success', 'Complete the payment to settle this ticket.'); + ->with('success', 'Payment sheet ready — hand the device to the customer for card or MoMo.'); } catch (RuntimeException $e) { return back()->with('error', $e->getMessage()); } diff --git a/app/Services/Pos/PosSaleService.php b/app/Services/Pos/PosSaleService.php index 064c768..8b33122 100644 --- a/app/Services/Pos/PosSaleService.php +++ b/app/Services/Pos/PosSaleService.php @@ -300,15 +300,22 @@ class PosSaleService 'status' => PosPayment::STATUS_PENDING, ]); + // Till-operator checkout: gateways require an email; use the merchant + // account (not a walk-up customer) so the register can complete Card/MoMo. + $operatorEmail = trim((string) ($merchant->email ?? '')); + if ($operatorEmail === '' || ! str_contains($operatorEmail, '@')) { + $operatorEmail = 'seller+'.($merchant->public_id ?? 'pos').'@checkout.ladill.local'; + } + $reference = 'POSP-'.strtoupper(Str::random(16)); $checkout = $this->gateway->initializeCheckout( $merchant, $amount, (string) ($sale->currency ?? 'GHS'), - (string) (trim((string) ($merchant->email ?? '')) !== '' ? $merchant->email : ('seller+'.($merchant->public_id ?? 'pos').'@checkout.ladill.local')), + $operatorEmail, route('pos.payments.callback'), $reference, - ['title' => 'Ticket '.$sale->reference.' payment', 'pos_sale_id' => $sale->id, 'pos_payment_id' => $payment->id], + ['title' => 'Ticket '.$sale->reference.' payment', 'pos_sale_id' => $sale->id, 'pos_payment_id' => $payment->id, 'channel' => 'pos_till'], ); $payment->forceFill([ @@ -502,14 +509,20 @@ class PosSaleService $amount = (int) $sale->total_minor; } + // Till-operator checkout: use merchant email (register staff), not a guest. + $operatorEmail = trim((string) ($merchant->email ?? '')); + if ($operatorEmail === '' || ! str_contains($operatorEmail, '@')) { + $operatorEmail = 'seller+'.($merchant->public_id ?? 'pos').'@checkout.ladill.local'; + } + $checkout = $this->gateway->initializeCheckout( $merchant, $amount, (string) ($sale->currency ?? 'GHS'), - (string) (trim((string) ($merchant->email ?? '')) !== '' ? $merchant->email : ('seller+'.($merchant->public_id ?? 'pos').'@checkout.ladill.local')), + $operatorEmail, $callbackUrl, $reference, - ['title' => 'POS '.$sale->reference, 'pos_sale_id' => $sale->id, 'pos_reference' => $sale->reference], + ['title' => 'POS '.$sale->reference, 'pos_sale_id' => $sale->id, 'pos_reference' => $sale->reference, 'channel' => 'pos_till'], ); $checkoutUrl = $checkout['checkout_url']; diff --git a/resources/views/partials/payment-checkout-host.blade.php b/resources/views/partials/payment-checkout-host.blade.php index 1e2c827..b456685 100644 --- a/resources/views/partials/payment-checkout-host.blade.php +++ b/resources/views/partials/payment-checkout-host.blade.php @@ -1,3 +1,4 @@ +{{-- Global host for till-operator Card/MoMo sheets (register + open tickets). --}}