1. Go to this page and download the library: Download cloudstek/mollie-php-api 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/ */
cloudstek / mollie-php-api example snippets
// Import the namespace
use Mollie\API\Mollie;
// Create an API client instance
$mollie = new Mollie('test_yourapikeyhere');
// Alternatively..
$mollie = new Mollie();
$mollie->setApiKey('test_yourapikeyhere');
// Now you're ready to use the Mollie API, please read on for more examples.
use Mollie\API\Mollie;
// Initialize API client
$mollie = new Mollie('test_yourapikeyhere');
// Create customer
$customer = $mollie->customer()->create('John Doe', '[email protected]');
// Alternatively you can also specify a locale and/or metadata.
// In the following example we'll create the same customer with some metadata
$customer = $mollie->customer()->create(
'John Doe',
'[email protected]',
array(
'user_id' => 11,
'group' => 'regular_customers'
)
);
// Now save the customer ID to your database for future reference. Pseudo code:
$db->save($customer->id);
use Mollie\API\Mollie;
// Initialize API client
$mollie = new Mollie('test_yourapikeyhere');
// Create new payment
$payment = $mollie->payment()->create(
10.00,
'Expensive cup of coffee',
'https://example.org/order/101'
);
// Redirect user to payment page
$payment->gotoPaymentPage();
use Mollie\API\Mollie;
// Initialize API client
$mollie = new Mollie('test_yourapikeyhere');
// Create new payment
$payment = $mollie->customer('cst_test')->payment()->create(
10.00,
'Expensive cup of coffee',
'https://example.org/order/101'
);
// Redirect user to payment page
$payment->gotoPaymentPage();
exit; // Do redirect immediately
use Mollie\API\Mollie;
// Initialize API client
$mollie = new Mollie('test_yourapikeyhere');
// Get customer
$customer = $mollie->customer('cst_test')->get();
// Make sure the customer has no valid mandates
if(!$customer->mandate()->hasValid()) {
// Create mandate by issueing the first recurring payment.
// This is usually a small amount like a few cents as it's only used to confirm
// the payment details.
$customer->mandate()->createFirstRecurring(
0.01,
'Recurring payment mandate confirmation',
'https://example.org/account'
);
}
use Mollie\API\Mollie;
// Initialize API client
$mollie = new Mollie('test_yourapikeyhere');
// Get customer
$customer = $mollie->customer('cst_test')->get();
// Check if customer has a valid mandate for recurring payments
if($customer->mandate()->hasValid()) {
$customer->payment()->createRecurring(10.00, 'Expensive cup of coffee');
}
else {
// Customer has no valid mandates, you should get one first.
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.