petericebear/laravel-mollie

Laravel 5 wrapper for payment provider mollie

v3.0.0 2019-09-06 14:47 UTC

This package is auto-updated.

Last update: 2024-04-07 01:06:41 UTC


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.

Build Status StyleCI 68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7065746572696365626561722f6c61726176656c2d6d6f6c6c69652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572 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: