PHP code example of bahiazul / redsys-virtual-pos
1. Go to this page and download the library: Download bahiazul/redsys-virtual-pos 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/ */
bahiazul / redsys-virtual-pos example snippets
use Bahiazul\RedsysVirtualPos\Message\WebRequest;
use Bahiazul\RedsysVirtualPos\Field\Currency;
use Bahiazul\RedsysVirtualPos\Field\TransactionType;
$secret = 'Mk9m98IfEblmPfrpsawt7BmxObt98Jev';
$merchantCode = '999008881';
$terminal = '871';
// The Environment object holds connection details
$env = new Bahiazul\RedsysVirtualPos\Environment\DevelopmentEnvironment();
$env->setSecret($secret);
// Setup the Parameters for the Request
$params['Amount'] = '145'; // €1,45
$params['Order'] = strval(time());
$params['MerchantCode'] = $merchantCode;
$params['Currency'] = Currency::EUR;
$params['TransactionType'] = TransactionType::STANDARD;
$params['Terminal'] = $terminal;
$params['MerchantName'] = 'Test Store'; // optional
$params['ProductDescription'] = 'Product Description'; // optional
$params['UrlOk'] = 'http://localhost:8000/success.php'; // optional
$params['UrlKo'] = 'http://localhost:8000/failure.php'; // optional
// Generate the Request
$webRequest = new WebRequest($env);
$webRequest->setParams($params);
// Generate the form
$submitBtn = "<p><input type='submit' value='Submit'></p>";
$wrForm = $webRequest->getForm([], $submitBtn);
// Render the HTML form w/ Submit button
echo $wrForm;