Last active
August 7, 2018 10:31
-
-
Save eonarik/62bc63cb6571da87e9716a882436faae to your computer and use it in GitHub Desktop.
modx snippet robokassaLink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* требуемые настройки сайта | |
* | |
* robokassa.env_test (1|0) - тестовый режим | |
* robokassa.login - идентификатор магазина | |
* robokassa.password_1 - пароль 1 | |
* robokassa.password_2 - пароль 2 | |
* robokassa.test_password_1 - тестовый пароль 1 | |
* robokassa.test_password_2 - тестовый пароль 2 | |
* | |
* документация https://docs.robokassa.ru/ | |
* */ | |
$price = $modx->getOption('price', $scriptProperties, 0); | |
$order_id = $modx->getOption('order_id', $scriptProperties, 0); | |
$desc = $modx->getOption('desc', $scriptProperties, 'Order payment'); | |
$culture = $modx->getOption('cultureKey', $scriptProperties, 'ru'); | |
$payments = $modx->getOption('payments', $scriptProperties, ''); | |
if ($price <= 0) { | |
return 'Not available price'; | |
} | |
// регистрационная информация (логин, пароль #1) | |
// registration info (login, password #1) | |
$mrh_login = $modx->getOption('robokassa.login'); | |
if ($modx->getOption('robokassa.env_test')) { | |
$mrh_pass1 = $modx->getOption('robokassa.test_password_1'); | |
} else { | |
$mrh_pass1 = $modx->getOption('robokassa.password_1'); | |
} | |
// номер заказа | |
// number of order | |
$inv_id = $order_id; | |
// $OutSumCurrency = "EUR"; | |
// описание заказа | |
// order description | |
$inv_desc = $desc; | |
// сумма заказа | |
// sum of order | |
$out_summ = $price; | |
// тип товара | |
// code of goods | |
$shp_item = 1; | |
// язык | |
// language | |
$culture = $culture; | |
// кодировка | |
// encoding | |
$encoding = "utf-8"; | |
// формирование подписи | |
// generate signature | |
$crc = md5("$mrh_login:$out_summ:$inv_id:$mrh_pass1"); | |
// HTML-страница с кассой | |
// ROBOKASSA HTML-page | |
return "https://auth.robokassa.ru/Merchant/Index.aspx?". | |
"MerchantLogin=$mrh_login&OutSum=$out_summ&InvId=$inv_id". | |
"&Description=$inv_desc&SignatureValue=$crc". | |
"&Culture=$culture&Encoding=$encoding" . | |
($payments ? "&IncCurrLabel=$payments" : "") . | |
($modx->getOption('robokassa.env_test') ? "&IsTest=1" : ""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment