Implement backend support for the user notification system by adding endpoints to retrieve and manage notifications. - Add `notifications` and `markNotificationRead` methods to `CustomerOrderController` - Register notification routes under the `v1` API prefix - Update `IFNEX_User_Bridge` in WordPress to support fetching notifications and marking them as read via API calls
98 lines
6.3 KiB
PHP
98 lines
6.3 KiB
PHP
<?php
|
||
|
||
use App\Http\Controllers\Api\Customer\CustomerOrderController;
|
||
use App\Http\Controllers\Api\DiscountCodeController;
|
||
use App\Http\Controllers\Api\MockGatewayController;
|
||
use App\Http\Controllers\Api\PaymentController;
|
||
use App\Http\Controllers\Api\PricingController;
|
||
use App\Http\Controllers\Api\TrackController;
|
||
use App\Http\Controllers\Api\WalletController;
|
||
use App\Http\Middleware\ApiKeyMiddleware;
|
||
use Illuminate\Support\Facades\Route;
|
||
use App\Http\Controllers\Api\AuthController;
|
||
use App\Http\Controllers\Api\BridgeAuthController;
|
||
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// Bridge Auth API (فقط برای پلاگین وردپرس - با API Key محافظت میشود)
|
||
// ══════════════════════════════════════════════════════════════
|
||
Route::post('/v1/bridge/login', [BridgeAuthController::class, 'login']); // Login
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// API عمومی با API Key
|
||
// ══════════════════════════════════════════════════════════════
|
||
Route::middleware([ApiKeyMiddleware::class])->prefix('v1')->group(function () {
|
||
Route::get('/track/{awb_no}', [TrackController::class, 'show']);
|
||
});
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// Auth API (عمومی - برای دریافت توکن)
|
||
// ══════════════════════════════════════════════════════════════
|
||
Route::post('/v1/auth/login', [AuthController::class, 'login']);
|
||
|
||
Route::middleware(['auth:sanctum'])->post('/v1/auth/logout', [AuthController::class, 'logout']);
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// API برای کاربران لاگینشده (با Sanctum / Bearer Token)
|
||
// ══════════════════════════════════════════════════════════════
|
||
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
|
||
|
||
// ─── Wallet API (کاربر عادی) ───
|
||
Route::get('/wallet/balance', [WalletController::class, 'balance']);
|
||
Route::get('/wallet/transactions', [WalletController::class, 'transactions']);
|
||
|
||
// ─── Payment API ───
|
||
Route::post('/payment/redirect', [PaymentController::class, 'redirectToGateway']);
|
||
Route::get('/payment/check/{transaction}', [PaymentController::class, 'checkStatus']);
|
||
|
||
// ─── Admin Wallet API ───
|
||
Route::post('/wallet/admin-adjust', [WalletController::class, 'adminAdjust']);
|
||
Route::post('/wallet/{wallet}/freeze', [WalletController::class, 'freeze']);
|
||
Route::post('/wallet/{wallet}/unfreeze', [WalletController::class, 'unfreeze']);
|
||
Route::get('/wallet/{wallet}/activity-log', [WalletController::class, 'activityLog']);
|
||
|
||
// ─── Customer Orders API (جدید) ───
|
||
Route::prefix('customer')->group(function () {
|
||
// پروفایل و آمار
|
||
Route::get('/profile', [CustomerOrderController::class, 'profile']);
|
||
|
||
// لیست کشورها
|
||
Route::get('/countries', [CustomerOrderController::class, 'countries']);
|
||
|
||
// سفارشات
|
||
Route::get('/orders', [CustomerOrderController::class, 'index']);
|
||
Route::post('/orders', [CustomerOrderController::class, 'store']);
|
||
Route::get('/orders/{shipment}', [CustomerOrderController::class, 'show']);
|
||
Route::post('/orders/{shipment}/cancel', [CustomerOrderController::class, 'cancel']);
|
||
|
||
|
||
// نوتیفیکیشنها
|
||
Route::get('/notifications', [CustomerOrderController::class, 'notifications']);
|
||
Route::post('/notifications/{notification}/read', [CustomerOrderController::class, 'markNotificationRead']);
|
||
|
||
|
||
// پرداخت سفارش
|
||
Route::post('/orders/{shipment}/pay-wallet', [CustomerOrderController::class, 'payFromWallet']);
|
||
Route::post('/orders/{shipment}/pay-gateway', [CustomerOrderController::class, 'payViaGateway']);
|
||
});
|
||
});
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// Mock Gateway Routes (عمومی - برای شبیهسازی درگاه)
|
||
// ══════════════════════════════════════════════════════════════
|
||
Route::prefix('v1/payment')->group(function () {
|
||
Route::get('/mock-gateway', [MockGatewayController::class, 'showGateway']);
|
||
Route::get('/mock-gateway/success', [MockGatewayController::class, 'simulateSuccess']);
|
||
Route::get('/mock-gateway/failure', [MockGatewayController::class, 'simulateFailure']);
|
||
});
|
||
|
||
// Callback از درگاه (بدون auth)
|
||
Route::any('/v1/payment/callback', [PaymentController::class, 'callback'])
|
||
->name('payment.callback');
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// APIهای عمومی (بدون auth)
|
||
// ══════════════════════════════════════════════════════════════
|
||
Route::post('/v1/calculate', [PricingController::class, 'calculate']);
|
||
Route::get('/v1/discount-codes', [DiscountCodeController::class, 'index']);
|
||
Route::post('/v1/discount-codes/validate', [DiscountCodeController::class, 'validate']); |