PHP code example of minic / lunar-hosted-payment

1. Go to this page and download the library: Download minic/lunar-hosted-payment 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/ */

    

minic / lunar-hosted-payment example snippets


'providers' => [
    Minic\LunarHostedPayment\HostedPaymentServiceProvider::class,
];

return [
    'default' => env('PAYMENT_PROVIDER', 'stripe'),
    'providers' => [
        'stripe' => [
            'driver_class' => Minic\LunarHostedPayment\Drivers\StripeDriver::class,
            'secret_key' => env('STRIPE_SECRET_KEY'),
            'public_key' => env('STRIPE_PUBLIC_KEY'),
        ]
    ]
];



return [

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

    'types' => [
        'offline' => [
            'driver' => 'offline',
            'authorized' => 'payment-offline',
        ],
        'hosted-payment' => [
            'driver' => 'hosted-payment',
            'authorized' => 'payment-received',
        ],
    ],

];

$response = Lunar\Facades\Payments::driver('hosted-payment')->cart($cart)->withData([
    'successUrl' => $successUrl,
    'cancelUrl' => $cancelUrl,
    'paymentOption' => 'hosted-payment',
    'orderId' => $order->id,
])->initiatePayment();

return redirect($response['redirectUrl']);

Lunar\Facades\Payments::driver('hosted-payment')->cart($cart)->withData(
    ['sessionId' => $transaction->reference]
)->authorize();