PHP implementation of GestPay (Banca Sella) Web Services
- Simple API
- Decoupled classes
- PHPUnit tested
- Framework agnostic
- Composer ready, PSR-2 and PSR-4 compliant
You need PHP >= 5.3.3 and the soap
extension to use the library, but the latest stable version of PHP is recommended.
Install EndelWar/GestPayWS
using Composer.
$ composer require endelwar/gestpayws
require __DIR__ . '/../vendor/autoload.php';
use EndelWar\GestPayWS\WSS2SSoapClient;
use EndelWar\GestPayWS\WSS2S;
use EndelWar\GestPayWS\Parameter;
use EndelWar\GestPayWS\Data;
// enable or disable test environment
$enableTestEnv = true;
$soapClient = new WSS2SSoapClient($enableTestEnv);
try {
$gestpay = new WSS2S($soapClient->getSoapClient());
} catch (\Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
// set mandatory info
$pagamParameter = new Parameter\PagamParameter();
$pagamParameter->shopLogin = 'GESPAY12345';
$pagamParameter->amount = '1.23';
$pagamParameter->shopTransactionId = '1';
$pagamParameter->uicCode = Data\Currency::EUR;
$pagamParameter->languageId = Data\Language::ITALIAN;
// set optional custom info as array
$customArray = array('STORE_ID' => '42', 'STORE_NAME' => 'Shop Abc123');
$pagamParameter->setCustomInfo($customArray);
// encrypt data
$gestpayResult = $gestpay->pagam($pagamParameter);
// get redirect link to Banca Sella
echo $gestpayResult->getPaymentPageUrl($pagamParameter->shopLogin, $soapClient->wsdlEnvironment);
require __DIR__ . '/../vendor/autoload.php';
use EndelWar\GestPayWS\Parameter\DecryptParameter;
use EndelWar\GestPayWS\WSCryptDecryptSoapClient;
use EndelWar\GestPayWS\WSCryptDecrypt;
// $_GET['a'] and $_GET['b'] are received from Banca Sella
$param = array(
'shopLogin' => $_GET['a'],
'CryptedString' => $_GET['b']
);
$decryptParam = new DecryptParameter($param);
// enable or disable test environment
$enableTestEnv = true;
$soapClient = new WSCryptDecryptSoapClient($enableTestEnv);
try {
$gestpay = new WSCryptDecrypt($soapClient->getSoapClient());
$decryptResult = $gestpay->decrypt($decryptParam);
echo $decryptResult->TransactionResult;
} catch (\Exception $e) {
var_dump($e->getCode(), $e->getMessage());
}
EndelWar/GestPayWS
has a PHPUnit test suite. To run the tests, run the following command from the project folder.
$ phpunit
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Semantic versioning (semver) is applied.
This library is under the MIT license. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.