-
Notifications
You must be signed in to change notification settings - Fork 32
X22
Andrei Baibaratsky edited this page Nov 29, 2015
·
1 revision
<form method="post">
<input type="text" name="validityperiodinhours" placeholder="validityperiodinhours" value="1"><br>
<input type="text" name="lmi_payment_amount" placeholder="lmi_payment_amount" value="1"><br>
<input type="text" name="lmi_payment_no" placeholder="lmi_payment_no" value="13"><br>
<input type="text" name="lmi_payment_desc" placeholder="lmi_payment_desc(_base64)" value="Test payment #13-x"><br>
<input type="text" name="lmi_sim_mode" placeholder="lmi_sim_mode"><br>
<input type="text" name="lmi_result_url" placeholder="lmi_result_url"><br>
<input type="text" name="lmi_success_url" placeholder="lmi_success_url"><br>
<input type="text" name="lmi_success_method" placeholder="lmi_success_method"><br>
<input type="text" name="lmi_fail_url" placeholder="lmi_fail_url"><br>
<input type="text" name="lmi_fail_method" placeholder="lmi_fail_method"><br>
<input type="text" name="lmi_paymer_pinnumberinside" placeholder="lmi_paymer_pinnumberinside"><br>
<input type="text" name="lmi_wmnote_pinnumberinside" placeholder="lmi_wmnote_pinnumberinside"><br>
<input type="text" name="lmi_paymer_email" placeholder="lmi_paymer_email"><br>
<input type="text" name="lmi_wmcheck_numberinside" placeholder="lmi_wmcheck_numberinside"><br>
<input type="text" name="lmi_wmcheck_codeinside" placeholder="lmi_wmcheck_codeinside"><br>
<input type="text" name="lmi_allow_sdp" placeholder="lmi_allow_sdp"><br>
<input type="text" name="lmi_fast_phonenumber" placeholder="lmi_fast_phonenumber"><br>
<input type="text" name="lmi_payment_creditdays" placeholder="lmi_payment_creditdays"><br>
<input type="text" name="lmi_shop_id" placeholder="lmi_shop_id"><br>
<input type="text" name="payment_method" placeholder="payment_method" value="authtype_16"><br>
<input type="text" name="name1" placeholder="name1"><input type="text" name="value1" placeholder="value1"><br>
<input type="text" name="name2" placeholder="name2"><input type="text" name="value2" placeholder="value2"><br>
<input type="text" name="name3" placeholder="name3"><input type="text" name="value3" placeholder="value3"><br>
<input type="text" name="name4" placeholder="name4"><input type="text" name="value4" placeholder="value4"><br>
<input type="text" name="name5" placeholder="name5"><input type="text" name="value5" placeholder="value5"><br>
<input type="submit" name="X22" value="X22">
</form>
<?php
require_once(__DIR__ . '/vendor/autoload.php'); // Require autoload file generated by composer
use baibaratsky\WebMoney\Api\X\X22\Request;
if (isset($_POST['X22'])) {
$request = new Request(Request::AUTH_SHA256, 'YOUR SECRET KEY');
$request->setSignerWmid('YOUR WMID');
$request->setPayeePurse('YOUR PURSE');
$request->setValidityPeriodInHours($_POST['validityperiodinhours']);
$request->setPaymentAmount($_POST['lmi_payment_amount']);
$request->setPaymentNumber($_POST['lmi_payment_no']);
$request->setPaymentDescription($_POST['lmi_payment_desc']);
$request->setSimMode($_POST['lmi_sim_mode']);
$request->setResultUrl($_POST['lmi_result_url']);
$request->setSuccessUrl($_POST['lmi_success_url']);
$request->setSuccessMethod($_POST['lmi_success_method']);
$request->setFailUrl($_POST['lmi_fail_url']);
$request->setFailMethod($_POST['lmi_fail_method']);
$request->setPaymerPinNumberInside($_POST['lmi_paymer_pinnumberinside']);
$request->setWmNotePinNumberInside($_POST['lmi_wmnote_pinnumberinside']);
$request->setPaymerEmail($_POST['lmi_paymer_email']);
$request->setWmCheckNumberInside($_POST['lmi_wmcheck_numberinside']);
$request->setWmCheckCodeInside($_POST['lmi_wmcheck_codeinside']);
$request->setAllowSdp($_POST['lmi_allow_sdp']);
$request->setFastPhoneNumber($_POST['lmi_fast_phonenumber']);
$request->setPaymentCreditDays($_POST['lmi_payment_creditdays']);
$request->setShopId($_POST['lmi_shop_id']);
$request->setPaymentMethod($_POST['payment_method']);
for ($i = 1; $i <= 5; $i++) {
if ($_POST['name' . $i]) {
$request->setUserTag($_POST['name' . $i], $_POST['value' . $i]);
}
}
$request->sign();
if ($request->validate()) {
/** @var \baibaratsky\WebMoney\Api\X\X22\Response $response */
$response = $webMoney->request($request);
if ($response->getReturnCode() === 0) {
echo 'Transaction token: ' . $response->getTransactionToken() . '<br>';
echo 'Validity Period: ' . $response->getValidityPeriodInHours() . '<br>';
echo 'URL: <a href="' . $response->getUrl() . '" target="_blank">' . $response->getUrl() . '</a>';
} else {
echo 'Error: ', $response->getReturnDescription() . '<br>';
echo 'Code: ', $response->getReturnCode();
}
} else {
echo 'Request errors:<br>';
foreach ($request->getErrors() as $error) {
echo ' — ' . $error . '<br>';
}
}
}
?>