Develop a custom Payum gateway

This chapter could be useful for a developer who wants to create a gateway on top of payum. The Payum provides a skeleton project which helps us a lots.

  1. Create new project

$ composer create-project payum/skeleton
  1. Replace all occurrences of payum with your vendor name. It may be your github name, for now let's say you choose: acme.

  2. Replace all occurrences of skeleton with a payment gateway name. For example Stripe, Paypal etc. For now let's say you choose: paypal.

  3. Register a gateway factory to the payum's builder and create a gateway:


use Payum\Core\PayumBuilder;

$defaultConfig = [];

$payum = (new PayumBuilder)
    ->addGatewayFactory('paypal', new \Acme\Paypal\PaypalGatewayFactory($defaultConfig))

    ->addGateway('paypal', [
        'factory' => 'paypal',
        'sandbox' => true,


Or, if your are working on the bases of Symfony, you can define it in a service that way :

        class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
        arguments: [Acme\Paypal\PaypalGatewayFactory]
            - { name: payum.gateway_factory_builder, factory: paypal }
  1. While using the gateway implement all method where you get Not implemented exception:


use Payum\Core\Request\Capture;

/** @var \Payum\Core\Payum $payum */
$paypal = $payum->getGateway('paypal');

$model = new \ArrayObject([
  // ...

$paypal->execute(new Capture($model));

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