PHP code example of ttrig / laravel-billmate

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

    

ttrig / laravel-billmate example snippets


'accept_action' => 'App\Http\Controllers\BillmateController@accept',
'cancel_action' => 'App\Http\Controllers\BillmateController@cancel',
'callback_action' => \Ttrig\Billmate\Controllers\CallbackController::class,

use Ttrig\Billmate\Article as BillmateArticle;
use Ttrig\Billmate\Service as BillmateService;

class CheckoutController extends Controller
{
    public function index(BillmateService $billmate)
    {
        $articles = collect()->push(new BillmateArticle([
            'title' => '1kg potatoes',
            'price' => 30,
        ]));

        $checkout = $billmate->initCheckout($articles);

        return view('checkout', compact('checkout'));
    }
}

$billmate->initCheckout($articles, function (&$data) {
    data_set($data, 'PaymentData.autoactivate', '1');
});

use Ttrig\Billmate\Order as BillmateOrder;
use Ttrig\Billmate\Service as BillmateService;

class YourRedirectController extends Controller
{
    public function accept(BillmateService $billmate)
    {
        $order = new BillmateOrder(request()->data);

        $paymentInfo = $billmate->getPaymentInfo($order);

        return view('payment.accept');
    }

    public function cancel()
    {
        return view('payment.cancel');
    }
}

protected $listen = [
    \Ttrig\Billmate\Events\OrderCreated::class => [
        \App\Listeners\DoSomething::class,
    ],
];
shell
php artisan vendor:publish --provider="Ttrig\Billmate\ServiceProvider"