How do I add a new payment gateway in v5?

We’re looking to add a gateway for Bambora, or develop one from the SDK if required.

I’ve looked at the steps here Configure — Invoice Ninja 4.5.37 documentation but I think these steps may be for v4. There is a new “key” field in the v5 gateway table.

Are the steps to add a gateway different for v5?


Here’s the info for v5:

Thanks hillel!

In the database migration file, I used:
$gateway = new Gateway;
$gateway->name = ‘Bambora’;
$gateway->key = Str::lower(Str::random(32));
$gateway->provider = ‘Bambora’;
$gateway->is_offsite = true;
$gateway->fields = new \stdClass;
$gateway->visible = true;
$gateway->site_url = ‘’;
$gateway->default_gateway_type_id = 1;

Then I ran

php artisan migrate

Migrating: 2021_07_04_062006_bambora


Class ‘Gateway’ not found

  at database/migrations/2021_07_04_062006_bambora.php:17
      13▕      */
      14▕     public function up()
      15▕     {
      16▕         // Add gateway record for Bambora
➜  17▕        $gateway = new Gateway;
      18▕        $gateway->name = 'Bambora'; 
      19▕        $gateway->key = Str::lower(Str::random(32)); 
      20▕        $gateway->provider = ‘Bambora’;
      21▕        $gateway->is_offsite = true;

• A class import is missing: You have a missing class import. Try importing this class: App\Models\Gateway.

So I added
use App\Models\Gateway;

Running migrate again and I got a little further:

Call to undefined method Dotenv\Util\Str::lower()
A class import is missing: You have a missing class import. Try importing this class: Dotenv\Util\Str

Success! Final code looked like this:


use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\Gateway;     // Added line
use Illuminate\Support\Str;    // Added line

class Bambora extends Migration
     * Run the migrations.
     * @return void
    public function up()
        // Add gateway record for Bambora
        $gateway = new Gateway;
        $gateway->name = 'Bambora'; 
        $gateway->key = Str::lower(Str::random(32)); 
        $gateway->provider = 'Bambora';
        $gateway->is_offsite = true;
        $gateway->fields = new \stdClass;
        $gateway->visible = true;
        $gateway->site_url = '';
        $gateway->default_gateway_type_id = 1;

     * Reverse the migrations.
     * @return void
    public function down()

Add the gateways table has a new row.

My gateway is not in the drop down list of Gateways, so I need to refresh the cache, yes?

The record added to gateways looks like this:

MariaDB [ninja]> select * from gateways where id=57\G
*************************** 1. row ***************************
                     id: 57
                   name: Bambora
                    key: s5wpcmio3zjchi5xk6kenohykdkvfpja
               provider: Bambora
                visible: 1
             sort_order: 7
             is_offsite: 0
              is_secure: 0
                 fields: "{\"merchantId\":\"\",\"apiPasscode\":\"\"}"

default_gateway_type_id: 1
             created_at: 2021-07-04 07:12:49.562302
             updated_at: 2021-07-04 07:12:49.562302

When I do Settings → Device Settings → Refresh, it fails with this error:

Error :: ‘[id, 57, name, Bambora, key, s5wpcmio3zjchi5xk6kenohykdkvfpja, provider, Bamb…’ to ‘minified:js’ failed due to: Deserializing ‘[]’ to ‘String’ failed due to: TypeError: Instance of ‘minified:Z’: type ‘minified:Z’ is not a subtype of type ‘String’

When I check the Gateway drop down list in the GUI, my new gateway is not there.

Why would the refresh fail after addeding the new record?

@david do you have any suggestions?

You need to clear and reload the cache.

You can do this by running /update?secret=

Then log and back in again and go to Settings > Device Settings > Refresh data

Your gateway should then appear


No luck with the /update?secret=
My new gateway does not appear in the list of gateways.

Am I supposed to append my key from the gateways table? I tried it with and without, but nothing.

It definitely worked once when things got all messed up.

When I do a grep -i bambora storage/framework/cache/data * -Rl on the files in the cache folder … it finds a match on this one file:

which was the messed up one. The files newer than this don’t have my bambora gateway in it.

Can I just remove the row from the gateways table and start the add process again?


Try updating the updated_at timestamp on the row of the gateways table you added.

I just retested this and this flow worked for me.

Log out
Device Settings > Refresh Data