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

Exception throw when calling Paddle\SDK\Entities\Event::from() with SubscriptionUpdated event #107

Open
tigerbook73 opened this issue Dec 5, 2024 · 1 comment

Comments

@tigerbook73
Copy link

Describe the bug

When try to build a SubscriptionUpdated Notification from Paddle\SDK\Entities\Event::from(data), exception thrown.

Reason:
In the subscription.updated event, the event.data.discount.started_at field may be null in a special scenario. This makes the invoking of Paddle\SDK\Entities\Event::from() failed.

Steps to reproduce

  1. create a subscription
  2. update the subscription with and discount start from next period
  3. cancel the subscription immediately
  4. an subscription.updated notification will be emitted. In this notfication, the subscription.discount.starts_at is null.
  5. when try to build Paddle\SDK\Notifications\Events\SubscriptionUpdated from this event by calling Paddle\SDK\Notifications\Events::from($data), exception thrown at Paddle\SDK\Notifications\Entities\Subscription\SubscriptionDiscount::from()
    Line: 29 DateTime::from($data['starts_at'])

"message": "Paddle\SDK\Notifications\Entities\DateTime::from(): Argument #1 ($date) must be of type DateTimeInterface|string, null given,

Expected behavior

SubscriptionUpdated object can be successfully constructed from Event::from(...) call.

Code snippets

No response

PHP version

PHP 8.1

SDK version

paddle-php-sdk 1.20.1

API version

Paddle verson 1

Additional context

No response

@davidgrayston-paddle
Copy link
Contributor

Hello @tigerbook73 👋 Thank you for raising this issue.

We'll make a fix for this in the next patch release, and will update this issue accordingly

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