Skip to content

Laravel 5.x wrapper for integrating Mollie as a payment provider.

License

Notifications You must be signed in to change notification settings

petericebear/laravel-mollie

Repository files navigation

Mollie API wrapper for Laravel 5.x

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.

Build Status StyleCI Code Coverage Software License Total Downloads Latest Version

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: