1. Go to this page and download the library: Download baibaratsky/php-webmoney 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/ */
baibaratsky / php-webmoney example snippets
use baibaratsky\WebMoney;
use baibaratsky\WebMoney\Api\X\X9\Request;
use baibaratsky\WebMoney\Api\X\X9\Response;
use baibaratsky\WebMoney\Request\Requester\CurlRequester;
use baibaratsky\WebMoney\Signer;
// If you don’t want to use the WM root certificate to protect against DNS spoofing, pass false to the CurlRequester constructor
$webMoney = new WebMoney\WebMoney(new CurlRequester);
$request = new Request;
$request->setSignerWmid('YOUR WMID');
$request->setRequestedWmid('REQUESTED WMID');
$key = 'FULL PATH TO THE KEY FILE';
// or key is a data string from DB, cache, etc.
// $key = getKeyData();
$request->sign(new Signer('YOUR WMID', $key, 'KEY FILE PASSWORD'));
// You can access the request XML: $request->getData()
if ($request->validate()) {
/** @var Response $response */
$response = $webMoney->request($request);
// The response from WebMoney is here: $response->getRawData()
if ($response->getReturnCode() === 0) {
echo $response->getPurseByName('Z000000000000')->getAmount();
} else {
echo 'Error: ' . $response->getReturnDescription();
}
}
use baibaratsky\WebMoney;
use baibaratsky\WebMoney\Api\X\X9\Request;
use baibaratsky\WebMoney\Api\X\X9\Response;
use baibaratsky\WebMoney\Request\Requester\CurlRequester;
// If you don’t want to use the WM root certificate to protect against DNS spoofing, pass false to the CurlRequester constructor
$webMoney = new WebMoney\WebMoney(new CurlRequester);
$request = new Request(Request::AUTH_LIGHT);
$request->setRequestedWmid('REQUESTED WMID');
$request->lightAuth('FULL PATH TO THE CERTIFICATE FILE', 'FULL PATH TO THE CERTIFICATE KEY', '(OPTIONAL) PASSWORD');
// You can access the request XML: $request->getData()
if ($request->validate()) {
/** @var Response $response */
$response = $webMoney->request($request);
// The response from WebMoney is here: $response->getRawData()
if ($response->getReturnCode() === 0) {
echo $response->getPurseByName('Z000000000000')->getAmount();
} else {
echo 'Error: ' . $response->getReturnDescription();
}
}
curl -sS https://getcomposer.org/installer | php
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.