Php – Place Order fails in Magento OnePage Checkout

ajaxmagentoPHP

I have a Magento store that has been converted to a "one deal at a time" type store, and the checkout process is broken. I've been trying to debug this, but have hit a wall, primarily due to my limited understanding of Magento.

On the saveOrder step, when clicking "Place Order", the page shows "submitting order information, then the message clears and the shopper is still on the Order Review page.

I've analyzed with Firebug and HttpFox, and I can see the order information is being sent

(Request-Line)  POST /checkout/onepage/saveOrder/ HTTP/1.1
Host    www.domainname.com
User-Agent  Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0
Accept  text/javascript, text/html, application/xml, text/xml, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  115
Connection  keep-alive
X-Requested-With    XMLHttpRequest
X-Prototype-Version 1.6.0.3
Content-Type    application/x-www-form-urlencoded; charset=UTF-8
Referer https://www.domainname.com/checkout/onepage/
Content-Length  178
Cookie  frontend=cd60252d28cd115d4096cb2bb5b6a043
Pragma  no-cache
Cache-Control   no-cache

Post Data shows all of the required information:

payment[method] authorizenet
payment[cc_type]    VI
payment[cc_number]  4111111111111111
payment[cc_exp_month]   5
payment[cc_exp_year]    2012
payment[cc_cid] 987

My problem seemed similar to this post:
http://fishpig.co.uk/magento-tutorials/magento-checkout-error-undefined-javascript-alert

but I'm not getting an "Undefined" alert, so I added the "else" statement below:

nextStep: function(transport){
    if (transport && transport.responseText) {
            alert(transport.responseText);
        try{
            response = eval('(' + transport.responseText + ')');
        }
        catch (e) {
            response = {};
        }
        if (response.redirect) {
            location.href = response.redirect;
            return;
        }
        if (response.success) {
            this.isSuccess = true;
            window.location=this.successUrl;
        }
        else{
            var msg = response.error_messages;
            if (typeof(msg)=='object') {
                msg = msg.join("\n");
            }
            alert(msg);
        }

        if (response.update_section) {
            $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
            response.update_section.html.evalScripts();
        }

        if (response.goto_section) {
            checkout.gotoSection(response.goto_section);
            checkout.reloadProgressBlock();
        }
    } else {
        alert('transport.responseText');
        }
},

I am getting the JS alert with no text, so it looks like transport.reponseText is empty. The main references to empty response text I've found appear to be related to same-origin policy, which I don't think applies, because my AJAX post is to and from www.domainname.com.

When I call the saveOrder function directly in the browser, I'm receiving a valid response:

https://www.domainname.com/checkout/onepage/saveOrder
{"success":false,"error":true,"error_messages":"Credit card number mismatch with credit card type"}

and HTTPFox shows I'm getting a 200 response from the Ajax call, but the responsetext is simply empty. I find no PHP errors or errors in Magento's exceptions log. The only thing I'm finding that might be related is "Headers already sent' in Magento's system log:

</pre>
2011-09-03T12:14:21+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] wwwroot/app/code/core/Mage/Core/Controller/Response/Http.php:50
[1] wwwroot/lib/Zend/Controller/Response/Abstract.php:726
[2] wwwroot/app/code/core/Mage/Core/Controller/Response/Http.php:82
[3] wwwroot/app/code/core/Mage/Core/Controller/Varien/Front.php:169
[4] wwwroot/app/Mage.php:459
[5] wwwroot/index.php:67
</pre>

Does anyone have any suggestions why else the responseText is coming back empty?

Best Answer

Custom modules were at fault. Disabling all of the custom modules in the Magento admin does not actually disable them, it only "disables their output".

Setting False in the module configuration resolved the invalid headers error, at which point I was able to debug the custom module issue that was causing the AJAX checkout errors.

Related Topic