-
Notifications
You must be signed in to change notification settings - Fork 32
X18
Andrei Baibaratsky edited this page Aug 15, 2015
·
3 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\X18\Request;
use baibaratsky\WebMoney\Api\X\X18\Response;
$webMoney = new WebMoney(new CurlRequester);
$request = new Request(Request::AUTH_SHA256, 'YOUR_SECRET_KEY');
$request->setSignerWmid('YOUR WMID');
$request->setPaymentNumber('PAYMENT ID IN YOUR SYSTEM');
$request->setPayeePurse('YOUR PURSE');
$request->sign();
if ($request->validate()) {
/** @var Response $response */
$response = $webMoney->request($request);
if ($response->getReturnCode() === 0) {
echo 'Payment found' . PHP_EOL;
echo 'Transaction ID: ' . $response->getTransactionId() . PHP_EOL;
echo 'Payer’s WMID: ' . $response->getPayerWmid() . PHP_EOL;
echo 'Payer’s purse: ' . $response->getPayerPurse() . PHP_EOL;
echo 'Amount: ' . $response->getAmount() . PHP_EOL;
echo 'Date: ' . $response->getDateTime()->format(DateTime::RFC850) . PHP_EOL;
echo 'Description: ' . $response->getDescription() . PHP_EOL;
echo 'IP: ' . $response->getIp() . PHP_EOL;
} else {
echo 'Payment error: ' . $response->getReturnDescription();
}
} else {
echo 'Request errors: ' . PHP_EOL;
foreach ($request->getErrors() as $error) {
echo ' - ' . $error . PHP_EOL;
}
}