-
- koyan

-
Total Posts: 14
Joined: 2008-02-28
|
Hi,
Firstly, thanks for integrating the eWay gateway PHP into Magento!
Saved many people lots of time, including myself.
I installed it via Magento Connect quite easily, and everything was working with test and live accounts.
After a few days however, my client was getting reports of random transactions getting declined when payments were submitted to eWay.
The response message was a javascript alert right at the end of the payment process, and the transaction could not proceed:
“xml formatted to eway standards whitespace not allowed at this location”
I contacted eWay support, and they said this is becuase there was a ampersand or special character in the data somewhere.
Sure enough, the title of the product had an ampersand in it. However, this didn’t seem right, as it is very common for products or addresses to have special characters in them. They should be prepared for xml / database etc.
The PHP example on the eWay site uses a straight version of htmlentities to prepare ALL XML inserts.
They recommended i use the full version formatted for UTF-8 e.g. htmlentities(trim($var),ENT_QUOTES,’UTF-8’)
I updated the page \Eway\Model\Direct.php to have html entity conversion on ALL variables, except the CC details which should be already parsed.
// $this->getQuote()->reserveOrderId(); $xml = "<ewaygateway>"; $xml .= "<ewayCustomerID>" . $this->getCustomerId() . "</ewayCustomerID>"; $xml .= "<ewayTotalAmount>" . ($this->getAmount()*100) . "</ewayTotalAmount>"; $xml .= "<ewayCardHoldersName>" . htmlentities(trim($payment->getCcOwner()),ENT_QUOTES,'UTF-8') . "</ewayCardHoldersName>"; $xml .= "<ewayCardNumber>" . $payment->getCcNumber() . "</ewayCardNumber>"; $xml .= "<ewayCardExpiryMonth>" . $payment->getCcExpMonth() . "</ewayCardExpiryMonth>"; $xml .= "<ewayCardExpiryYear>" . $payment->getCcExpYear() . "</ewayCardExpiryYear>"; $xml .= "<ewayTrxnNumber>" . '' . "</ewayTrxnNumber>"; $xml .= "<ewayCustomerInvoiceDescription>" . htmlentities(trim($invoiceDesc),ENT_QUOTES,'UTF-8') . "</ewayCustomerInvoiceDescription>"; $xml .= "<ewayCustomerFirstName>" . htmlentities(trim($billing->getFirstname()),ENT_QUOTES,'UTF-8') . "</ewayCustomerFirstName>"; $xml .= "<ewayCustomerLastName>" . htmlentities(trim($billing->getLastname()),ENT_QUOTES,'UTF-8') . "</ewayCustomerLastName>"; $xml .= "<ewayCustomerEmail>" . htmlentities(trim($payment->getOrder()->getCustomerEmail()),ENT_QUOTES,'UTF-8') . "</ewayCustomerEmail>"; $xml .= "<ewayCustomerAddress>" . htmlentities(trim($formatedAddress),ENT_QUOTES,'UTF-8') . "</ewayCustomerAddress>"; $xml .= "<ewayCustomerPostcode>" . htmlentities(trim($billing->getPostcode()),ENT_QUOTES,'UTF-8') . "</ewayCustomerPostcode>"; // $xml .= "<ewayCustomerInvoiceRef>" . $this->getQuote()->getReservedOrderId() . "</ewayCustomerInvoiceRef>"; $xml .= "<ewayCustomerInvoiceRef>" . '' . "</ewayCustomerInvoiceRef>";
It now works as expected, which is great!
1 other questions for you: Why did you not include the Magento Order ID in the XML - see commented line out above. I was wondering why no order ID was visible in the eWay admin earlier as well. Was it causing bugs, and do you see any reason why i could not uncomment it so i can have the corresponding order in eWay for reference?
thanks again!
|