Skip to content
Andrei Baibaratsky edited this page Nov 29, 2015 · 3 revisions

Links

Usage

Trust Request

<form method="post">
    <input type="text" name="lmi_day_limit" placeholder="lmi_day_limit" value="100"><br>
    <input type="text" name="lmi_week_limit" placeholder="lmi_week_limit" value="1000"><br>
    <input type="text" name="lmi_month_limit" placeholder="lmi_month_limit" value="10000"><br>
    <input type="text" name="lmi_clientnumber" placeholder="lmi_clientnumber" value="R385841645357"><br>
    <input type="text" name="lmi_clientnumber_type" placeholder="lmi_clientnumber_type" value="4"><br>
    <input type="text" name="lmi_sms_type" placeholder="lmi_sms_type" value="1"><br>
    <input type="text" name="lang" placeholder="lang" value="en-US"><br>
    <input type="submit" name="X21R" value="X21 Trust Request">
</form>

<?php
require_once(__DIR__ . '/vendor/autoload.php'); // Require autoload file generated by composer

use baibaratsky\WebMoney\Api\X\X21\TrustRequest\Request;

if (isset($_POST['X21R'])) {
    $request = new Request(Request::AUTH_LIGHT);
    $request->cert('FULL PATH TO THE CERTIFICATE FILE', 'FULL PATH TO THE CERTIFICATE KEY');
    $request->setSignerWmid('YOUR WMID');
    $request->setPayeePurse('YOUR PURSE');
    if (isset($_POST['lmi_day_limit']) && $_POST['lmi_day_limit'] !== '') {
        $request->setDayLimit($_POST['lmi_day_limit']);
    }
    if (isset($_POST['lmi_week_limit']) && $_POST['lmi_week_limit'] !== '') {
        $request->setWeekLimit($_POST['lmi_week_limit']);
    }
    if (isset($_POST['lmi_month_limit']) && $_POST['lmi_month_limit'] !== '') {
        $request->setMonthLimit($_POST['lmi_month_limit']);
    }
    $request->setClientNumber($_POST['lmi_clientnumber']);
    $request->setClientNumberType($_POST['lmi_clientnumber_type']);
    $request->setSmsType($_POST['lmi_sms_type']);
    if (isset($_POST['lang']) && $_POST['lang'] !== '') {
        $request->setLanguage($_POST['lang']);
    }

    if ($request->validate()) {
        /** @var \baibaratsky\WebMoney\Api\X\X21\TrustRequest\Response $response */
        $response = $webMoney->request($request);

        if ($response->getReturnCode() === 0) {
            echo 'Request ID: ' . $response->getRequestId() . '<br>';
        } else {
            echo 'Error: ' . $response->getReturnDescription() . '<br>';
            echo 'Code: ' . $response->getReturnCode() . '<br>';
        }
    } else {
        echo 'Request errors:<br>';
        foreach ($request->getErrors() as $error) {
            echo '' . $error . '<br>';
        }
    }
}
?>

Trust Confirmation

<form method="post">
    <input type="text" name="lmi_purseid" placeholder="lmi_purseid">
    <input type="text" name="lmi_clientnumber_code"
           placeholder="lmi_clientnumber_code">
    <input type="text" name="lang" placeholder="lang" value="en-US">
    <input type="submit" name="X21C" value="X21 Trust Confirmation">
</form>

<?php
require_once(__DIR__ . '/vendor/autoload.php'); // Require autoload file generated by composer

use baibaratsky\WebMoney\Api\X\X21\TrustConfirm\Request;

if (isset($_POST['X21C'])) {
    $request = new Request(Request::AUTH_LIGHT);
    $request->cert('FULL PATH TO THE CERTIFICATE FILE', 'FULL PATH TO THE CERTIFICATE KEY');
    $request->setSignerWmid('YOUR WMID');
    $request->setRequestId($_POST['lmi_purseid']);
    $request->setConfirmationCode($_POST['lmi_clientnumber_code']);
    if (isset($_POST['lang']) && $_POST['lang'] !== '') {
        $request->setLanguage($_POST['lang']);
    }

    if ($request->validate()) {
        /** @var \baibaratsky\WebMoney\Api\X\X21\TrustConfirm\Response $response */
        $response = $webMoney->request($request);

        if ($response->getReturnCode() === 0) {
            echo 'Trust ID: ' . $response->getTrustId() . '<br>';
        } else {
            echo 'Error: ' . $response->getReturnDescription() . '<br>';
            echo 'Code: ' . $response->getReturnCode();
        }
    } else {
        echo 'Request errors:<br>';
        foreach ($request->getErrors() as $error) {
            echo '' . $error . '<br>';
        }
    }
}
?>
Clone this wiki locally