laravel / cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

Home Page:https://laravel.com/docs/cashier-paddle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

majdiyassin20 opened this issue · comments

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');
       }

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