PHPackages                             karser/payum-saferpay - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. karser/payum-saferpay

ActiveLibrary[Payment Processing](/categories/payments)

karser/payum-saferpay
=====================

Saferpay Payum plugin providing Ecommerce and Business features

v0.5.0(3y ago)533.6k↓42.9%3[3 PRs](https://github.com/karser/PayumSaferpay/pulls)1MITPHPPHP ^7.3 || ^8.0

Since May 22Pushed 2y ago2 watchersCompare

[ Source](https://github.com/karser/PayumSaferpay)[ Packagist](https://packagist.org/packages/karser/payum-saferpay)[ RSS](/packages/karser-payum-saferpay/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (5)Versions (11)Used By (1)

Saferpay Payum Plugin
=====================

[](#saferpay-payum-plugin)

[![Build Status](https://github.com/karser/PayumSaferpay/workflows/Code_Checks/badge.svg)](https://github.com/karser/PayumSaferpay/actions)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0b964aae7758cab3ef7e47a2777c2113b0b4ccea9497568348c5548b574daa9a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b61727365722f506179756d53616665727061792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/karser/PayumSaferpay/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/072a7af59d88eb37d451e75e58efdc093191f860d49dadf64c7dc05eff465c8d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b61727365722f506179756d53616665727061792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/karser/PayumSaferpay/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/96310c6825e1837f121e4c1f336d0ef8765d92040cc554fe12b56688bb6829b2/68747470733a2f2f706f7365722e707567782e6f72672f6b61727365722f706179756d2d73616665727061792f646f776e6c6f616473)](https://packagist.org/packages/karser/payum-saferpay)

Introduction
------------

[](#introduction)

This plugin implements [Saferpay specification v1.10](https://docs.saferpay.com/home/integration-guide/introduction), including all features from e-commerce and business licenses. Saferpay e-commerce license provides access to Payment Page interface only. Saferpay Business license provides Transaction Interface, [recurring payments](https://docs.saferpay.com/home/integration-guide/licences-and-interfaces/transaction-interface/recurring-payments#3.-recurring-transaction), storing cards aliases and etc. For more detailed comparison please refer to [Licensing options](https://docs.saferpay.com/home/integration-guide/licences-and-interfaces#supported-api-methods-per-license) and [Supported payment methods per interface](https://docs.saferpay.com/home/integration-guide/licences-and-interfaces#supported-payment-methods-per-interface).

Transaction Interface provides two options: an iframe (similar to Payment Page) and submitting the card data directly. The last option is available only if you are PCI compliant.

Here is how Payment Page interface looks like: [![](docs/payment-page-interface.png)](docs/payment-page-interface.png)

Here is how Transaction interface looks like: [![](docs/transaction-interface.png)](docs/transaction-interface.png)

Requirements
------------

[](#requirements)

- PHP 7.3+
- [Payum](https://github.com/Payum/Payum)
- Optionally [PayumBundle](https://github.com/Payum/PayumBundle) and Symfony 3 or 4+

Features
--------

[](#features)

This plugin supports

- [Payment Page interface](https://docs.saferpay.com/home/integration-guide/licences-and-interfaces/payment-page)
- [Transaction interface](https://docs.saferpay.com/home/integration-guide/licences-and-interfaces/transaction-interface)
- Recurring Payments [with the referenced transactions Method](https://docs.saferpay.com/home/integration-guide/licences-and-interfaces/transaction-interface/recurring-payments#recurring-payments-with-the-referenced-transactions-method)
- Recurring Payments [using an alias](https://docs.saferpay.com/home/integration-guide/licences-and-interfaces/transaction-interface/recurring-payments#recurring-payments-using-an-alias)
- Aliases support: Add and remove, Capture transaction
- Specifying LIABILITY\_SHIFT condition (payment will not be accepted if LiabilityShift is not possible)
- Handling payment notification for Payment Page interface

All features are covered with tests. You can find useful examples in functional tests.

Installation
------------

[](#installation)

```
$ composer require karser/payum-saferpay
```

Configuration
-------------

[](#configuration)

### With PayumBundle (Symfony)

[](#with-payumbundle-symfony)

First register the gateway factory in your services definition:

```
# config/services.yaml or app/config/services.yml
services:
    app.saferpay.gateway_factory:
        class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
        arguments: [Karser\PayumSaferpay\SaferpayGatewayFactory]
        tags:
            - { name: payum.gateway_factory_builder, factory: saferpay }
```

Then configure the gateway:

You can use `General test account` credentials or create personal test account [here](https://www.six-payment-services.com/en/site/e-commerce/support/testaccount.html)

```
# config/packages/payum.yaml or app/config/config.yml

payum:
    gateways:
        saferpay:
            factory: saferpay
            # this is test credentials
            username: 'API_401860_80003225'
            password: 'C-y*bv8346Ze5-T8'
            customerId: '401860'
            terminalId: '17795278'
            interface: 'TRANSACTION' #optionally, can be defined via details too
            optionalParameters: #optionally, add some additional interface options, read more below in section "Additional Configuration"
                styling_css_url: 'https://acme.com/hosted-page-styles.css'
            sandbox: true
```

### With Payum

[](#with-payum)

```
//config.php

use Payum\Core\GatewayFactoryInterface;
use Payum\Core\PayumBuilder;
use Payum\Core\Payum;
use Karser\PayumSaferpay\SaferpayGatewayFactory;

/** @var Payum $payum */
$payum = (new PayumBuilder())
    ->addDefaultStorages()
    ->addGatewayFactory('saferpay', static function(array $config, GatewayFactoryInterface $coreGatewayFactory) {
        return new SaferpayGatewayFactory($config, $coreGatewayFactory);
    })
    ->addGateway('saferpay', [
        'factory' => 'saferpay',
        # this is test credentials
        'username' => 'API_401860_80003225',
        'password' => 'C-y*bv8346Ze5-T8',
        'customerId' => '401860',
        'terminalId' => '17795278',
        'interface' => 'TRANSACTION', #optionally, can be defined via details too
        'sandbox' => true,
    ])
    ->getPayum()
;
```

### Configure the routes

[](#configure-the-routes)

You can include the default Payum Bundle's routes, although only these routes are actually required by this plugin:

```
#config/routes.yaml
payum_capture_do:
    path: /payment/capture/{payum_token}
    controller: PayumBundle:Capture:do

#notification route is required only if you use payment page interface
#payum_notify_do:
#    path: /payment/notify/{payum_token}
#    controller: PayumBundle:Notify:do
```

Usage
-----

[](#usage)

### Capture example

[](#capture-example)

Make sure you defined `Payment` and `Token` entities like it is described [here](https://github.com/Payum/Payum/blob/master/docs/storages.md)

```
//capture.php

use App\Entity\Payment;
use Payum\Core\Payum;
use Payum\Core\Request\Capture;
use Karser\PayumSaferpay\Constants;

/** @var Payum $payum */
$storage = $payum->getStorage(Payment::class);
$payment = $storage->create();
$payment->setNumber(uniqid());
$payment->setCurrencyCode('USD');
$payment->setTotalAmount(123); //$1.23 USD
$payment->setDescription('test payment');

// capture using TRANSACTION interface (default)
$payment->setDetails(['Interface' => Constants::INTERFACE_TRANSACTION]);
// or capture using PAYMENT_PAGE interface
$payment->setDetails(['Interface' => Constants::INTERFACE_PAYMENT_PAGE]);

$storage->update($payment);

$token = $payum->getTokenFactory()->createCaptureToken('saferpay', $payment, 'done.php');

$captureRequest = new Capture($token);
$captureRequest->setModel($payment);
$reply = $this->gateway->execute($captureRequest, true);

//then redirect user to $reply->getUrl();
```

```
//done.php

use App\Entity\Payment;
use Payum\Core\Payum;
use Payum\Core\Request\GetHumanStatus;

/** @var Payum $payum */
$token = $payum->getHttpRequestVerifier()->verify($_GET);
$this->payum->getHttpRequestVerifier()->invalidate($token);

$payment = $payum->getStorage(Payment::class)->find($token);

$this->assertStatus(GetHumanStatus::STATUS_CAPTURED, $payment);

$this->gateway->execute($status = new GetHumanStatus($payment));

//status of the payment is in $status->getValue()
```

### Recurring Payments with the referenced transactions Method

[](#recurring-payments-with-the-referenced-transactions-method)

1. Capture payment with Recurring or Installment option:

```
use Karser\PayumSaferpay\Constants;

$payment = $storage->create();

$payment->setDetails(['Payment' => ['Recurring' => ['Initial' => true]]]);
//or
$payment->setDetails(['Payment' => ['Installment' => ['Initial' => true]]]);

//then capture the payment
$captureRequest = new Capture($token);
$captureRequest->setModel($payment);
$reply = $this->gateway->execute($captureRequest, true);
//then redirect user to $reply->getUrl();
```

2. Capture a new transaction by providing a reference to the previous one:

```
$refTransactionId = $payment->getDetails()['Transaction']['Id'];

$payment = $storage->create();

$payment->setDetails([
    'TransactionReference' => [
        'TransactionId' =>  $refTransactionId,
    ]
]);

//then capture the payment
$captureRequest = new Capture($token);
$captureRequest->setModel($payment);
$this->gateway->execute($captureRequest);
```

### Recurring Payments using an alias

[](#recurring-payments-using-an-alias)

1. Obtaining the Alias: The user will have to enter their card details in an iframe.

```
use Karser\PayumSaferpay\Constants;
use Karser\PayumSaferpay\Model\CardAlias;

$cardAliasStorage = $this->payum->getStorage(CardAlias::class);
$alias = $cardAliasStorage->create();
$alias->setDetails([
    'Alias' => [
        'IdGenerator' => Constants::ALIAS_ID_GENERATOR_MANUAL,
        'Id' => $generatedId = uniqid('id', true),
        'Lifetime' => 1600, //days
    ]
]);
$this->cardAliasStorage->update($alias);
$token = $this->payum->getTokenFactory()->createCaptureToken(self::GATEWAY_NAME, $cardAlias, 'done.php');

$insertCardAliasRequest = new InsertCardAlias($token);
$insertCardAliasRequest->setModel($cardAlias);
$reply = $this->gateway->execute($insertCardAliasRequest, true);
//then redirect user to $reply->getUrl();
```

2. Capture a new transaction by providing an alias id:

```
$aliasId = $cardAlias->getDetails()['Alias']['Id'];

$payment = $storage->create();

$payment->setDetails([
    'PaymentMeans' => [
        'Alias' => [
            'Id' => $aliasId,
        ],
    ],
]);

//then capture the payment
$captureRequest = new Capture($token);
$captureRequest->setModel($payment);
$this->gateway->execute($captureRequest);
```

### Change Payload Locale

[](#change-payload-locale)

1. Create a custom extension (If you're using the symfony bundle):

```
AppBundle\Extension\ConvertPaymentExtension:
    autowire: true
    public: true
    tags:
        - { name: payum.extension, alias: saferpay_locale_extension, factory: saferpay, gateway: saferpay, prepend: false }
```

2. Create service:

```
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Extension\Context;
use Payum\Core\Extension\ExtensionInterface;
use Payum\Core\Request\Convert;

class ConvertPaymentExtension implements ExtensionInterface
{
    public function onPostExecute(Context $context)
    {
        $action = $context->getAction();
        $previousActionClassName = get_class($action);

        if (false === stripos($previousActionClassName, 'ConvertPaymentAction')) {
            return;
        }

        /** @var Convert $request */
        $request = $context->getRequest();
        if (false === $request instanceof Convert) {
            return;
        }

        // do your locale logic here
        $customLocale = 'de';

        $result = ArrayObject::ensureArrayObject($request->getResult());

        $payerData = [];
        if (isset($result['Payer']) && is_array($result['Payer'])) {
            $payerData = $result['Payer'];
        }

        $payerData['LanguageCode'] = $customLocale;

        $result['Payer'] = $payerData;

        $request->setResult((array) $result);
    }
}
```

### Additional Configuration

[](#additional-configuration)

Depending on given interface, there are several optional options available.

Example:

```
payum:
    gateways:
        saferpay:
            optionalParameters:
                styling_css_url: 'https://acme.com/hosted-page-styles.css'
```

#### Payment Page interface

[](#payment-page-interface)

KeyDescription`config_set`This parameter let you define your payment page config (PPConfig) by name. If this parameters is not set, your default PPConfig will be applied if available. When the PPConfig can't be found (e.g. wrong name), the Saferpay basic style will be applied to the payment page.`payment_methods`Used to restrict the means of payment which are available to the payer for this transaction. If only one payment method id is set, the payment selection step will be skipped.`wallets`Used to control if wallets should be enabled on the payment selection page and to go directly to the given wallet (if exactly one wallet is filled and PaymentMethods is not set).`notification_merchant_email`Email addresses to which a confirmation email will be sent to the merchants after successful authorizations.`notification_payer_email`Email address to which a confirmation email will be sent to the payer after successful authorizations.`styling_css_url`Deprecated`styling_content_security_enabled`When enabled, then ContentSecurity/SAQ-A is requested, which leads to the CSS being loaded from the saferpay server.`styling_theme`This parameter let you customize the appearance of the displayed payment pages. Per default a lightweight responsive styling will be applied.If you don't want any styling use 'NONE'.`payer_note`Text which will be printed on payer's debit note. Supported by SIX Acquiring. No guarantee that it will show up on the payer's debit note, because his bank has to support it too. Please note that maximum allowed characters are rarely supported. It's usually around 10-12.#### Transaction interface

[](#transaction-interface)

KeyDescription`config_set`This parameter let you define your payment page config (PPConfig) by name. If this parameters is not set, your default PPConfig will be applied if available. When the PPConfig can't be found (e.g. wrong name), the Saferpay basic style will be applied to the payment page.`payment_methods`Used to restrict the means of payment which are available to the payer for this transaction. If only one payment method id is set, the payment selection step will be skipped.`styling_css_url`Deprecated`styling_content_security_enabled`When enabled, then ContentSecurity/SAQ-A is requested, which leads to the CSS being loaded from the saferpay server.`styling_theme`This parameter let you customize the appearance of the displayed payment pages. Per default a lightweight responsive styling will be applied. If you don't want any styling use 'NONE'.`payer_note`Text which will be printed on payer's debit note. Supported by SIX Acquiring. No guarantee that it will show up on the payer's debit note, because his bank has to support it too. Please note that maximum allowed characters are rarely supported. It's usually around 10-12.Testing
-------

[](#testing)

```
composer update
vendor/bin/phpunit

```

ToDo
----

[](#todo)

- Implement separate actions: Authorize, Cancel transaction
- Improve and add more unit tests
- config parameters: LIABILITY\_SHIFT condition

Credits
-------

[](#credits)

- Dmitrii Poddubnyi

License
-------

[](#license)

This plugin is under the MIT license. For the whole copyright, see the [LICENSE](LICENSE) file distributed with this source code.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 64.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~153 days

Recently: every ~211 days

Total

10

Last Release

1170d ago

PHP version history (3 changes)v0.1.0PHP ^7.2.0

v0.3.3PHP ^7.2 || ^8.0

v0.4.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a010cb48160a17e197994687462680101cdb20284a1dce61f8704218a7ee87e4?d=identicon)[karser](/maintainers/karser)

---

Top Contributors

[![solverat](https://avatars.githubusercontent.com/u/700119?v=4)](https://github.com/solverat "solverat (29 commits)")[![karser](https://avatars.githubusercontent.com/u/1675033?v=4)](https://github.com/karser "karser (8 commits)")[![Chris8934](https://avatars.githubusercontent.com/u/44963939?v=4)](https://github.com/Chris8934 "Chris8934 (6 commits)")[![alexdpunkt](https://avatars.githubusercontent.com/u/3079024?v=4)](https://github.com/alexdpunkt "alexdpunkt (1 commits)")[![Chris53897](https://avatars.githubusercontent.com/u/7104259?v=4)](https://github.com/Chris53897 "Chris53897 (1 commits)")

---

Tags

gatewaypaymentpayment-gatewaypayment-pagepayumpayum-extensionpayum-gatewaysaferpaysaferpay-payum-pluginpaymentecommercepayumipninstant payment notificationrecurring paymentsaferpaysix-payment

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/karser-payum-saferpay/health.svg)

```
[![Health](https://phpackages.com/badges/karser-payum-saferpay/health.svg)](https://phpackages.com/packages/karser-payum-saferpay)
```

###  Alternatives

[payum/payum

One million downloads of Payum already! Payum offers everything you need to work with payments. Friendly for all PHP frameworks (Symfony, Laravel, Laminas, Yii, Silex). Check more visiting site.

1.9k6.6M21](/packages/payum-payum)[payum/payum-bundle

One million downloads of Payum already! Payum offers everything you need to work with payments. Check more visiting site.

59510.3M40](/packages/payum-payum-bundle)[payum/payum-module

Rich payment solutions for zend framework2. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more

2014.0k](/packages/payum-payum-module)[payum/paypal-express-checkout-nvp

The Payum extension. It provides Paypal ExpressCheckout payment integration.

501.7M4](/packages/payum-paypal-express-checkout-nvp)[flux-se/payum-stripe

Payum Stripe gateways

29407.5k4](/packages/flux-se-payum-stripe)[crevillo/payum-redsys

Redsys gateway

1648.0k1](/packages/crevillo-payum-redsys)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
