This package is designed to seamlessly integrate Mollie payments into your Lunar storefront. By leveraging the Lunar API, this adapter makes it easy to accept and manage payments through Mollie, a popular payment service provider.
Whether you're running an e-commerce platform or a subscription service, this adapter will help you handle payments efficiently and securely. With easy installation and configuration, you can have Mollie payments up and running on your Lunar storefront in no time.
Please follow the installation and configuration instructions in the Installation section to get started.
This package depends on the following packages:
- Multiple payment methods, including iDEAL, credit card, PayPal, Apple Pay, and more
- Expose Payment methods in the API
- Expose Payment issuers for ideal payments in the API
- Install this package via composer:
composer require pixelpillow/lunar-api-mollie-adapter
- Publish the config file:
php artisan vendor:publish --tag="lunar-api-mollie-adapter-config"
- Add your Mollie API key (You can obtain your API key by signing up on the Mollie website.) to the
.env
file:
MOLLIE_API_KEY=your-api-key
- Add the Mollie payment type to the
config/lunar/payments.php
file:
<?php
return [
'default' => env('PAYMENTS_TYPE', 'cash-in-hand'),
'types' => [
'cash-in-hand' => [
'driver' => 'offline',
'authorized' => 'payment-offline',
],
// Add the Mollie payment type here:
'mollie' => [
'driver' => 'mollie',
'authorized' => 'payment-received',
],
],
];
- Manage the redirect on success in your own
RedirectOnSuccessUrlGenerator
by defining your own generator in theconfig/lunar-api-mollie-adapter.php
file:
<?php
namespace App\Mollie\Generators;
use Dystcz\LunarApi\Domain\Carts\Models\Cart;
use Pixelpillow\LunarApiMollieAdapter\Generators\RedirectOnSuccessUrlGenerator;
class CustomRedirectOnSuccessUrlGenerator extends RedirectOnSuccessUrlGenerator
{
/**
* @var Cart
*/
protected $cart;
public function __construct(Cart $cart)
{
$this->cart = $cart;
}
/**
* Generate the webhook URL.
*/
public function generate(): string
{
$order = $this->cart->orders()->first();
if (! $order) {
throw new \Exception('Order not found');
}
// Return your own redirect URL here
return 'https://example.com/checkout/success?order_id=' . $order->id;
}
}
- Manage the redirect on failure in your the
RedirectOnFailureUrlGenerator
by defining your own generator in theconfig/lunar-api-mollie-adapter.php
file:
<?php
namespace App\Mollie\Generators;
use Dystcz\LunarApi\Domain\Carts\Models\Cart;
use Lunar\Models\Order;
use Pixelpillow\LunarApiMollieAdapter\Generators\RedirectOnSuccessUrlGenerator;
class CustomRedirectOnFailureUrlGenerator extends RedirectOnSuccessUrlGenerator
{
/**
* @var Cart
*/
protected $cart;
/**
* @var Order
*/
protected $order;
public function __construct(Cart $cart)
{
$this->cart = $cart;
}
/**
* Generate the webhook URL.
*/
public function generate(): string
{
$order = $this->cart->orders()->first();
if (! $order) {
throw new \Exception('Order not found');
}
// Return your own redirect URL here
return 'https://example.com/checkout/failure?order_id=' . $order->id;
}
}
The create-payment-intent url is a signed url can be found in the response of the POST /api/v1/carts/{cart}/-actions/checkout request.
POST api/v1/orders/{order}/-actions/create-payment-intent
{
"data": {
"type": "orders",
"id": 1,
"attributes": {
"payment_method": "mollie",
"meta": {
"payment_method_type": "ideal",
"payment_method_issuer": "ideal_ABNANL2A"
}
}
}
}
The create-payment-intent url is a signed url can be found in the response of the POST /api/v1/carts/{cart}/-actions/checkout request.
POST api/v1/orders/{order}/-actions/create-payment-intent
{
"data": {
"type": "orders",
"id": 1,
"attributes": {
"payment_method": "mollie",
"meta": {
"payment_method_type": "bancontact"
}
}
}
}
This package extends the Lunar API with the following endpoints:
Returns a list of enabled payment methods in the Mollie dashboard. The results are not paginated. See the Mollie API documentation for more information.
Example response:
{
"jsonapi": {
"version": "1.0"
},
"data": [
{
"type": "payment-methods",
"id": "ideal",
"attributes": {
"name": "iDEAL",
"method_id": "ideal",
"image": [
"https://www.mollie.com/external/icons/payment-methods/ideal.png",
"https://www.mollie.com/external/icons/payment-methods/ideal%402x.png",
"https://www.mollie.com/external/icons/payment-methods/ideal.svg"
]
},
"links": {
"self": "https://api.monoz.test/api/v1/payment-methods/ideal"
}
}
]
}
Returns a list of available payment issuers for ideal payments, including the issuer ID, issuer name and more. See the Mollie API documentation for more information.
Example response:
{
"jsonapi": {
"version": "1.0"
},
"data": [
{
"type": "payment-issuers",
"id": "ideal_ABNANL2A",
"attributes": {
"resource": "issuer",
"name": "ABN AMRO",
"issuer_id": "ideal_ABNANL2A",
"image": [
"https://www.mollie.com/external/icons/ideal-issuers/ABNANL2A.png",
"https://www.mollie.com/external/icons/ideal-issuers/ABNANL2A%402x.png",
"https://www.mollie.com/external/icons/ideal-issuers/ABNANL2A.svg"
]
},
"links": {
"self": "https://api.monoz.test/api/v1/payment-issuers/ideal_ABNANL2A"
}
}
]
}
If you discover any security related issues, please email security[at]pixelpillow.nl instead of using the issue tracker.
- All Contributors
- Lunar for providing awesome e-commerce package.
- Dystcz for creating the Lunar API package.
- Laravel JSON:API which is a brilliant JSON:API layer for Laravel applications
- Mollie for providing a great payment service.
The MIT License (MIT). Please see License File for more information.