-
Notifications
You must be signed in to change notification settings - Fork 32
Andrei Baibaratsky edited this page May 25, 2015
·
6 revisions
require_once(__DIR__ . '/vendor/autoload.php'); // Require autoload file generated by composer
use baibaratsky\WebMoney;
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 WebMoney\Request\Requester\CurlRequester);
$request = new WebMoney\Api\X\X9\Request;
$request->setSignerWmid('YOUR WMID');
$request->setRequestedWmid('REQUESTED WMID');
$request->sign(new Signer('YOUR WMID', 'FULL PATH TO KEY FILE', 'KEY FILE PASSWORD'));
// You can access the request XML: $request->getData()
if ($request->validate()) {
/** @var WebMoney\Api\X\X9\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();
}
}