Laravel package for working with Billmate API

v1.2.0 2021-01-14 18:53 UTC

This package is auto-updated.

Last update: 2022-05-14 21:41:32 UTC


Build Status Codecov Packagist Version License

Laravel Billmate

Laravel package for interacting with Billmate API.


composer require ttrig/laravel-billmate


Publish the configuration file using this command:

php artisan vendor:publish --provider="Ttrig\Billmate\ServiceProvider"

Add a Billmate ID and key in .env.


Update config/billmate.php to use your own controller(s).

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

General payment flow

Usage example


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'));

You can view or update the data to be sent to Billmate by passing a callback as second argument to initCheckout.

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


To render the Billmate Checkout iframe you can use $checkout->iframe() in your blade template or write your own iframe and pass $checkout->url to its src attribute.


To update height of the Checkout when it updates, we need this JavaScript.

window.addEventListener('message', function (event) {
    if (event.origin !== '') {

    try {
        var json = JSON.parse(
    } catch (e) {

    if (json.event === 'content_height') {

Redirect controller

You need your own controller(s) for handling the accept and cancel redirections.

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');

Callback controller

If you use Ttrig\Billmate\Controllers\CallbackController::class as your "callback_action" in config/billmate.php, you need to listen to the Ttrig\Billmate\Events\OrderCreated event in your EventServiceProvider to handle the order.

protected $listen = [
    \Ttrig\Billmate\Events\OrderCreated::class => [

Read more about events at


Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b amazing-feature)
  3. Commit your Changes (git commit -m 'Add some amazing feature)
  4. Push to the Branch (git push origin amazing-feature)
  5. Open a Pull Request


laravel-billmate is open-sourced software licensed under the MIT license.