Moneris / Moneris-Gateway-API-PHP

23 stars 55 forks source link

Validations missing in toXML_low #21

Open guillaumefortin opened 1 year ago

guillaumefortin commented 1 year ago

2 validations are missing in toXML_low():

private function toXML_low($template,$txnType)
{
    $xmlString = "";
    //FIX: This line should be added.
    if( !empty($this->level3data[$txnType]) && is_array($this->level3data[$txnType]) )
    {
        for($x=0;$x<count($this->level3data[$txnType]);$x++)
        {
            if($x>0)
            {
                $xmlString .="</$txnType><$txnType>";
            }
            $keys=array_keys($template);
            for($i=0; $i < count($keys);$i++)
            {
                $tag=$keys[$i];

                if(is_array($template[$keys[$i]]))
                {
                    $data=$template[$tag];

                    //FIX: should add !is_array
                    if( !is_array($this->level3data[$tag]) || !count($this->level3data[$tag]) )
                    {
                        continue;
                    }
                    $beginTag="<$tag>";
                    $endTag="</$tag>";