-
Notifications
You must be signed in to change notification settings - Fork 32
X19
Andrei Baibaratsky edited this page Jan 27, 2015
·
2 revisions
require_once(__DIR__ . '/vendor/autoload.php'); // Require autoload file generated by composer
use baibaratsky\WebMoney\WebMoney;
use baibaratsky\WebMoney\Signer;
use baibaratsky\WebMoney\Request\Requester\CurlRequester;
use baibaratsky\WebMoney\Api\X\X19\Request;
use baibaratsky\WebMoney\Api\X\X19\Response;
$webMoney = new WebMoney(new CurlRequester);
$request = new Request;
$request->setSignerWmid('YOUR WMID');
$request->setOperationType(Request::TYPE_EMONEY);
$request->setOperationDirection(Request::DIRECTION_INPUT);
$request->setOperationPurseType(Request::PURSE_WMZ);
$request->setOperationAmount(123.45);
$request->setOrderId(18); // Order ID in your system
$request->setUserFirstName('John');
$request->setUserLastName('Snow');
$request->setUserEMoneyName(Request::EMONEY_PP);
$request->setUserEMoneyId('john.snow@example.com');
$request->sign(new Signer('YOUR WMID', 'FULL PATH TO KEY FILE', 'KEY FILE PASSWORD'));
if ($request->validate()) {
/** @var Response $response */
$response = $webMoney->request($request);
if ($response->getReturnCode() === 0) {
echo 'OK';
} else {
echo 'Error: ' . $response->getReturnDescription();
}
} else {
echo 'Request errors: ' . PHP_EOL;
foreach ($request->getErrors() as $error) {
echo ' - ' . $error . PHP_EOL;
}
}