mollie/laravel-mollie

Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite


README

259760257-5fce72ed-3fee-4645-b29a-18d97407fcfd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTA5NDAyNjIsIm5iZiI6MTcxMDkzOTk2MiwicGF0aCI6Ii83MjY1NzAzLzI1OTc2MDI1Ny01ZmNlNzJlZC0zZmVlLTQ2NDUtYjI5YS0xOGQ5NzQwN2ZjZmQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDMyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDAzMjBUMTMwNjAyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGFkNzBkMWY1MzkzMjQ3ZWI3NTQyMjc5OGQ1MmQ5NjU4ZjRkZDczYmQ1M2JjNWIxN2FmMmI4YTdiMmFhZDc5YSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.NHaGqr0G7deMYYoyENl3nk_cqbWjZllXiHZfbUm_ofA

Mollie for Laravel

create new payment

Laravel-Mollie incorporates the Mollie API and Mollie Connect into your Laravel or Lumen project.

Accepting iDEAL, Apple Pay, Bancontact/Mister Cash, SOFORT Banking, Creditcard, SEPA Bank transfer, SEPA Direct debit, PayPal, Belfius Direct Net, KBC/CBC, paysafecard, ING Home'Pay, Giftcards, Giropay, EPS and Przelewy24 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.

Looking for a complete recurring billing solution? Take a look at Laravel Cashier for Mollie instead.

Build Status Latest Stable Version Total Downloads

Requirements

  • Get yourself a free Mollie account. No sign up costs.
  • Now you're ready to use the Mollie API client in test mode.
  • Follow a few steps to enable payment methods in live mode, and let us handle the rest.
  • Up-to-date OpenSSL (or other SSL/TLS toolkit)
  • PHP >= 8.1
  • Laravel >= 10.0
  • Laravel Socialite >= 5.0 (if you intend on using Mollie Connect)

Upgrading from v2.x?

To support the enhanced Mollie API, some breaking changes were introduced. Make sure to follow the instructions in the upgrade guide.

Fresh install? Continue with the installation guide below.

Installation

Add Laravel-Mollie to your composer file via the composer require command:

composer require mollie/laravel-mollie

Or add it to composer.json manually:

"require": {
    "mollie/laravel-mollie": "^3.0"
}

Laravel-Mollie's service providers will be automatically registered using Laravel's auto-discovery feature.

Configuration

You'll only need to add the MOLLIE_KEY variable to your .env file.

MOLLIE_KEY=test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Example usage

Here you can see an example of just how simple this package is to use.

A payment using the Mollie API

use Mollie\Laravel\Facades\Mollie;

public function preparePayment()
{
    $payment = Mollie::api()->payments->create([
        "amount" => [
            "currency" => "EUR",
            "value" => "10.00" // You must send the correct number of decimals, thus we enforce the use of strings
        ],
        "description" => "Order #12345",
        "redirectUrl" => route('order.success'),
        "webhookUrl" => route('webhooks.mollie'),
        "metadata" => [
            "order_id" => "12345",
        ],
    ]);

    // redirect customer to Mollie checkout page
    return redirect($payment->getCheckoutUrl(), 303);
}

/**
 * After the customer has completed the transaction,
 * you can fetch, check and process the payment.
 * This logic typically goes into the controller handling the inbound webhook request.
 * See the webhook docs in /docs and on mollie.com for more information.
 */
public function handleWebhookNotification(Request $request) {
    $paymentId = $request->input('id');
    $payment = Mollie::api()->payments->get($paymentId);

    if ($payment->isPaid())
    {
        echo 'Payment received.';
        // Do your thing ...
    }
}

Other examples

Want to help us make our Laravel module even better?

Want to help us make our Laravel module even better? We take pull requests, sure. But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers. Check out our vacancies or get in touch.

License

The MIT License. Copyright (c) 2024, Mollie B.V.

Support

Contact: www.mollie.cominfo@mollie.com