descom / omnipay-redsys
Omnipay 的 Redsys 驱动程序
v1.4.0
2024-08-16 09:10 UTC
Requires
- php: ^8.2
- descom/redsys: ^1.7.6
- guzzlehttp/guzzle: ^7.4
- league/omnipay: ^3.2
- omnipay/common: ^3.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.10
- guzzlehttp/psr7: ^1|^2
- omnipay/tests: ^4.1
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5|^10.0|^10.5
This package is auto-updated.
Last update: 2024-09-16 11:08:43 UTC
README
Omnipay 的 Redsys 驱动程序
安装
composer require descom/omnipay-redsys
基本用法
创建购买请求
use Omnipay\Omnipay; $gateway = Omnipay::create('Redsys'); $gateway->initialize([ 'merchantCode' => '999008881', 'merchantTerminal' => '1', 'merchantSignatureKey' => 'sq7HjrUOBfKmC576ILgskD5srU870gJ7', 'testMode' => true, ]); $request = $gateway->purchase([ 'amount' => 12.50, 'description' => 'Test purchase', 'transactionId' => 1, 'notifyUrl' => 'https://:8080/gateway/notify', ])->send(); $response->redirect();
使用 Bizum 创建购买请求
use Omnipay\Omnipay; $gateway = Omnipay::create('Bizum'); $gateway->initialize([ 'merchantCode' => '999008881', 'merchantTerminal' => '1', 'merchantSignatureKey' => 'sq7HjrUOBfKmC576ILgskD5srU870gJ7', 'testMode' => true, 'merchantPaymethods' => 'z', ]); $request = $gateway->purchase([ 'amount' => 12.50, 'description' => 'Test purchase', 'transactionId' => 1, 'notifyUrl' => 'https://:8080/gateway/notify', ])->send(); $response->redirect();
完成购买请求
use Omnipay\Omnipay; $gateway = Omnipay::create('Redsys'); $gateway->initialize([ 'merchantCode' => '999008881', 'merchantTerminal' => '1', 'merchantSignatureKey' => 'sq7HjrUOBfKmC576ILgskD5srU870gJ7', 'testMode' => true, ]); $request = $this->gateway->completePurchase(); /* Redsys notification payment $_POST = [ 'Ds_SignatureVersion' => 'HMAC_SHA256_V1', 'Ds_MerchantParameters' => '...', 'Ds_Signature' => '...', ]; */ $redsysNotificationData = $_POST; $response = $request->sendData($redsysNotificationData); if ($response->isSuccessful()) { // $dsOrder = $response->transactionId(); // $dsAuthorizationCode = $response->transactionReference(); } else { // $dsResponse = $response->getCode(); }