descom / redsys
A PHP package to platform Redsys
Installs: 2 117
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: ^8.2
- php-http/discovery: ^1.17
- psr/http-client-implementation: *
- psr/http-factory-implementation: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4
- illuminate/http: ^11.20
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^9.3
- symfony/http-client: ^7.0
README
A PHP package to platform Redsys
Install
Via Composer
composer require descom/redsys
Usage
Generate Redirect From to payment
use Descom\Redsys\Redsys; $redsys = Redsys::sandbox([ 'code' => 999008881, 'terminal' => 1, 'signatureKey' => 'sq7HjrUOBfKmC576ILgskD5srU870gJ7', ]); $orderId = '123456'; $amount = 12.05; echo $redsys ->redirect() ->generateRedirectPayment($orderId, $amount, 'http://localhost:8000') // ->description('description about the order products') optional DS_MERCHANT_PRODUCTDESCRIPTION // ->merchantName('rename merchant name') optional DS_MERCHANT_MERCHANTNAME // ->data('internal data, to read in response') optional DS_MERCHANT_MERCHANTDATA // ->merchantPaymethods('z') // optional payment with Bizum ->redirect();
Capture payment notification
use Descom\Redsys\Redsys; $redsys = Redsys::sandbox([ 'code' => 999008881, 'terminal' => 1, 'signatureKey' => 'sq7HjrUOBfKmC576ILgskD5srU870gJ7', ]); $response = $redsys->redirect()->capturePaymentNotification($_POST); if (! $response->successful()) { $orderId = $response->orderId; $errorCode = $response->errorCode; $responseCode = $response->responseCode; // $responseData = $response->toArray(); throw new \Exception("Error processing payment [$orderId] [$errorCode]", $responseCode); } $orderId = $response->orderId; $authorizationCode = $response->authorizationCode; $amount = $response->amount; //
Testing
composer test