PHPackages                             code16/laravel-systempay - 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. code16/laravel-systempay

ActiveLibrary[Payment Processing](/categories/payments)

code16/laravel-systempay
========================

Systempay (Banque Populaire) tools for Laravel

v1.0.0(1mo ago)013MITPHPPHP ^8.4CI passing

Since Jun 15Pushed 1mo agoCompare

[ Source](https://github.com/code16/laravel-systempay)[ Packagist](https://packagist.org/packages/code16/laravel-systempay)[ Docs](https://github.com/code16/laravel-systempay)[ RSS](/packages/code16-laravel-systempay/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (9)Versions (2)Used By (0)

Systempay tools for Laravel
===========================

[](#systempay-tools-for-laravel)

Features
--------

[](#features)

- Fast and easy form generation for Systempay (by Banque Populaire)
- Support multiple site id for multiple stores within the same project
- Validate payment signature and status

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

[](#installation)

1. Install the package

```
composer require code16/laravel-systempay

```

2. Publish the config file

```
php artisan vendor:publish --tag="systempay-config"

```

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

[](#configuration)

After publishing edit the default configuration file : [`config/systempay.php`](config/systempay.php)

```
return [
    'default' => [
        'site_id' => 'YOUR_SITE_ID',
        'key'     => env('SYSTEMPAY_SITE_KEY', 'YOUR_KEY'),
        'env'     => env('SYSTEMPAY_ENV', 'PRODUCTION'),
    ]
];
```

You need to set `YOUR_SITE_ID` and `YOUR_KEY` with your own values. This two values are given by Systempay.

### Specific parameters

[](#specific-parameters)

These parameters are set by default :

namedefault valuenotecurrency978[List of currency codes](https://www.iban.com/currency-codes)payment\_configSINGLESINGLE or MULTIPLEtrans\_date\[current datetime\]Generated automaticalypage\_actionPAYMENTaction\_modeINTERACTIVEversionV2signature\[generated\]Generated automaticalyAlso see [Systempay documentation](https://paiement.systempay.fr/doc/fr-FR/form-payment/quick-start-guide/envoyer-un-formulaire-de-paiement-en-post.html)

**NB** : you don't have to add the `vads_` prefix to parameters, the prefix will be automaticaly added. But you can also set the parameters with the `vads_` prefix, it will be automaticaly removed.

There is also possible to set some specific parameters to a configuration by setting `params` values.

Example :

```
return [
    'default' => [
        // ...
        'params'  => [
            'currency' => '826'
        ]
    ]
];
```

In this case, default configuration will use the currency code 826.

### Additional configuration

[](#additional-configuration)

You can add as many configuration as you need by adding a new key to the configuration file.

For example :

```
return [
    'default' => [
       // ...
    ],
    'store_uk' => [
        'site_id' => '123456',
        'key'     => env('SYSTEMPAY_UK_SITE_KEY', '12345678'),
        'env'     => env('SYSTEMPAY_UK_ENV', 'PRODUCTION'),
    ]
];
```

To use another configuration, call the `config` method, for example :

```
$systemPay = SystemPay::config('store_uk')->set([
    'amount' => 12.34,
    'trans_id' => 123456
]);
```

IPN Callback
------------

[](#ipn-callback)

When a payment is processed, Systempay sends a POST request to your IPN URL (to be configured in your Systempay back office).

You can use the `SystemPay` facade to validate the signature and check the payment status.

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use SystemPay;

class PaymentCallbackController extends Controller
{
    public function __invoke(Request $request)
    {
        // 1. Validate the signature
        if (! SystemPay::validateSignature($request)) {
            abort(403, 'Invalid signature');
        }

        // 2. Check if the payment is valid (status is ACCEPTED, CAPTURED, or AUTHORISED)
        if (! SystemPay::isValidPayment($request)) {
            // Payment refused or cancelled
            return response()->json(['status' => 'error']);
        }

        // 3. Retrieve order information
        [$orderId, $transId, $uuid] = SystemPay::retrieveOrderAndTransaction($request);

        // Update your database...

        return response()->json(['status' => 'ok']);
    }
}
```

### Signature validation for specific configuration

[](#signature-validation-for-specific-configuration)

If you have multiple configurations, pass the configuration name to `validateSignature`:

```
SystemPay::validateSignature($request, 'store_uk');
```

### Customize valid payment status

[](#customize-valid-payment-status)

By default, `isValidPayment` returns true if the status is `CAPTURED`, `ACCEPTED`, or `AUTHORISED`. You can customize this by passing an array of valid statuses as the second parameter:

```
SystemPay::isValidPayment($request, ['CAPTURED']);
```

Create a payment form
---------------------

[](#create-a-payment-form)

To create a payment form, you can use the `SystemPay` facade.

In your controller :

```
