0
votes

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?

2

2 Answers

1
votes

I just came across your question here, and as Mollie employee I was able to find your test payments in our system. It turns out your SSL certificate is invalid. The error message says:

SSL: certificate subject name 'localhost' does not match target host name '[mysite]'

If you need more information you can always contact Mollie support. For technical questions an email generally works best.

0
votes

In your payment script, you only create a payment, but are you actually doing anything with the response and redirecting the user to the URL given (in _links.checkout) to actually start doing actual payment?

See https://docs.mollie.com/reference/v2/payments-api/create-payment for the reference to the API response and https://docs.mollie.com/payments/overview for an overview of the flow that used by the payment process!