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

Closed
tigerbook73 opened this issue Dec 5, 2024 · 6 comments

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

@N-M
Copy link
Contributor

N-M commented Dec 12, 2024

I have encountered a similar issue. Here is the full log.

{"message":"Uncaught PHP Exception TypeError: \"Paddle\\SDK\\Entities\\DateTime::from(): Argument #1 ($date) must be of type DateTimeInterface|string, null given, called in /var/www/****/backend/vendor/paddlehq/paddle-php-sdk/src/Entities/Subscription/SubscriptionDiscount.php on line 29\" at DateTime.php line 22","context":{"exception":{"class":"TypeError","message":"Paddle\\SDK\\Entities\\DateTime::from(): Argument #1 ($date) must be of type DateTimeInterface|string, null given, called in /var/www/*****/backend/vendor/paddlehq/paddle-php-sdk/src/Entities/Subscription/SubscriptionDiscount.php on line 29","code":0,"file":"/var/www/******/backend/vendor/paddlehq/paddle-php-sdk/src/Entities/DateTime.php:22"}},"level":500,"level_name":"CRITICAL","channel":"request","datetime":"2024-12-12T16:37:32.333854+00:00","extra":{}}

@davidgrayston-paddle
Copy link
Contributor

Hello 👋

This issue has now been fixed in release v1.7.1

@N-M
Copy link
Contributor

N-M commented Dec 13, 2024

Hi, We have encountered another issue after the update. Below is exception from the log.

{"message":"Uncaught PHP Exception TypeError: \"Paddle\\SDK\\Entities\\DateTime::from(): Argument #1 ($date) must be of type DateTimeInterface|string, null given, called in /var/www/******//backend/vendor/paddlehq/paddle-php-sdk/src/Entities/Subscription/SubscriptionDiscount.php on line 29\" at DateTime.php line 22","context":{"exception":{"class":"TypeError","message":"Paddle\\SDK\\Entities\\DateTime::from(): Argument #1 ($date) must be of type DateTimeInterface|string, null given, called in /var/www/******//backend/vendor/paddlehq/paddle-php-sdk/src/Entities/Subscription/SubscriptionDiscount.php on line 29","code":0,"file":"/var/www/******/backend/vendor/paddlehq/paddle-php-sdk/src/Entities/DateTime.php:22"}},"level":500,"level_name":"CRITICAL","channel":"request","datetime":"2024-12-13T10:16:33.615639+00:00","extra":{}}

@davidgrayston-paddle
Copy link
Contributor

Hello @N-M

With the fix released in v1.7.1 this error should no longer be possible. Please can you confirm that you are using version v1.7.1?

@N-M
Copy link
Contributor

N-M commented Dec 13, 2024

Hi @davidgrayston-paddle, sorry for the false alarm. An environment that I checked was not updated.

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

3 participants