Hosted Pay Page Asynchronous Transaction Response Parsing

We're receiving the hosted pay page asynchronous response via HTTPS POST.  The POST body contains what purports to be XML, but in certain cases it's not well-formed XML.  For example, if the cardholder name contains special characters:

<?xml version='1.0 standalone='yes'?>

Problem is, that "eacute" entity reference can't be resolved by any XML parser, because there is no DTD associated with this XML and, even if there was, it would be ignored due to the standalone='yes' attribute on the XML declaration.

Vanilla XML only defines five named entities. Anything else should be encoded using the relevant character (&#xE9; in this case).

Any chance this can be rectified?

  • This has bitten me too. It would be nice if this were to be fixed. I have worked around the issue by not including billing data in the response, but that is a function diminishing hack, not a solution.
  • we are working on creating on async option to send in standard XML. For now, it will be encoded as this was what lot of other merchants requested. You will have to read the post as is, decode the value and then pass it through your built-in XML parser.
  • In reply to MB_Moneris:

    The XML is pretty broken. In some fields (billing name and billoing address 1) the entities are double encoded, so an e actute becomes &amp;eacute;, but in other fields (city, for instance, an e acute manifests as &eacute;, which makes for broken xml. Cleanup of this to put through an xml parser is virtually impossible, but the data can be disassembled by fairly simple code. in php, for instance:

    function decode(&$t, $i) {
    $t = html_entity_decode ( html_entity_decode ($t, ENT_NOQUOTES, 'UTF-8'), ENT_NOQUOTES, 'UTF-8');
    function brokenxml_decode($text) {
    preg_match_all('/(?:<([^\/][^>]*)>([^<]*)<\/[^>]*>)/s', $text, $m);
    array_walk($m[2], 'decode');
    $res = [];
    foreach ($m[2] as $i=>$v) {
    $res[$m[1][$i]] = $v;
    return $res;
    // Recieve the response from the Moneris server
    $response = $_REQUEST["xml_response"];

    /* remove <?xml version=\'1.0\' standalone=\'yes\'?>
    from the string of XML before trying to parse the XML */
    $position = strpos($response, "?>");
    $length = strlen($response);
    $response = substr ($response, $position+2, $length );
    $receipt = brokenxml_decode($response);
  • In reply to yrqpeter:

    I also notice that the receipts emailed by moneris for bills like this are encode wromg
  • In reply to MB_Moneris:

    Is this "standard XML" feature still in the works?