Write Mollie payment to database via webhook

448 views Asked by At

I'm trying to retrieve a mollie payment by it's payment id in my custom webhook via:

$payment = $mollie->payments->get($_POST["id"]);

To test it(because i can't var_dump a webhook) I write the payment ID to a request.log file. This DOES write the correct payment id to the log file:

$fp = file_put_contents('request.log', $payment->id );

Afterwards I write this payment ID and some other data to the database via:

$conn = $GLOBALS['database']->dbconnect(); $webshopQuery = "INSERT INTO orders (userID, paymentID, paymentDateTime) VALUES (?,?,?)"; $stmt = $conn->prepare($webshopQuery); $stmt->bind_param("iss", $userID, $paymentID, $paymentDate); $stmt->execute();

(I get the parameter variables from the functions parameters. I didn't insert this function in the snippet because it doesnt have much to do with it)

This does NOT write anything to my database.

When I run the same piece of code on my mollie redirect file it DOES write to the database.

I'm very confused as to why it is not working. What am I doing wrong? And is there any way to debug the query on the webhook page?


EDIT(I've ran it down to a simpler problem):

I have a webhook that gets a paymentID from a Mollie payment API.

$payment = $mollie->payments->get($_POST["id"]);

file_put_contents('request.log', $payment->id);

$Webshop_Service->service_savePayment($loggedInUser->userID, "testID");

The function service_savePayment is tested and works. Only it does not get called while the file_put_contents('request.log', $payment->id); DOES write the mollie $payment->id to a text file.

0

There are 0 answers