Skip to content
On this page

Payments

TIP

If you're looking for a guide on how to create your own Payment Driver, or for a more in-depth look at how they work, head over to the extending section.

Overview

Lunar takes a driver based approach with Payments, meaning you are free to use either add ons to support the provider you wish to use, or you can create your own to meet your exact needs.

Configuration

All configuration for payments is located in config/lunar/payments.php. Here you can specify different types of payments and the driver each one should use.

php
<?php

return [
    'default' => env('PAYMENTS_TYPE', 'offline'),

    'types' => [
        'cash-in-hand' => [
            'driver' => 'offline',
            'released' => 'payment-offline',
        ],
        'card' => [
            'driver' => 'stripe',
            'released' => 'payment-received',
        ],
    ],
];

Usage

To use a payment driver, you need to pass the type of payment you wish to use, this will then return an instance of the driver.

php
$driver = \Lunar\Facades\Payments::driver('card');

We can then set the cart.

php
$driver->cart(\Lunar\Models\Cart $cart);

Set any additional data that the driver may need.

php
$driver->setData([
    'payment_token' => $token,
]);

Finally, we can authorize the payment.

php
$driver->authorize();