Commit 66ed84c2 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(pool-reservations): add pool_reservation to cashier payment queue whitelist

The PoolReservationService already called PaymentRequestService::createRequest()
but with member_id=0 and payment_type='pool_reservation' — which was silently
rejected because 'pool_reservation' wasn't in the non-member whitelist.

- Added 'pool_reservation' to PaymentRequestService whitelist
- Added payment type label (حجز حارة سباحة)
- Added payment completion handler → marks reservation as paid
- Added void handler → reverts reservation to pending
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent d1e9d443
......@@ -24,7 +24,7 @@ final class PaymentRequestService
$notes = $data['notes'] ?? null;
$currency = $data['currency'] ?? 'EGP';
if ($memberId <= 0 && !in_array($paymentType, ['sports_registration', 'hourly_booking', 'sa_form_fee', 'sa_subscription', 'sports_subscription', 'activity_subscription', 'sa_registration_fee', 'sa_game_ticket', 'sa_pool_ticket'], true)) {
if ($memberId <= 0 && !in_array($paymentType, ['sports_registration', 'hourly_booking', 'sa_form_fee', 'sa_subscription', 'sports_subscription', 'activity_subscription', 'sa_registration_fee', 'sa_game_ticket', 'sa_pool_ticket', 'pool_reservation'], true)) {
return ['success' => false, 'error' => 'العضو مطلوب'];
}
if ($paymentType === '') {
......@@ -347,6 +347,7 @@ final class PaymentRequestService
'sa_registration_fee' => 'رسوم تسجيل نشاط رياضي',
'sa_game_ticket' => 'تذكرة لعبة ترفيهية',
'sa_pool_ticket' => 'تذكرة حمام سباحة',
'pool_reservation' => 'حجز حارة سباحة',
'activity_subscription' => 'اشتراك نشاط',
'seasonal_fee' => 'رسوم عضوية موسمية',
'foreign_membership_fee' => 'رسوم عضوية أجنبية',
......
......@@ -63,6 +63,11 @@ final class SaEventListenerService
self::handlePoolTicketPaid($data);
return;
}
if ($entityType === 'sa_pool_reservations') {
self::handlePoolReservationPaid($data);
return;
}
} catch (\Throwable $e) {
Logger::error('SA payment_request.completed listener failed: ' . $e->getMessage());
}
......@@ -119,6 +124,15 @@ final class SaEventListenerService
], 'id = ?', [(int) $poolTicket['id']]);
}
$poolRes = $db->selectOne("SELECT id FROM sa_pool_reservations WHERE payment_id = ?", [$paymentId]);
if ($poolRes) {
$db->update('sa_pool_reservations', [
'payment_status' => 'pending',
'payment_id' => null,
'updated_at' => date('Y-m-d H:i:s'),
], 'id = ?', [(int) $poolRes['id']]);
}
$enrollment = $db->selectOne(
"SELECT id FROM sa_group_players WHERE activated_by_payment_id = ? AND status = 'active'",
[$paymentId]
......@@ -239,6 +253,21 @@ final class SaEventListenerService
], 'id = ?', [$ticketId]);
}
private static function handlePoolReservationPaid(array $data): void
{
$db = App::getInstance()->db();
$reservationId = (int) ($data['related_entity_id'] ?? 0);
if ($reservationId < 1) {
return;
}
$db->update('sa_pool_reservations', [
'payment_status' => SaConstants::PAYMENT_PAID,
'payment_id' => $data['payment_id'] ?? null,
'updated_at' => date('Y-m-d H:i:s'),
], 'id = ?', [$reservationId]);
}
private static function handleEnrollmentPaid(int $enrollmentId, int $paymentId, array $data): void
{
if ($enrollmentId < 1 || $paymentId < 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment