feat(payments): enhance Polar.sh provider with official API compliance

- Add comprehensive rate limiting (300 req/min) with automatic throttling
  - Implement centralized API request method for consistent authentication
  - Add support for Polar-specific webhook events (order.created, order.paid, subscription.active, customer.state_changed, benefit_grant.created)
  - Update API endpoints to match Polar's official structure (remove /v1 prefix)
  - Add external_id support for reliable customer-user mapping
  - Implement sandbox mode with separate credentials configuration
  - Add discount code support in checkout flow
  - Add credential validation method for API connectivity testing
  - Update webhook signature validation and event handling
  - Enhance error handling and logging throughout provider
  - Add proper metadata structure with user and plan information
  - Update services configuration and environment variables for sandbox support

  BREAKING CHANGE: Updated API endpoint structure and webhook event handling to comply with Polar.sh official API specification.
This commit is contained in:
idevakk
2025-11-22 06:19:27 -08:00
parent 38ae2770ea
commit ad89b84471
4 changed files with 330 additions and 82 deletions

View File

@@ -40,6 +40,14 @@ class Subscription extends Model
'migration_date',
'migration_reason',
'created_at',
'activated_at',
'checkout_id',
'customer_id',
'polar_checkout',
'order_id',
'polar_order',
'order_created_at',
'order_paid_at',
];
protected $casts = [