feat(webhooks): enhance Polar webhook processing with proper event handling
- Add support for subscription.uncanceled webhook event - Fix spelling mismatch for subscription.canceled (Polar) vs subscription.cancelled (code) - Implement proper cancel_at_period_end handling in subscription.canceled events - Add cancelled_at field updates for subscription.updated events - Handle Polar's spelling variants (canceled_at vs cancelled_at) consistently - Remove non-existent pause_reason column from subscription uncanceled handler - Enhance webhook logging with detailed field update tracking - Add comprehensive cancellation metadata storage in provider_data - Gracefully handle null provider_subscription_id in payment confirmation polling All Polar webhook events now properly sync subscription state including cancellation timing, reasons, and billing period details.
This commit is contained in:
@@ -1023,7 +1023,7 @@ class PaymentOrchestrator
|
||||
/**
|
||||
* Check subscription status via provider
|
||||
*/
|
||||
public function checkSubscriptionStatus(User $user, string $providerName, string $providerSubscriptionId): array
|
||||
public function checkSubscriptionStatus(User $user, string $providerName, ?string $providerSubscriptionId): array
|
||||
{
|
||||
try {
|
||||
$provider = $this->providerRegistry->get($providerName);
|
||||
@@ -1042,6 +1042,19 @@ class PaymentOrchestrator
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($providerSubscriptionId)) {
|
||||
Log::info('PaymentOrchestrator: Cannot check status - no provider subscription ID', [
|
||||
'user_id' => $user->id,
|
||||
'provider' => $providerName,
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'Provider subscription ID not available - webhook may not have processed yet',
|
||||
'retry_suggested' => true,
|
||||
];
|
||||
}
|
||||
|
||||
Log::info('PaymentOrchestrator: Checking subscription status', [
|
||||
'user_id' => $user->id,
|
||||
'provider' => $providerName,
|
||||
|
||||
Reference in New Issue
Block a user