Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double sending response from 'affirm/payment/confirmAction' #76

Open
DianaSol opened this issue Apr 24, 2020 · 0 comments
Open

Double sending response from 'affirm/payment/confirmAction' #76

DianaSol opened this issue Apr 24, 2020 · 0 comments

Comments

@DianaSol
Copy link

We've faced up with this error:

2020-04-23T07:26:04+00:00 DEBUG (7): after getOrderPayment 
2020-04-23T07:26:04+00:00 DEBUG (7): affirm
2020-04-23T07:31:53+00:00 DEBUG (7): HEADERS ALREADY SENT: \<pre>[0] /home/budsies/website/app/code/core/Mage/Core/Controller/Response/Http.php:52
[1] /home/budsies/website/lib/Zend/Controller/Response/Abstract.php:779
[2] /home/budsies/website/app/code/core/Mage/Core/Controller/Response/Http.php:84
[3] /home/budsies/website/app/code/core/Mage/Core/Controller/Varien/Front.php:184
[4] /home/budsies/website/app/code/core/Mage/Core/Model/App.php:365
[5] /home/budsies/website/app/Mage.class.php:655
[6] /home/budsies/website/index.php:82
\</pre>

It appears after order confirmation at the Affirm side.

After some debugging, it turned out, that Affirm observer Affirm_Affirm_Model_Order_Observer_AfterSaveOrder sends the response prior to Magento.

The fix was - to remove sending response from the observer:

    public function postDispatchSaveOrder($observer)
    {
        $response = $observer->getControllerAction()->getResponse();
        $session = Mage::helper('affirm')->getCheckoutSession();
        $serializedRequest = $session->getAffirmOrderRequest();
        $proxyRequest = unserialize($serializedRequest);
        $checkoutToken = Mage::registry('affirm_token_code');
        $lastOrderId = $session->getLastOrderId();
        //Return, if order was placed before confirmation
        if (!($serializedRequest && $checkoutToken) || !Mage::helper('affirm')->isXhrRequest($proxyRequest)
            || !$this->_isAffirmPaymentMethod($proxyRequest) || !$lastOrderId) {
            return;
        }

        $session->setPreOrderRender(null);
        $session->setLastAffirmSuccess($checkoutToken);
        $session->setAffirmOrderRequest(null);
//        $response->setRedirect(Mage::getUrl('checkout/onepage/success'))->sendResponse();
        $response->setRedirect(Mage::getUrl('checkout/onepage/success'));
        return;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant