laravel / cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.
https://laravel.com/docs/cashier-paddle
MIT License
238 stars 57 forks source link

[2.x] add end at of the subscription period #227

Closed majdiyassin20 closed 8 months ago

majdiyassin20 commented 8 months ago

hello, i don't know when the subscription will be end and when the next billing for renew in database subscription table i found the end_at is null is their any way can we get it ? for my solution: I checked the handleSubscriptionCreated webhook controller and i found it's have

if (isset($data['canceled_at'])) {
            $subscription->ends_at = Carbon::parse($data['canceled_at'], 'UTC');
        } elseif (isset($data['scheduled_change']) && $data['scheduled_change']['action'] === 'cancel') {
            $subscription->ends_at = Carbon::parse($data['scheduled_change']['effective_at'], 'UTC');
        } else {
            $subscription->ends_at = null;
        }

if we make it like this will be good?:

if (isset($data['canceled_at'])) {
            $subscription->ends_at = Carbon::parse($data['canceled_at'], 'UTC');
        } elseif (isset($data['scheduled_change']) && $data['scheduled_change']['action'] === 'cancel') {
            $subscription->ends_at = Carbon::parse($data['scheduled_change']['effective_at'], 'UTC');
        } else {
            $subscription->ends_at = Carbon::parse($data['current_billing_period']['ends_at'], 'UTC');
        }
crynobone commented 8 months ago

ends_at not being null and have future date indicate that the subscription under grace period for cancellation.