定制 code16/laravel-systempay 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

code16/laravel-systempay

Composer 安装命令:

composer require code16/laravel-systempay

包简介

Systempay (Banque Populaire) tools for Laravel

README 文档

README

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

  1. Install the package
composer require code16/laravel-systempay
  1. Publish the config file
php artisan vendor:publish --tag="systempay-config"

Configuration

After publishing edit the default configuration file : 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

These parameters are set by default :

name default value note
currency 978 List of currency codes
payment_config SINGLE SINGLE or MULTIPLE
trans_date [current datetime] Generated automaticaly
page_action PAYMENT
action_mode INTERACTIVE
version V2
signature [generated] Generated automaticaly

Also see Systempay documentation

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

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

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

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

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

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

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

In your controller :

<?php namespace App\Http\Controllers;

use SystemPay; // Facade

class PaymentController extends Controller
{
    public function create()
    {
        $systemPay = SystemPay::set([
            'amount' => 12.34,
            'trans_id' => 123456
        ]);
        
        return view('payment', compact('systemPay'));
    }
}

In your view

<x-systempay::form :config="$systemPay">
    <x-slot:button>
        <button type="submit" class="btn btn-primary">
            Pay
        </button>
    </x-slot:button>
</x-systempay::form>

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-15