- Add ZarinpalService for production payment gateway - Add MockZarinpalService for testing without real merchant ID - Add MockGatewayController for simulating payment page - Add beautiful mock gateway UI with RTL support - Update PaymentController to switch between mock/real based on config - Fix double-click bug: prevent re-processing completed transactions - Add payment-result page with success/failure UI - All API endpoints tested successfully: * balance, transactions, activity-log * admin-adjust (deposit/withdrawal) * freeze/unfreeze * online payment redirect + callback + verify - Wallet balance verified: 67,700,000 IRR after all transactions - 5 transactions recorded with correct gateways (manual/zarinpal) Closes: Payment gateway integration for Phase 2
50 lines
2.3 KiB
PHP
50 lines
2.3 KiB
PHP
<?php
|
||
|
||
use App\Http\Controllers\Api\DiscountCodeController;
|
||
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 Illuminate\Support\Facades\Route;
|
||
use App\Http\Middleware\ApiKeyMiddleware;
|
||
use App\Http\Controllers\Api\MockGatewayController;
|
||
|
||
|
||
|
||
// APIهای عمومی با API Key
|
||
Route::middleware([ApiKeyMiddleware::class])->prefix('v1')->group(function () {
|
||
Route::get('/track/{awb_no}', [TrackController::class, 'show']);
|
||
});
|
||
|
||
// 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']);
|
||
});
|
||
// 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']); |