PHP code example of pixelpillow / lunar-api-mollie-adapter
1. Go to this page and download the library: Download pixelpillow/lunar-api-mollie-adapter library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
pixelpillow / lunar-api-mollie-adapter example snippets
return [
'default' => env('PAYMENTS_TYPE' , 'cash-in-hand' ),
'types' => [
'cash-in-hand' => [
'driver' => 'offline' ,
'authorized' => 'payment-offline' ,
],
'mollie' => [
'driver' => 'mollie' ,
'authorized' => 'payment-received' ,
],
],
];
namespace App \Mollie \Generators ;
use Dystcz \LunarApi \Domain \Carts \Models \Cart ;
use Pixelpillow \LunarApiMollieAdapter \Generators \RedirectOnSuccessUrlGenerator ;
class CustomRedirectOnSuccessUrlGenerator extends RedirectOnSuccessUrlGenerator
{
protected $cart;
public function __construct (Cart $cart)
{
$this ->cart = $cart;
}
public function generate () : string
{
$order = $this ->cart->orders()->first();
if (! $order) {
throw new \Exception ('Order not found' );
}
return 'https://example.com/checkout/success?order_id=' . $order->id;
}
}
namespace App \Mollie \Generators ;
use Dystcz \LunarApi \Domain \Carts \Models \Cart ;
use Lunar \Models \Order ;
use Pixelpillow \LunarApiMollieAdapter \Generators \RedirectOnSuccessUrlGenerator ;
class CustomRedirectOnFailureUrlGenerator extends RedirectOnSuccessUrlGenerator
{
protected $cart;
protected $order;
public function __construct (Cart $cart)
{
$this ->cart = $cart;
}
public function generate () : string
{
$order = $this ->cart->orders()->first();
if (! $order) {
throw new \Exception ('Order not found' );
}
return 'https://example.com/checkout/failure?order_id=' . $order->id;
}
}
bash
php artisan vendor:publish --tag="lunar-api-mollie-adapter-config"