17 $xpath = new \DOMXPath(
$source);
19 'credit_cards' => $this->convertCreditCards($xpath),
20 'groups' => $this->convertGroups($xpath),
21 'methods' => $this->convertMethods($xpath)
31 protected function convertCreditCards(\DOMXPath $xpath)
35 foreach ($xpath->query(
'/payment/credit_cards/type') as
$type) {
39 foreach (
$type->childNodes as $typeSubNode) {
40 switch ($typeSubNode->nodeName) {
42 $typeArray[
'name'] = $typeSubNode->nodeValue;
49 $typeAttributes =
$type->attributes;
50 $typeArray[
'order'] = $typeAttributes->getNamedItem(
'order')->nodeValue;
51 $ccId = $typeAttributes->getNamedItem(
'id')->nodeValue;
52 $creditCards[$ccId] = $typeArray;
54 uasort($creditCards, [$this,
'_compareCcTypes']);
71 private function _compareCcTypes($left, $right)
73 return $left[
'order'] - $right[
'order'];
82 protected function convertGroups(\DOMXPath $xpath)
86 foreach ($xpath->query(
'/payment/groups/group') as
$group) {
87 $groupAttributes =
$group->attributes;
88 $id = $groupAttributes->getNamedItem(
'id')->nodeValue;
91 foreach (
$group->childNodes as $groupSubNode) {
92 switch ($groupSubNode->nodeName) {
110 protected function convertMethods(\DOMXPath $xpath)
114 foreach ($xpath->query(
'/payment/methods/method') as
$method) {
115 $name =
$method->attributes->getNamedItem(
'name')->nodeValue;
117 foreach (
$method->childNodes as $methodSubNode) {
118 if ($methodSubNode->nodeType != XML_ELEMENT_NODE) {
121 $config[
$name][$methodSubNode->nodeName] = $methodSubNode->nodeValue;
if(!isset($_GET['name'])) $name