mollie / laravel-cashier-mollie

Official Mollie integration for Laravel Cashier
https://www.cashiermollie.com/
MIT License
137 stars 44 forks source link

Undefined property: stdClass::$actions at /vendor/mollie/laravel-cashier-mollie/src/FirstPayment/FirstPaymentHandler.php:103 #202

Closed handhikadj closed 11 months ago

handhikadj commented 1 year ago

I'm getting this issue using v2.9.0 on the log this happens right after/some seconds after the recurring payment runs (Cashier::run();) especially the recurring payments of SEPA payments

Naoray commented 1 year ago

Hi @handhikadj,

could you parse the whole error log please?

sandervanhooft commented 1 year ago

Closing this for now, let me know if it should be reopened.

jivanrij commented 1 year ago

@sandervanhooft can you open this ticket?

I'm also having this issue, with 2.9.0 and 2.10.0.

I'm currently looking for the reason when stumbling on this ticket. I've tracked it down to FirstPaymentHandler::extractActions()

Screenshot 2023-10-08 at 15 12 59 Screenshot 2023-10-08 at 15 13 05

When my user gets a redirect to Mollie (test mode) (first payment), and then clicks on one of the banks, my application gets the following error:

Undefined property: stdClass::$actions {"exception":"[object] (ErrorException(code: 0): Undefined property: stdClass::$actions at /home/forge/app.mingleminded.nl/vendor/mollie/laravel-cashier-mollie/src/FirstPayment/FirstPaymentHandler.php:103)

Then when I click on success and get redirected back to the app, I see the following error:

Integrity constraint violation: 1048 Column 'owner_type' cannot be null (Connection: mysql, SQL: insert into `order_items` (`owner_id`, `owner_type`, `process_at`, `currency`, `unit_price`, `quantity`, `tax_percentage`, `description`, `orderable_id`, `orderable_type`, `updated_at`, `created_at`) values (2, ?, 2023-10-09 16:00:17, EUR, 75, 1, 0.0000, One day Subscription, 1, Laravel\Cashier\Subscription, 2023-10-08 16:00:17, 2023-10-08 16:00:17)) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'owner_type' cannot be null (Connection: mysql, SQL: insert into `order_items` (`owner_id`, `owner_type`, `process_at`, `currency`, `unit_price`, `quantity`, `tax_percentage`, `description`, `orderable_id`, `orderable_type`, `updated_at`, `created_at`) values (2, ?, 2023-10-09 16:00:17, EUR, 75, 1, 0.0000, One day Subscription, 1, Laravel\\Cashier\\Subscription, 2023-10-08 16:00:17, 2023-10-08 16:00:17)) at /home/forge/app.mingleminded.nl/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760)

I'm working on a new application, last week (with version 2.9.0) I didn't have this issue. Somewhere It appeared. I've rolled back the code and tested older versions but it keeps appearing.

I need to leave the office now, I'll continue looking for the issue tomorrow.

jivanrij commented 1 year ago

One update, not a solution though. But perhaps an answer for @handhikadj.

When \Laravel\Cashier\FirstPayment\FirstPaymentHandler::extractActions() is called metadata doesn't exist if the code runs due to a Mollie callback for a Payment that is removed from the database because of testing, debugging, migrate:fresh or stuff like that. That's an explanation for the "Undefined property: stdClass::$actions" message.

In my case, the Subscription model is still not created. But I guess that's an other issue/ticket. I'll create one for it.

sandervanhooft commented 1 year ago

One update, not a solution though. But perhaps an answer for @handhikadj.

When \Laravel\Cashier\FirstPayment\FirstPaymentHandler::extractActions() is called metadata doesn't exist if the code runs due to a Mollie callback for a Payment that is removed from the database because of testing, debugging, migrate:fresh or stuff like that. That's an explanation for the "Undefined property: stdClass::$actions" message.

In my case, the Subscription model is still not created. But I guess that's an other issue/ticket. I'll create one for it.

Thanks for diving in deeper here. That reads like a plausible explanation. I'll keep this ticket open for us to investigate. Perhaps we can also raise a better Exception here.

Naoray commented 1 year ago

One update, not a solution though. But perhaps an answer for @handhikadj.

When \Laravel\Cashier\FirstPayment\FirstPaymentHandler::extractActions() is called metadata doesn't exist if the code runs due to a Mollie callback for a Payment that is removed from the database because of testing, debugging, migrate:fresh or stuff like that. That's an explanation for the "Undefined property: stdClass::$actions" message.

In my case, the Subscription model is still not created. But I guess that's an other issue/ticket. I'll create one for it.

Good point @jivanrij. So the error only popped up in your local env?!

Naoray commented 11 months ago

Will close this for now. If anyone can offer more details to this please let me know!