0

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.

  • Count your columns (3), placeholders (4), and variables in your bind_param (4 types, 3 variables). – aynber Jan 07 '20 at 13:26
  • You're right. I kept changing the location of where to insert the date hoping that would perhaps solve my problem. I fixed this but I still have the same problem. Thanks for the attention to it – William Bruijntjes Jan 07 '20 at 13:30
  • MySQL does not return errors the same way PHP does. You need to explicitly check for [mysqli errors](http://php.net/manual/en/mysqli.error.php) – aynber Jan 07 '20 at 13:31
  • Problem is that I cannot display my webhook page because it gets it's POST information from mollie. – William Bruijntjes Jan 07 '20 at 13:36
  • You can always log the information to a file you define, or use [error_log](https://www.php.net/manual/en/function.error-log.php) – aynber Jan 07 '20 at 13:38
  • If i did it corretly, the myqli_error() function does not output anything. This must mean the problem is not in my mysql I suppose. This does not surprise very much because if I write the information from a different file than the webhook it DOES work. – William Bruijntjes Jan 07 '20 at 13:42
  • There might be an error in your SQL syntax –  Jan 13 '20 at 10:54

0 Answers0