PHP code example of vitegroupltd / vitepay-laravel-integrate

1. Go to this page and download the library: Download vitegroupltd/vitepay-laravel-integrate 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/ */

    

vitegroupltd / vitepay-laravel-integrate example snippets




namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    // Other kernel properties...
    
    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $routeMiddleware = [
        // Other middlewares...
         'vitepay' => 'App\Http\Middleware\VitePayMiddleware',
    ];
}



use Illuminate\Support\Facades\Route;
use App\Http\Controllers\VitePayController;

// Other routes properties...

Route::group(['middleware' => ['vitepay']], function () {
    Route::post('/vitepay/webhook', [VitePayController::class, 'webhook']);
});

}
bash
php artisan vendor:publish --provider="ViteGroup\VitePay\VitePayServiceProvider" --tag="vitepay"
 php


namespace App\Console\Commands;

use GuzzleHttp\Exception\GuzzleException;
use ViteGroup\VitePay\VitePayTransactions;
use Illuminate\Console\Command;

class VitePayTestCommand extends Command
{
    protected $signature = 'vitepay:test';

    protected $description = 'Test VitePay SDK';

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * @throws GuzzleException
     */
    public function handle()
    {
        $instance = new VitePayTransactions();
        print_r($instance->create(
            'INV-test-01',
            '',
            100000,
            'Description-test-01'
        ));
    }
}