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->setToken("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");
use Mollie\Api\Http\Data\Money;
use Mollie\Api\Http\Requests\CreatePaymentRequest;
use Mollie\Api\Types\PaymentStatus;
$payment = $mollie->send(new CreatePaymentRequest(
description: 'My first API payment',
amount: new Money(currency: 'EUR', value: '10.00'),
redirectUrl: 'https://webshop.example.org/order/12345/',
webhookUrl: 'https://webshop.example.org/mollie-webhook/'
));
if ($payment->status === PaymentStatus::Paid) {
echo "Paid {$payment->amount->value} {$payment->amount->currency}";
}
use Mollie\Api\Fake\MockResponse;
use Mollie\Api\Http\Data\Money;
use Mollie\Api\Http\Requests\GetPaymentRequest;
use Mollie\Api\MollieApiClient;
use Mollie\Api\Types\PaymentStatus;
$client = MollieApiClient::fake([
GetPaymentRequest::class => MockResponse::payment(
id: 'tr_xxx',
status: PaymentStatus::Paid,
amount: new Money(currency: 'EUR', value: '10.00'),
),
]);
$payment = $client->send(new GetPaymentRequest('tr_xxx'));
$client->assertSent(GetPaymentRequest::class);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.