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');
/* Start to develop here. Best regards https://php-download.com/ */
pixelpillow / lunar-api-mollie-adapter example snippets
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;
}
}
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;
}
}