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
This commit is contained in:
Kazem Alghasi 2026-08-08 00:46:54 +03:30
parent 78f5919b69
commit 2e7f975094
8 changed files with 532 additions and 70 deletions

View File

@ -0,0 +1,44 @@
<?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',
])
);
}
}

View File

@ -4,14 +4,12 @@ namespace App\Http\Controllers\Api;
use App\Enums\PaymentGateway;
use App\Enums\TransactionStatus;
use App\Enums\TransactionType;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Models\Wallet;
use App\Models\WalletActivityLog;
use App\Models\WalletTransaction;
use App\Services\WalletService;
use App\Services\ZarinpalService;
use App\Services\MockZarinpalService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@ -21,12 +19,21 @@ class PaymentController extends Controller
{
public function __construct(
protected WalletService $walletService,
protected ZarinpalService $zarinpalService
protected ZarinpalService $zarinpalService,
protected MockZarinpalService $mockZarinpalService
) {}
/**
* ارسال کاربر به درگاه پرداخت
*/
private function isMockMode(): bool
{
return config('ifnex.zarinpal.merchant_id') === 'fake-merchant-id-for-testing'
|| config('ifnex.zarinpal.sandbox', true);
}
private function getGatewayService()
{
return $this->isMockMode() ? $this->mockZarinpalService : $this->zarinpalService;
}
public function redirectToGateway(Request $request): JsonResponse
{
$user = $request->user();
@ -36,9 +43,9 @@ class PaymentController extends Controller
}
$validated = $request->validate([
'amount' => ['required', 'numeric', 'min:10000'], // حداقل ۱۰ هزار ریال
'amount' => ['required', 'numeric', 'min:10000'],
'description' => ['nullable', 'string', 'max:500'],
'frontend_callback' => ['nullable', 'url', 'max:500'], // URL فرانت‌اند برای redirect بعد از پرداخت
'frontend_callback' => ['nullable', 'url', 'max:500'],
]);
$wallet = $user->wallet ?? Wallet::create([
@ -46,15 +53,13 @@ class PaymentController extends Controller
'balance' => 0,
]);
// بررسی مسدود نبودن کیف پول
if ($wallet->isFrozen()) {
return response()->json([
'message' => 'کیف پول شما مسدود است. لطفاً با پشتیبانی تماس بگیرید.',
'message' => 'کیف پول شما مسدود است.',
], 403);
}
try {
// ایجاد تراکنش pending
$transaction = $this->walletService->requestDeposit(
wallet: $wallet,
amount: $validated['amount'],
@ -63,18 +68,18 @@ class PaymentController extends Controller
gateway: PaymentGateway::ZARINPAL
);
// دریافت لینک پرداخت از زرین‌پال
$paymentData = $this->zarinpalService->requestPayment(
$gateway = $this->getGatewayService();
$paymentData = $gateway->requestPayment(
amount: $validated['amount'],
description: $validated['description'] ?? 'شارژ کیف پول IFNEX',
mobile: $user->phone,
email: $user->email
);
// ذخیره authority و frontend_callback در metadata
$metadata = $transaction->metadata ?? [];
$metadata['zarinpal_authority'] = $paymentData['authority'];
$metadata['frontend_callback'] = $validated['frontend_callback'] ?? null;
$metadata['is_mock'] = $this->isMockMode();
$transaction->update(['metadata' => $metadata]);
return response()->json([
@ -84,6 +89,7 @@ class PaymentController extends Controller
'transaction_id' => $transaction->id,
'authority' => $paymentData['authority'],
'amount' => $paymentData['amount'],
'is_mock' => $this->isMockMode(),
]);
} catch (\Exception $e) {
@ -99,95 +105,145 @@ class PaymentController extends Controller
}
}
/**
* Callback از درگاه پرداخت (بعد از بازگشت کاربر)
*/
public function callback(Request $request): RedirectResponse
{
$authority = $request->input('Authority');
$status = $request->input('Status'); // OK یا NOK
$status = $request->input('Status');
// پیدا کردن تراکنش بر اساس authority
$transaction = WalletTransaction::whereJsonContains('metadata->zarinpal_authority', $authority)->first();
Log::info('Payment callback received', [
'authority' => $authority,
'status' => $status,
]);
// پیدا کردن تراکنش با JSON_EXTRACT
$transaction = WalletTransaction::whereRaw(
"JSON_EXTRACT(metadata, '$.zarinpal_authority') = ?",
[$authority]
)->first();
// Fallback برای MySQL قدیمی‌تر
if (!$transaction) {
Log::warning('Payment callback: transaction not found', ['authority' => $authority]);
return redirect(config('ifnex.zarinpal.frontend_failure_url', '/payment/failed'));
$transaction = WalletTransaction::where('metadata->zarinpal_authority', $authority)->first();
}
$frontendCallback = $transaction->metadata['frontend_callback'] ?? config('ifnex.zarinpal.frontend_failure_url', '/payment/failed');
if (!$transaction) {
Log::warning('Payment callback: transaction not found', [
'authority' => $authority,
]);
return redirect(config('ifnex.zarinpal.frontend_failure_url', '/') . '?' . http_build_query([
'status' => 'error',
'message' => 'تراکنش یافت نشد',
]));
}
// ✅ اصلاح: تعریف $frontendCallback در ابتدای متد (قبل از هر استفاده)
$frontendCallback = $transaction->metadata['frontend_callback']
?? config('ifnex.zarinpal.frontend_failure_url', '/');
// بررسی اینکه تراکنش قبلاً پردازش نشده باشد
if ($transaction->status !== TransactionStatus::PENDING) {
Log::info('Transaction already processed', [
'transaction_id' => $transaction->id,
'current_status' => $transaction->status->value,
]);
if ($transaction->status === TransactionStatus::COMPLETED) {
return redirect($frontendCallback . '?' . http_build_query([
'status' => 'success',
'transaction_id' => $transaction->id,
'ref_id' => $transaction->gateway_reference_id ?? '',
'amount' => $transaction->amount,
'message' => 'این تراکنش قبلاً پردازش شده است',
]));
}
return redirect($frontendCallback . '?' . http_build_query([
'status' => 'failed',
'transaction_id' => $transaction->id,
'message' => 'این تراکنش قبلاً ناموفق شده است',
]));
}
// کاربر پرداخت را لغو کرده
if ($status !== 'OK') {
$this->walletService->failTransaction($transaction, 'کاربر پرداخت را لغو کرد یا پرداخت ناموفق بود.');
$this->walletService->failTransaction($transaction, 'کاربر پرداخت را لغو کرد.');
$failureUrl = $frontendCallback . '?' . http_build_query([
return redirect($frontendCallback . '?' . http_build_query([
'status' => 'failed',
'transaction_id' => $transaction->id,
'message' => 'پرداخت ناموفق بود',
]);
return redirect($failureUrl);
]));
}
// تایید پرداخت با درگاه
try {
// بررسی صحت پرداخت
$verification = $this->zarinpalService->verifyPayment(
Log::info('Verifying payment', [
'transaction_id' => $transaction->id,
'authority' => $authority,
'current_status' => $transaction->status->value,
]);
$gateway = $this->getGatewayService();
$verification = $gateway->verifyPayment(
authority: $authority,
expectedAmount: $transaction->amount
);
Log::info('Payment verification result', [
'transaction_id' => $transaction->id,
'verification' => $verification,
]);
if (!$verification['success']) {
$this->walletService->failTransaction(
$transaction,
'تأیید درگاه ناموفق بود: ' . ($verification['error_message'] ?? 'نامشخص')
'تأیید درگاه ناموفق: ' . ($verification['error_message'] ?? 'نامشخص')
);
$failureUrl = $frontendCallback . '?' . http_build_query([
return redirect($frontendCallback . '?' . http_build_query([
'status' => 'failed',
'transaction_id' => $transaction->id,
'message' => 'تأیید پرداخت ناموفق بود',
]);
return redirect($failureUrl);
]));
}
// تأیید تراکنش و افزایش موجودی
$this->walletService->completeDeposit(
transaction: $transaction,
gatewayReferenceId: $verification['ref_id'] ?? $authority
);
$successUrl = config('ifnex.zarinpal.frontend_success_url', '/payment/success') . '?' . http_build_query([
Log::info('Payment completed successfully', [
'transaction_id' => $transaction->id,
'amount' => $transaction->amount,
]);
return redirect($frontendCallback . '?' . http_build_query([
'status' => 'success',
'transaction_id' => $transaction->id,
'ref_id' => $verification['ref_id'] ?? '',
'amount' => $transaction->amount,
]);
return redirect($successUrl);
]));
} catch (\Exception $e) {
Log::error('Payment callback error', [
'transaction_id' => $transaction->id,
'error' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString(),
]);
$this->walletService->failTransaction($transaction, 'خطای سیستمی: ' . $e->getMessage());
$failureUrl = $frontendCallback . '?' . http_build_query([
return redirect($frontendCallback . '?' . http_build_query([
'status' => 'failed',
'transaction_id' => $transaction->id,
'message' => 'خطای سیستمی در پردازش پرداخت',
]);
return redirect($failureUrl);
'message' => 'خطای سیستمی: ' . $e->getMessage(),
]));
}
}
/**
* استعلام وضعیت یک پرداخت
*/
public function checkStatus(Request $request, $transactionId): JsonResponse
{
$user = $request->user();

View File

@ -0,0 +1,52 @@
<?php
namespace App\Services;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
class MockZarinpalService
{
public function requestPayment(
float $amount,
string $description,
?string $mobile = null,
?string $email = null
): array {
$authority = 'MOCK_' . Str::upper(Str::random(32));
Log::info('Mock Zarinpal Payment Request', [
'amount' => $amount,
'authority' => $authority,
]);
return [
'authority' => $authority,
'payment_url' => url("/api/v1/payment/mock-gateway?authority={$authority}&amount={$amount}"),
'amount' => $amount,
'amount_toman' => (int) round($amount / 10),
];
}
public function verifyPayment(string $authority, float $expectedAmount): array
{
Log::info('Mock Zarinpal Payment Verification', [
'authority' => $authority,
]);
if (str_starts_with($authority, 'MOCK_')) {
return [
'success' => true,
'ref_id' => 'MOCK_REF_' . Str::upper(Str::random(16)),
'card_hash' => 'MOCK_HASH_' . rand(100000, 999999),
'card_pan' => '6037****' . rand(1000, 9999),
];
}
return [
'success' => false,
'error_code' => -1,
'error_message' => 'Authority نامعتبر است',
];
}
}

View File

@ -2,7 +2,6 @@
namespace App\Services;
use App\Models\WalletTransaction;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
@ -10,31 +9,29 @@ class ZarinpalService
{
private string $merchantId;
private string $baseUrl;
private string $callbackUrl;
private ?string $callbackUrl;
public function __construct()
{
$this->merchantId = config('ifnex.zarinpal.merchant_id', 'fake-merchant-id-for-testing');
$isProduction = config('ifnex.zarinpal.sandbox', true);
$isSandbox = config('ifnex.zarinpal.sandbox', true);
// URLs برای محیط تست و واقعی
$this->baseUrl = $isProduction
$this->baseUrl = $isSandbox
? 'https://sandbox.zarinpal.com/pg/v4'
: 'https://api.zarinpal.com/pg/v4';
$this->callbackUrl = config('ifnex.zarinpal.callback_url', url('/api/v1/payment/callback'));
// ✅ اصلاح: مدیریت null و تنظیم callback
$this->callbackUrl = config('ifnex.zarinpal.callback_url')
?? url('/api/v1/payment/callback');
}
/**
* ایجاد درخواست پرداخت (Payment Request)
*/
public function requestPayment(
float $amount,
string $description,
?string $mobile = null,
?string $email = null
): array {
$amountToman = (int) round($amount / 10); // ریال به تومان
$amountToman = (int) round($amount / 10);
$response = Http::timeout(30)->post("{$this->baseUrl}/PaymentRequest.json", [
'merchant_id' => $this->merchantId,
@ -55,8 +52,8 @@ class ZarinpalService
'response' => $result,
]);
if ($result['data']['code'] !== 100) {
throw new \Exception('خطا در ارتباط با زرین‌پال: ' . ($result['errors']['message'] ?? 'نامشخص'));
if (!isset($result['data']['code']) || $result['data']['code'] !== 100) {
throw new \Exception('خطا در ارتباط با زرین‌پال: ' . ($result['errors']['message'] ?? $result['data']['message'] ?? 'نامشخص'));
}
$authority = $result['data']['authority'];
@ -70,9 +67,6 @@ class ZarinpalService
];
}
/**
* بررسی صحت پرداخت (Verification)
*/
public function verifyPayment(string $authority, float $expectedAmount): array
{
$amountToman = (int) round($expectedAmount / 10);
@ -90,6 +84,14 @@ class ZarinpalService
'response' => $result,
]);
if (!isset($result['data']['code'])) {
return [
'success' => false,
'error_code' => -1,
'error_message' => 'پاسخ نامعتبر از زرین‌پال',
];
}
if ($result['data']['code'] === 100) {
return [
'success' => true,
@ -98,7 +100,6 @@ class ZarinpalService
'card_pan' => $result['data']['card_pan'] ?? null,
];
} elseif ($result['data']['code'] === 101) {
// قبلاً verify شده
return [
'success' => true,
'ref_id' => $result['data']['ref_id'] ?? null,
@ -113,13 +114,10 @@ class ZarinpalService
];
}
/**
* ساخت لینک پرداخت
*/
private function getPaymentUrl(string $authority): string
{
$isProduction = config('ifnex.zarinpal.sandbox', true);
$gatewayUrl = $isProduction
$isSandbox = config('ifnex.zarinpal.sandbox', true);
$gatewayUrl = $isSandbox
? 'https://sandbox.zarinpal.com/pg/StartPay/'
: 'https://www.zarinpal.com/pg/StartPay/';

View File

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🔐 درگاه پرداخت شبیه‌سازی شده - IFNEX</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: Tahoma, Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
padding: 20px;
}
.gateway-card {
background: white;
border-radius: 16px;
padding: 40px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 420px;
width: 100%;
text-align: center;
}
.logo {
font-size: 48px;
margin-bottom: 10px;
}
h1 { color: #333; font-size: 22px; margin-bottom: 8px; }
.subtitle { color: #888; font-size: 13px; margin-bottom: 30px; }
.amount-box {
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
padding: 25px;
border-radius: 12px;
margin: 20px 0;
}
.amount-box .label { font-size: 14px; opacity: 0.9; margin-bottom: 8px; }
.amount-box .value { font-size: 32px; font-weight: bold; }
.amount-box .unit { font-size: 16px; opacity: 0.8; margin-right: 5px; }
.authority {
background: #f5f5f5;
padding: 10px;
border-radius: 8px;
font-size: 11px;
color: #666;
margin: 20px 0;
word-break: break-all;
font-family: monospace;
}
.buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 25px; }
.btn {
padding: 16px 24px;
border: none;
border-radius: 10px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s;
text-decoration: none;
display: block;
font-family: inherit;
}
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; transform: translateY(-2px); }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-2px); }
.warning {
background: #fef3c7;
border: 1px solid #f59e0b;
border-radius: 8px;
padding: 12px;
font-size: 12px;
color: #92400e;
margin-top: 20px;
}
.test-badge {
display: inline-block;
background: #fee2e2;
color: #991b1b;
padding: 4px 12px;
border-radius: 20px;
font-size: 11px;
font-weight: bold;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="gateway-card">
<div class="logo">🔐</div>
<span class="test-badge">🧪 محیط تست (Mock)</span>
<h1>درگاه پرداخت IFNEX</h1>
<p class="subtitle">شبیه‌ساز زرین‌پال تراکنش واقعی انجام نمی‌شود</p>
<div class="amount-box">
<div class="label">مبلغ قابل پرداخت</div>
<div class="value">
{{ number_format($amount) }}
<span class="unit">ریال</span>
</div>
</div>
<div class="authority">
Authority: {{ $authority }}
</div>
<div class="buttons">
<a href="{{ url('/api/v1/payment/mock-gateway/success?authority=' . $authority) }}" class="btn btn-success">
پرداخت موفق
</a>
<a href="{{ url('/api/v1/payment/mock-gateway/failure?authority=' . $authority) }}" class="btn btn-danger">
انصراف از پرداخت
</a>
</div>
<div class="warning">
⚠️ این صفحه فقط برای تست است. در محیط Production، کاربر به درگاه واقعی زرین‌پال هدایت می‌شود.
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,159 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ $isSuccess ? 'پرداخت موفق' : 'پرداخت ناموفق' }} - IFNEX</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: Tahoma, Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
padding: 20px;
}
.result-card {
background: white;
border-radius: 16px;
padding: 40px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 500px;
width: 100%;
text-align: center;
}
.icon {
font-size: 64px;
margin-bottom: 20px;
}
.success-icon { color: #10b981; }
.failure-icon { color: #ef4444; }
h1 {
color: #333;
font-size: 24px;
margin-bottom: 10px;
}
.message {
color: #666;
font-size: 14px;
margin-bottom: 30px;
}
.details {
background: #f5f5f5;
border-radius: 12px;
padding: 20px;
margin: 20px 0;
text-align: right;
}
.detail-row {
display: flex;
justify-content: space-between;
padding: 8px 0;
border-bottom: 1px solid #e5e5e5;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: #666; font-size: 14px; }
.detail-value { color: #333; font-weight: bold; font-size: 14px; }
.amount {
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
padding: 20px;
border-radius: 12px;
margin: 20px 0;
}
.amount .value {
font-size: 32px;
font-weight: bold;
}
.amount .unit {
font-size: 16px;
opacity: 0.9;
}
.btn {
background: #667eea;
color: white;
padding: 14px 32px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
text-decoration: none;
display: inline-block;
margin-top: 20px;
transition: all 0.3s;
}
.btn:hover {
background: #5568d3;
transform: translateY(-2px);
}
.warning {
background: #fef3c7;
border: 1px solid #f59e0b;
border-radius: 8px;
padding: 12px;
font-size: 13px;
color: #92400e;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="result-card">
@if($isSuccess)
<div class="icon success-icon"></div>
<h1>پرداخت موفق</h1>
<p class="message">پرداخت شما با موفقیت انجام شد و کیف پول شارژ گردید.</p>
@if($amount)
<div class="amount">
<div class="value">{{ number_format((float)$amount) }}</div>
<div class="unit">ریال</div>
</div>
@endif
<div class="details">
<div class="detail-row">
<span class="detail-label">شناسه تراکنش:</span>
<span class="detail-value">#{{ $transactionId }}</span>
</div>
@if($refId)
<div class="detail-row">
<span class="detail-label">کد پیگیری:</span>
<span class="detail-value">{{ $refId }}</span>
</div>
@endif
@if($message)
<div class="detail-row">
<span class="detail-label">پیام:</span>
<span class="detail-value">{{ $message }}</span>
</div>
@endif
</div>
@else
<div class="icon failure-icon"></div>
<h1>پرداخت ناموفق</h1>
<p class="message">{{ $message ?? 'پرداخت شما انجام نشد. لطفاً دوباره تلاش کنید.' }}</p>
@if($transactionId)
<div class="details">
<div class="detail-row">
<span class="detail-label">شناسه تراکنش:</span>
<span class="detail-value">#{{ $transactionId }}</span>
</div>
</div>
@endif
@endif
<a href="http://localhost:8000/admin" class="btn">
بازگشت به پنل مدیریت
</a>
<div class="warning">
⚠️ این یک صفحه تست است. در محیط Production، این صفحه باید با طراحی برند IFNEX تطبیق داده شود.
</div>
</div>
</body>
</html>

View File

@ -7,6 +7,9 @@ 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 () {
@ -30,6 +33,12 @@ Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
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'])

View File

@ -20,3 +20,23 @@ Route::middleware('auth')->group(function () {
Route::get('/shipments/{shipment}/pdf/invoice', [ShipmentPdfController::class, 'invoice'])->name('shipments.pdf.invoice');
Route::get('/shipments/{shipment}/pdf/label', [ShipmentPdfController::class, 'label'])->name('shipments.pdf.label');
});
// صفحات نتیجه پرداخت (برای تست)
Route::get('/payment-result', function (Illuminate\Http\Request $request) {
$status = $request->input('status');
$transactionId = $request->input('transaction_id');
$refId = $request->input('ref_id');
$amount = $request->input('amount');
$message = $request->input('message');
$isSuccess = $status === 'success';
return view('payment-result', [
'status' => $status,
'isSuccess' => $isSuccess,
'transactionId' => $transactionId,
'refId' => $refId,
'amount' => $amount,
'message' => $message,
]);
})->name('payment.result');