feat(payment): implement comprehensive Polar subscription sync with proper date and cancellation handling

- Add Polar-specific date field mapping in PaymentOrchestrator (current_period_start, current_period_end, cancelled_at, trial_end)
  - Handle both cancellation scenarios: cancel_at_period_end=true and existing cancelled_at timestamp
  - Map customer_cancellation_reason and customer_cancellation_comment from Polar to database
  - Update billing page to show correct renewal vs expiry dates based on cancellation status
  - Restrict cancel button to activation_key provider only (Polar uses customer portal)
  - Fix button spacing between "Manage in Polar" and "Sync" buttons
  - Ensure both "Sync" and "Recheck Status" buttons use identical sync functionality
This commit is contained in:
idevakk
2025-12-06 10:42:25 -08:00
parent 0724e6da43
commit 15e018eb88
4 changed files with 150 additions and 18 deletions

View File

@@ -68,7 +68,11 @@
@if($latestActiveSubscription->isActive())
<flux:text class="mt-1 text-sm text-gray-500 dark:text-gray-500">
@if($latestActiveSubscription->ends_at)
{{ __('Renews on :date', ['date' => $latestActiveSubscription->ends_at->format('M j, Y')]) }}
@if($latestActiveSubscription->cancelled_at)
{{ __('Expires on :date', ['date' => $latestActiveSubscription->ends_at->format('M j, Y')]) }}
@else
{{ __('Renews on :date', ['date' => $latestActiveSubscription->ends_at->format('M j, Y')]) }}
@endif
@else
{{ __('Active subscription') }}
@endif
@@ -93,7 +97,7 @@
wire:click="managePolarSubscription"
variant="outline"
size="sm"
class="w-full sm:w-auto cursor-pointer"
class="w-full sm:w-auto cursor-pointer sm:mr-2"
>
{{ __('Manage in Polar') }}
</flux:button>
@@ -112,7 +116,7 @@
</flux:button>
@endif
@if($latestActiveSubscription->isActive() && $latestActiveSubscription->provider !== 'activation_key')
@if($latestActiveSubscription->isActive() && in_array($latestActiveSubscription->provider, ['activation_key']))
<flux:button
wire:click="confirmCancelSubscription({{ $latestActiveSubscription->id }})"
variant="danger"