Store gateway config in database

Payum allows you store gateway configuration and credentials in your database. Later you may provide a backoffice so the admin can modify gateway through it. Payum Laravel Package contains Eloquent GatewayConfig model, which we are going to reuse in this example.

The database schema could be generated like this

<?php

Schema::create('payum_gateway_configs', function($table) {
    /** @var \Illuminate\Database\Schema\Blueprint $table */
    $table->bigIncrements('id');
    $table->text('config');
    $table->string('factoryName');
    $table->string('gatewayName');
    $table->timestamps();
});

The gateway config storage should be registered like this:

// bootstrap/start.php

use Payum\LaravelPackage\Storage\EloquentStorage;
use Payum\LaravelPackage\Model\GatewayConfig;

App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
    $payumBuilder
        ->setGatewayConfigStorage(new EloquentStorage(GatewayConfig::class))
    ;
});

Supporting Payum

Payum is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:

Last updated