Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
majdiyassin20 opened this issue Dec 24, 2023 · 1 comment
Closed

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

majdiyassin20 opened this issue Dec 24, 2023 · 1 comment

Comments

@majdiyassin20
Copy link
Contributor

majdiyassin20 commented Dec 24, 2023

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants