ifnex/04_Laravel/app/Http/Controllers/Api/MockGatewayController.php
Kazem Alghasi 2e7f975094 feat(wallet): complete online payment with Zarinpal + mock gateway
- 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
2026-08-08 00:46:54 +03:30

44 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class MockGatewayController extends Controller
{
public function showGateway(Request $request)
{
$authority = $request->input('authority');
$amount = $request->input('amount', 0);
return response()->view('mock-gateway', [
'authority' => $authority,
'amount' => $amount,
]);
}
public function simulateSuccess(Request $request)
{
$authority = $request->input('authority');
return redirect()->to(
url('/api/v1/payment/callback') . '?' . http_build_query([
'Authority' => $authority,
'Status' => 'OK',
])
);
}
public function simulateFailure(Request $request)
{
$authority = $request->input('authority');
return redirect()->to(
url('/api/v1/payment/callback') . '?' . http_build_query([
'Authority' => $authority,
'Status' => 'NOK',
])
);
}
}