So I'm trying to make fake test payments for a school project, using Mollie. The payments, and the redirect after the payments, work just fine but the Webhook.php just doesn't seem to be called. This is what's going on in the payment script:
$payment = $mollie->payments->create([
"amount" => [
"currency" => "EUR",
"value" => "7.50"
],
"description" => "Ad Highlight",
"redirectUrl" => "https://[mysite]/redirect.php [working]",
"webhookUrl" => "https://[mysite]/webhook.php"]);
This is what the webhook looks like:
$servername = "localhost";
$username = "[workingusername]";
$password = "[workingpassword]";
$dbname = "[workingDB]";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO test (te)
VALUES ('TEST')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
require_once("mollie/vendor/autoload.php");
require_once("mollie/examples/functions.php");
$mollie = new \Mollie\Api\MollieApiClient();
$mollie->setApiKey("[validkey]");
$payment = $mollie->payments->get($_POST["id"]);
$orderId = $payment->metadata->order_id;
/*
* Update the order in the database.
*/
database_write($orderId, $payment->status);
if ($payment->isPaid() && !$payment->hasRefunds() && !$payment->hasChargebacks()) {
/*
* The payment is paid and isn't refunded or charged back.
* At this point you'd probably want to start the process of delivering the product to the customer.
*/
}
As you can see I made a test query just to check if the webhook is doing anything. When I open my browser and go straight to the webhook.php file. It actually executes the query and I can see it in the database. Therefore I concluded that that the Webhook file is ok, but for some reason Mollie doesn't call it after making a payment.
I also can't find any error log or whatsoever. The site is controlled by Directadmin, which does have an error log, but no useful info there either.
Anybody got any ideas?