1. Go to this page and download the library: Download mollie/mollie-api-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mollie / mollie-api-php example snippets
$mollie = new \Mollie\Api\MollieApiClient();
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");
$order = $mollie->orders->get('ord_8wmqcHMN4U');
$refund = $order->refundAll();
echo 'Refund ' . $refund->id . ' was created for order ' . $order->id;
$order = $mollie->orders->get('ord_8wmqcHMN4U');
$refund = $order->refund([
'lines' => [
[
'id' => 'odl_dgtxyl',
'quantity' => 1,
],
],
"description" => "Required quantity not in stock, refunding one photo book.",
]);
$order = $mollie->orders->get("ord_pbjz8x");
if ($order->isCancelable) {
$canceledOrder = $order->cancel();
echo "Your order " . $order->id . " has been canceled.";
} else {
echo "Unable to cancel your order " . $order->id . ".";
}
$payment = $mollie->payments->create([
"amount" => [
"currency" => "EUR",
"value" => "10.00"
],
"description" => "My first API payment",
"redirectUrl" => "https://webshop.example.org/order/12345/",
"webhookUrl" => "https://webshop.example.org/mollie-webhook/",
]);