PHP code example of funnydevjsc / cryptomus-laravel-integrate

1. Go to this page and download the library: Download funnydevjsc/cryptomus-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/ */

    

funnydevjsc / cryptomus-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...
         'cryptomus' => 'App\Http\Middleware\CryptomusMiddleware',
    ];
}



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

// Other routes properties...

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

}
bash
php artisan vendor:publish --provider="FunnyDev\Cryptomus\CryptomusServiceProvider" --tag="cryptomus"
 php


namespace App\Console\Commands;

use FunnyDev\Cryptomus\CryptomusSdk;
use Illuminate\Console\Command;

class CryptomusTestCommand extends Command
{
    protected $signature = 'cryptomus:test';

    protected $description = 'Test Cryptomus SDK';

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

    public function handle()
    {
        $instance = new CryptomusSdk();
        echo $instance->create_payment(
            'INV-test-01',
            100,
            'USDT',
            'BSC',
            'INV-test-01',
            'https://yourdomain.ltd/invoices/INV-test-01',
            'https://yourdomain.ltd/invoices/INV-test-01',
            'https://yourdomain.ltd/invoices/INV-test-01?success=true' // Remember that param success=true or any similar is just for toast notification, do not put any logical process here
        );
    }
}