<?php
// цена продукта
$product_price = 2500;
$pay_methods = [];
$login = 'trevoga';
$pay_methods_url = 'https://auth.robokassa.ru/Merchant/WebService/Service.asmx/GetRates?MerchantLogin=' . $login . '&IncCurrLabel=&Language=ru&OutSum=' . $product_price;
$pay_methods = [];
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
if ($dom->load($pay_methods_url)) {
$groups = $dom->getElementsByTagName('Group');
if ($groups->length) {
foreach ($groups as $group) {
if ($group->getElementsByTagName('Items')->length) {
$currencyList = $group->getElementsByTagName('Items')[0]->getElementsByTagName('Currency');
if ($currencyList->length) {
foreach ($currencyList as $currency) {
$price_rate = $currency->firstChild->getAttribute('IncSum');
$rate = $price_rate - $product_price;
$rate_round = ceil($rate);
$price_rate_round = ceil($price_rate);
$pay_methods[$group->getAttribute('Description')][] = [
'Alias' => $currency->getAttribute('Label'),
'Name' => $currency->getAttribute('Name'),
'price' => $product_price,
'rate' => $rate,
'rate_round' => $rate_round,
'price_rate' => $price_rate,
'price_rate_round' => $price_rate_round,
];
}
}
}
}
}
}
print_r($pay_methods);