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:
@@ -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]),
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user