fix: Double-charged shipping fee in Yoco payment + ops staff access

1. Fix Yoco payment amount calculation: order->total already includes
   shipping_fee, so don't add it again. Was charging 2x shipping.

2. Add authorization gate for ops staff access: users with is_admin=true
   can now access the ops page by scanning QR codes.
This commit is contained in:
twotalesanimation
2026-01-02 21:07:21 +02:00
parent ed57956694
commit 4a8b4ddac2
3 changed files with 29 additions and 1 deletions
+1 -1
View File
@@ -296,7 +296,7 @@ class OrderController extends Controller
: 'https://payments.yoco.com/api/checkouts';
$checkoutData = [
'amount' => (int)(($order->total + $order->shipping_fee) * 100), // Amount in cents, including shipping
'amount' => (int)($order->total * 100), // Amount in cents (total already includes shipping)
'currency' => 'ZAR',
'successUrl' => route('yoco-success', ['order' => $order->uuid]),
'cancelUrl' => route('yoco-cancel', ['order' => $order->uuid]),
+6
View File
@@ -30,5 +30,11 @@ class AppServiceProvider extends ServiceProvider
$cartCount = session('cart') ? count(session('cart')) : 0;
$view->with('cartCount', $cartCount);
});
// Authorization gates
\Illuminate\Support\Facades\Gate::define('access-ops', function ($user) {
// Allow admin users to access ops
return $user->is_admin === true;
});
}
}