petericebear / laravel-mollie
Laravel 5 wrapper for payment provider mollie
Installs: 1 883
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- illuminate/support: 5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0
- mollie/mollie-api-php: ~1.0
Requires (Dev)
- php: >=5.5.9
- graham-campbell/testbench: ~3.0
- illuminate/contracts: 5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^4.8|^5.0
- scrutinizer/ocular: ~1.1
README
This is a package to integrate Mollie with Laravel 5.x. You can use it to easily manage your configuration, and use the Facade to provide shortcuts to the Mollie Client.
Requirements
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.
- PHP >= 5.2 although Laravel itself requires a higher PHP version
- PHP cURL extension
- Up-to-date OpenSSL (or other SSL/TLS toolkit)
- SSL v3 disabled. Mollie does not support SSL v3 anymore.
Installation
Via Composer
$ composer require petericebear/laravel-mollie
After updating composer, add the MollieServiceProvider to the providers array in config/app.php
PeterIcebear\Mollie\Providers\MollieServiceProvider::class,
You need to publish the config for this package. A sample configuration is provided. The defaults will be merged with gateway specific configuration.
$ php artisan vendor:publish --provider="PeterIcebear\Mollie\Providers\MollieServiceProvider"
To use the Facade (\Mollie::getMethods()
instead of App::make('mollie')->getMethods()
), add that to the facades array.
'Mollie' => PeterIcebear\Mollie\Facades\Mollie::class,
Usage of the wrapper
Creating a new payment.
$payment = Mollie::getPayments()->create([ "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::getPayments()->get($payment->id); if ($payment->isPaid()) { echo "Payment received."; }
Fully integrated iDEAL payments
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::getIssuers()->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.
Create a payment with the selected issuer:
$payment = Mollie::getPayments()->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.
Refunding payments
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, Bancontact/Mister Cash, SOFORT Banking and bank transfer payments. Other types of payments cannot be refunded through our API at the moment.
$payment = Mollie::getPayments()->get($payment->id); // Refund € 15 of this payment $refund = Mollie::getPayments()->refund($payment, 15.00);
More information
Please use the official documentation of Mollie of one off the following resources: