Commit 6d9424f3 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(sports): complete registration when subscription is paid

handleSubscriptionPaid() now finds the player's assessed registration
and marks it as completed (payment_status='paid', status='completed').
Previously, paying the subscription only updated sa_subscriptions but
never flowed back to sa_registrations, leaving the wizard card button
permanently disabled.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent f7c01e7d
......@@ -137,6 +137,8 @@ final class SaEventListenerService
private static function handleSubscriptionPaid(array $data): void
{
$db = App::getInstance()->db();
$subscriptionId = (int) ($data['related_entity_id'] ?? 0);
$db->update('sa_subscriptions', [
'payment_status' => SaConstants::PAYMENT_PAID,
'paid_at' => date('Y-m-d H:i:s'),
......@@ -145,7 +147,26 @@ final class SaEventListenerService
'receipt_id' => $data['receipt_id'] ?? null,
'receipt_number' => $data['receipt_number'] ?? null,
'updated_at' => date('Y-m-d H:i:s'),
], 'id = ?', [(int) ($data['related_entity_id'] ?? 0)]);
], 'id = ?', [$subscriptionId]);
$sub = $db->selectOne(
"SELECT player_id FROM sa_subscriptions WHERE id = ?",
[$subscriptionId]
);
if ($sub) {
$reg = $db->selectOne(
"SELECT id FROM sa_registrations WHERE player_id = ? AND status = 'assessed' AND payment_status = 'unpaid' ORDER BY id DESC LIMIT 1",
[(int) $sub['player_id']]
);
if ($reg) {
$db->update('sa_registrations', [
'payment_status' => SaConstants::PAYMENT_PAID,
'status' => 'completed',
'completed_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
], 'id = ?', [(int) $reg['id']]);
}
}
}
private static function handleBookingPaid(array $data): void
......
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