PHP code example of avaibooksports / redsys-messages
1. Go to this page and download the library: Download avaibooksports/redsys-messages library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
avaibooksports / redsys-messages example snippets
use AvaiBookSports\Component\RedsysMessages;
$redsysMessages = new RedsysMessages\Factory(new RedsysMessages\Loader\CatalogLoader());
// Returns "Expired card"
$redsysMessages->createCatalogByLanguage('en')->getDsResponseMessage('0101');
// You can load catalogs by ISO 639-1 and ISO 639-2
$redsysMessages->createCatalogByLanguage('eng')->getDsResponseMessage('0101');
// There is a different library for error messages. Those error codes can be provided by Redsys in two different formats:
$redsysMessages->createCatalogByLanguage('en')->getErrorMessage('9002'));
$redsysMessages->createCatalogByLanguage('en')->getErrorMessage('SIS0002')); // Alias of '9002'
// src/Redsys/Messages/Italian.php
namespace App\Redsys\Messages;
use AvaiBookSports\Component\RedsysMessages\CatalogInterface;
class English implements CatalogInterface
{
/**
* @var string[]
*/
private $dsResponseMessages = [
'0101' => 'Carta scaduta',
// ...
];
/**
* {@inheritdoc}
*/
public static function getIso639Alpha2()
{
return 'it';
}
/**
* {@inheritdoc}
*/
public static function getIso639Alpha3()
{
return 'ita';
}
/**
* {@inheritdoc}
*/
public function getDsResponseMessage($code)
{
if (array_key_exists($code, $this->dsResponseMessages)) {
return $this->dsResponseMessages[$code];
}
return null;
}
}
use AvaiBookSports\Component\RedsysMessages;
$redsysMessages = new RedsysMessages\Factory(
new RedsysMessages\Loader\ArrayLoader([
\App\Redsys\Messages\Italian::class,
// ...
])
);
// "Carta scaduta"
$redsysMessages->createCatalogByLanguage('it')->getDsResponseMessage('0101');
use AvaiBookSports\Component\RedsysMessages;
$redsysMessages = new RedsysMessages\Factory(
new RedsysMessages\ChainLoader([
new RedsysMessages\Loader\CatalogLoader(),
new RedsysMessages\Loader\ArrayLoader([
\App\Redsys\Messages\Italian::class,
// ...
])
new App\Redsys\Loader\MyCustomLoader(), // Maybe you want to implement your own loader?
])
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.