feat(payment): enhance payment configuration to include active gateways and update CORS settings
This commit is contained in:
@@ -545,12 +545,36 @@ class PaymentController extends BaseController
|
||||
#[Route('/api/v1/payment/config', methods: ['GET'])]
|
||||
public function config(): JsonResponse
|
||||
{
|
||||
$testMode = $this->configRepo->get('payment_test_mode') === '1';
|
||||
|
||||
return $this->success([
|
||||
'test_mode' => $this->configRepo->get('payment_test_mode') === '1',
|
||||
'appointment_fee_rials' => (int) $this->configRepo->get('appointment_fee_rials'),
|
||||
'test_mode' => $testMode,
|
||||
'appointment_fee_rials' => (int) ($this->configRepo->get('appointment_fee_rials') ?: 0),
|
||||
'gateways' => $this->activeGateways($testMode),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* درگاههای قابلانتخاب: در حالت تست فقط درگاه آزمایشی، در غیر این صورت هر درگاهی که اعتبارنامهاش ست شده.
|
||||
* @return array<int, array{name: string, label: string}>
|
||||
*/
|
||||
private function activeGateways(bool $testMode): array
|
||||
{
|
||||
if ($testMode) {
|
||||
return [['name' => 'mellat', 'label' => 'بانک ملت (آزمایشی)']];
|
||||
}
|
||||
|
||||
$labels = ['mellat' => 'بانک ملت', 'sep' => 'سپ (سامان کیش)'];
|
||||
$gateways = [];
|
||||
foreach ([$this->mellat, $this->sep] as $gateway) {
|
||||
if ($gateway->isConfigured()) {
|
||||
$name = $gateway->getName();
|
||||
$gateways[] = ['name' => $name, 'label' => $labels[$name] ?? $name];
|
||||
}
|
||||
}
|
||||
return $gateways;
|
||||
}
|
||||
|
||||
#[IsGranted('IS_AUTHENTICATED_FULLY')]
|
||||
#[Route('/api/v1/my/payments', methods: ['GET'])]
|
||||
public function myPayments(Request $request, #[CurrentUser] User $user): JsonResponse
|
||||
|
||||
Reference in New Issue
Block a user