Skip to content

Commit 4c7a1d5

Browse files
author
Andrew Keynes
committed
Always encode entities in messageID and purchaseOrderNo
This fixes an issue where a client submitting a transaction containing a purchaseOrderNo with an ampersand in it resulted in an 'unterminated entity reference' exception. Turns out that in SimpleXML 'addChild' doesn't encode entities however when assigning the value directly it does.
1 parent 9336b82 commit 4c7a1d5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Message/SecureXMLAbstractRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function getBaseXML()
6565
$xml = new \SimpleXMLElement('<SecurePayMessage/>');
6666

6767
$messageInfo = $xml->addChild('MessageInfo');
68-
$messageInfo->addChild('messageID', $this->getMessageId());
68+
$messageInfo->messageID = $this->getMessageId();
6969
$messageInfo->addChild('messageTimestamp', $this->generateTimestamp());
7070
$messageInfo->addChild('timeoutValue', 60);
7171
$messageInfo->addChild('apiVersion', 'xml-4.2');
@@ -98,7 +98,7 @@ protected function getBasePaymentXML()
9898
$transaction->addChild('txnSource', 23); // Must always be 23 for SecureXML.
9999
$transaction->addChild('amount', $this->getAmountInteger());
100100
$transaction->addChild('currency', $this->getCurrency());
101-
$transaction->addChild('purchaseOrderNo', $this->getTransactionId());
101+
$transaction->purchaseOrderNo = $this->getTransactionId();
102102

103103
return $xml;
104104
}

0 commit comments

Comments
 (0)