Accepting iDEAL, Mister Cash, SOFORT Banking, Creditcard, SEPA Bank transfer, Bitcoin, PayPal, and paysafecard online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.
To use the Mollie API client, the following things are required:
- Get yourself a free Mollie account. No sign up costs.
- Create a new Website profile to generate API keys (live and test mode) and setup your webhook.
- Now you're ready to use the Mollie API client in test mode.
- In order to accept payments in live mode, payment methods must be activated in your account. Follow a few of steps, and let us handle the rest.
- Mollie API client requires PHP >= 5.2.
By far the easiest way to install the Mollie API client is to require it with Composer.
$ composer require mollie/mollie-api-php 1.1.x
{
"require": {
"mollie/mollie-api-php": "1.1.x"
}
}
You may also git checkout or download all the files, and include the Mollie API client manually.
To successfully receive a payment, these steps should be implemented:
-
Use the Mollie API client to create a payment with the requested amount, description and optionally, a payment method. It is important to specify a unique redirect URL where the customer is supposed to return to after the payment is completed.
-
Immediately after the payment is completed, our platform will send an asynchronous request to the configured webhook to allow the payment details to be retrieved, so you know when exactly to start processing the customer's order.
-
The customer returns, and should be satisfied to see that the order was paid and is now being processed.
Requiring the included autoloader. If you're using Composer, you can skip this step.
require "Mollie/API/Autoloader.php";
Initializing the Mollie API client, and setting your API key.
$mollie = new Mollie_API_Client;
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");
Creating a new payment.
$payment = $mollie->payments->create(array(
"amount" => 10.00,
"description" => "My first API payment",
"redirectUrl" => "https://webshop.example.org/order/12345/",
));
After creation, the payment id is available in the $payment->id
property. You should store this id with your order.
Retrieving a payment.
$payment = $mollie->payments->get($payment->id);
if ($payment->isPaid())
{
echo "Payment received.";
}
If you want to fully integrate iDEAL payments in your web site, some additional steps are required. First, you need to retrieve the list of issuers (banks) that support iDEAL and have your customer pick the issuer he/she wants to use for the payment.
Retrieve the list of issuers:
$issuers = $mollie->issuers->all();
$issuers
will be a list of Mollie_API_Object_Issuer
objects. Use the property $id
of this object in the
API call, and the property $name
for displaying the issuer to your customer. For a more in-depth example, see Example 4.
Create a payment with the selected issuer:
$payment = $mollie->payments->create(array(
"amount" => 10.00,
"description" => "My first API payment",
"redirectUrl" => "https://webshop.example.org/order/12345/",
"method" => Mollie_API_Object_Method::IDEAL,
"issuer" => $selected_issuer_id, // e.g. "ideal_INGBNL2A"
));
The links
property of the $payment
object will contain a string paymentUrl
, which is a URL that points directly to the online banking environment of the selected issuer.
The API also supports refunding payments. Note that there is no confirmation and that all refunds are immediate and definitive. Refunds are only supported for iDEAL, credit card and Bank Transfer payments. Other types of payments cannot be refunded through our API at the moment.
$payment = $mollie->payments->get($payment->id);
$refund = $mollie->payments->refund($payment);
If you wish to learn more about our API, please visit the Mollie Developer Portal. API Documentation is available in both Dutch and English.
BSD (Berkeley Software Distribution) License. Copyright (c) 2013, Mollie B.V.
Contact: www.mollie.nl — [email protected] — +31 20-612 88 55
- More information about iDEAL via Mollie
- More information about credit card via Mollie
- More information about Mister Cash / Bancontact via Mollie
- More information about SOFORT Banking via Mollie
- More information about SEPA Bank transfer via Mollie
- More information about Bitcoin via Mollie
- More information about PayPal via Mollie
- More information about paysafecard via Mollie