feat(payment): implement beautiful payment confirmation page with real-time status checking
- Add PaymentSuccessController with authentication and subscription selection logic - Create PaymentConfirmation Livewire component with polling mechanism - Implement real-time subscription status verification via Polar provider API - Add confetti animation for successful payment confirmation - Design responsive payment success page with dark mode support - Fix Polar provider field mapping (updated_at -> modified_at) - Add comprehensive error handling and logging - Support multiple subscription status states (verifying, activated, pending, error) - Implement automatic polling with 30-second intervals (max 5 attempts) - Add fallback redirects and user-friendly status messages
This commit is contained in:
@@ -938,4 +938,63 @@ class PaymentOrchestrator
|
||||
'avg_extension_days' => $totalExtensions > 0 ? $totalDaysExtended / $totalExtensions : 0,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check subscription status via provider
|
||||
*/
|
||||
public function checkSubscriptionStatus(User $user, string $providerName, string $providerSubscriptionId): array
|
||||
{
|
||||
try {
|
||||
$provider = $this->providerRegistry->get($providerName);
|
||||
|
||||
if (! $provider) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => "Provider {$providerName} not found",
|
||||
];
|
||||
}
|
||||
|
||||
if (! $provider->isActive()) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => "Provider {$providerName} is not active",
|
||||
];
|
||||
}
|
||||
|
||||
Log::info('PaymentOrchestrator: Checking subscription status', [
|
||||
'user_id' => $user->id,
|
||||
'provider' => $providerName,
|
||||
'provider_subscription_id' => $providerSubscriptionId,
|
||||
]);
|
||||
|
||||
// Get subscription details from provider
|
||||
$details = $provider->getSubscriptionDetails($providerSubscriptionId);
|
||||
|
||||
if (empty($details)) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'Unable to fetch subscription details from provider',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => $details['status'] ?? 'unknown',
|
||||
'details' => $details,
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
Log::error('PaymentOrchestrator: Error checking subscription status', [
|
||||
'user_id' => $user->id,
|
||||
'provider' => $providerName,
|
||||
'provider_subscription_id' => $providerSubscriptionId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user