Closed PatricGithub closed 10 months ago
Can you check your laravel.log
file? It probably contains the error message.
`[2023-10-14 09:33:32] local.ERROR: Cannot use object of type stdClass as array {"exception":"[object] (Error(code: 0): Cannot use object of type stdClass as array at /home/vito/hallopsychologe.de/app/Http/Controllers/ThankYouController.php:158) [stacktrace]
`
@Psychology4me the payment is an object and not an array. I guess the data in the payload
variable is an object instead of an array. Can you verify this?
I can confirm this was indeed the mistake. Here is the final code for future references:
public function handleWebhookNotification(Request $request) {
$paymentId = $request->input('id');
$payment = Mollie::api()->payments->get($paymentId);
$metadata = $payment->metadata;
$rechnungsnummer = $metadata->rechnungsnummer;
if ($payment->isPaid()) {
DB::table('appointments')
->where('rechnungsnummer', '=', $rechnungsnummer)
->update(['paid' => 'paid']);
} else{
}
Maybe provide additional examples in your example section for "coders new to mollie and laravel". (like me) I had to switch from svelte to laravel to make mollie work :) Anyhow, thank you for the great tip with the logs!
I'm happy that I could help you. Feel free to ask any questions if you need help @Psychology4me.
My function results in Verbindung zum Webhook ist mit Status-Code 500 ist fehlgeschlagen (Internal Server Error). the original lines of code worked, however this one not. I would be happy for a helping hand.