Call-back icon  Sales: Call 800.374.8146 (N America)|757.278.0920 (International)

Magento

Open Source eCommerce Evolved

Magento Forum

   
eWay bug - data not prepared properly for XML
 
koyan
Jr. Member
 
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!

 
Magento Community Magento Community
Magento Community
Magento Community
 
odi-um
Magento Team
 
Avatar
Total Posts:  81
Joined:  2008-04-02
 

Hi koyan,

thanks for the bug report, it will be fixed.
about commented line - it was not a bug ... as we don’t have test account (so we can’t see how those payments look like in your account area) seems we simply forgot to uncomment it smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
koyan
Jr. Member
 
Total Posts:  14
Joined:  2008-02-28
 

Thanks odi-um,

I’ll uncomment the order Id line, good to know it can be used safely wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
odi-um
Magento Team
 
Avatar
Total Posts:  81
Joined:  2008-04-02
 

Hi koyan,

but also don’t forget uncomment

$this->getQuote()->reserveOrderId();

before this block, so there will be some value in reserved order id.
And now i remember why we comment it ... its not a bug it like a feature smile ... if u will execute reservOrderId() u will change the order of order’s ids. Now order of order’s id are the same as created_at ... so order created earlier will have smaller id. but after executing reservOrderId() it will be small disorder and orders sorted by created_at time can not have id order as 1, 2, 3, 4 etc. And also some ids can disappear ... so for example u will not have order with some id bc id was reserved but transaction was unsuccessful and order was not created.

For some clients its very critical to have right order and don’t miss any numbers, so it was commented.

Sorry. forgot about this fact.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 800.374.8146 (North America) 757.278.0920 (International)
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
33683 users|424 users currently online|74658 forum posts