itemvirtual / ecommerce-redsys
Redsys payments with Laravel
1.1.0
2023-01-18 14:57 UTC
Requires
- php: ^7.4|^8.0
- sermepa/sermepa: ^1.3
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
Redsys payments with Laravel
Installation
You can install the package via composer:
composer require itemvirtual/ecommerce-redsys
Publish config (with --force
option to update)
php artisan vendor:publish --provider="Itemvirtual\EcommerceRedsys\EcommerceRedsysServiceProvider" --tag=config
Add this environment variable to your .env
ECOMMERCE_REDSYS_ENVIRONMENT=test # or live ECOMMERCE_REDSYS_KEY="sq7HjrUOBfKmC576ILgskD5srU870gJ7" ECOMMERCE_REDSYS_CODE="999008881" ECOMMERCE_REDSYS_TERMINAL=1 ECOMMERCE_REDSYS_CURRENCY=978 ECOMMERCE_REDSYS_LANGUAGE="001" ECOMMERCE_REDSYS_NOTIFICATION_URL="${APP_URL}/redsys-notification-url" ECOMMERCE_REDSYS_URL_OK="${APP_URL}/redsys-ok-url" ECOMMERCE_REDSYS_URL_KO="${APP_URL}/redsys-ko-url" ECOMMERCE_REDSYS_TRADE_NAME="${APP_NAME}" ECOMMERCE_REDSYS_TITULAR="Your company name"
Add your ECOMMERCE_REDSYS_NOTIFICATION_URL
to your app/Http/Middleware/VerifyCsrfToken
middleware
protected $except = [ 'redsys-notification-url' ];
Usage
To create the redsys payment form
use Itemvirtual\EcommerceRedsys\EcommerceRedsys; $EcommerceRedsys = new EcommerceRedsys(); $redsysForm = $EcommerceRedsys->setAmount(100) ->setMerchantData('YourMerchantData') ->setDescription('Purchase title') ->setSubmitButtonTitle('Pay button text') ->createForm();
Available methods
$EcommerceRedsys = new EcommerceRedsys(); $params = $EcommerceRedsys->setAmount(100) ->setOrder(time()) ->setMerchantData('YourMerchantData') ->setDescription('Purchase title') ->setMerchantcode('Your Custom Data') ->setCurrency(999) ->setLanguage('Your Custom Data') ->setTransactiontype('Your Custom Data') ->setTerminal(1) ->setMethod('Your Custom Data') ->setNotificationUrl('Your Custom Data') ->setUrlOk('Your Custom Data') ->setUrlKo('Your Custom Data') ->setTradeName('Your Custom Data') ->setTitular('Your Custom Data') ->setEnvironment('test') ->setSubmitButtonName('Your Custom Button title') ->setSubmitButtonTitle('Your Custom Button title') ->setSubmitButtonId('Your Custom Button title') ->setSubmitButtonClass('Your Custom Button title') ->debugParameters();
To get redsys response
use Itemvirtual\EcommerceRedsys\EcommerceRedsys; $EcommerceRedsys = new EcommerceRedsys(); $parameters = $EcommerceRedsys->getMerchantParameters($request->get('Ds_MerchantParameters')); $yourMerchantData = $EcommerceRedsys->getMerchantData($request->get('Ds_MerchantParameters')); // validate payment $isValid = $EcommerceRedsys->checkValidPayment($request->all());
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.