1. Go to this page and download the library: Download ligrila/redsys 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/ */
ligrila / redsys example snippets
use Ligrila\Payment\Redsys;
use Ligrila\Payment\RedsysConfig;
use Ligrila\Payment\RedsysOrder;
$checkoutUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$responseUrl = dirname($checkoutUrl).'/response.php';
$successUrl = dirname($checkoutUrl).'/success.php';
$errorUrl = dirname($checkoutUrl).'/error.php';
$config = new RedsysConfig(
array(
'debug' => true,
'autoRedirect' => false,
'checkoutLoading' => 'Click on checkout button',
'checkoutText' => 'Checkout',
'Ds_Merchant_MerchantCode' => '111111111',
'Ds_Merchant_Terminal' => '2',
'Ds_Merchant_Password' => 'password',
'Ds_Merchant_MerchantURL' => $responseUrl,
'Ds_Merchant_UrlOK' => $successUrl,
'Ds_Merchant_UrlKO' => $errorUrl,
)
);
$order = new RedsysOrder();
$order->setAmount(100)
->setCurrency('GBP') // ISO 4217 Code
->setProductDescription('product1');
$redsys = new Redsys($config);
$html = $redsys->checkout($order);
echo $html;
use Ligrila\Payment\Redsys;
use Ligrila\Payment\RedsysConfig;
$config = new RedsysConfig(
array(
'debug' => true,
'autoRedirect' => false,
'checkoutLoading' => 'Click on checkout button',
'checkoutText' => 'Checkout',
'Ds_Merchant_MerchantCode' => '111111',
'Ds_Merchant_Terminal' => '2',
'Ds_Merchant_Password' => 'password'
)
);
$redsys = new Redsys($config);
$result = $redsys->parseResponse();
if ($result['accepted']) {
//payment accepted
} else {
//payment refused
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.