isotope / core

Core repository of Isotope eCommerce, an eCommerce extension for Contao Open Source CMS
https://isotopeecommerce.org
135 stars 107 forks source link

Orders go missing after redirecting to payment #342

Closed ghost closed 11 years ago

ghost commented 11 years ago

I've found on two seperate installations that I sometimes receive a payment notification from my bank, but have not received an order e-mail from Isotope. On one installation (Isotope 1.3.0 rc1) it happened recently, and I have been able to look at the access and error logs. The error log shows no errors that could cause this. The access log shows something interesting. The order that failed did return to the correct page, but instead of being redirected to the confirmation page (303) the page gets status code 200 (OK).

    xxx.xxx.153.51 - - [09/Jan/2012:22:50:37 +0100] "GET /afrekenen/step/complete/purchaseID/22/response/success.html HTTP/1.1" 303 499 "-" "Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3"
    xxx.xxx.153.51 - - [09/Jan/2012:22:50:39 +0100] "GET /order-summary.html?uid=4f0b60871ac7e6.11732532 HTTP/1.1" 200 3964 "-" "Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3"

6 Jan (FAIL)
    xxx.xxx.54.75 - - [06/Jan/2012:14:05:21 +0100] "GET /afrekenen/step/process.html HTTP/1.1" 200 4163 "http://winkel.nl/afrekenen/step/review.html" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1"
    xxx.xxx.54.75 - - [06/Jan/2012:14:05:22 +0100] "GET /system/html/cron.txt HTTP/1.1" 304 161 "http://winkel.nl/afrekenen/step/process.html" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1"
    xxx.xxx.54.75 - - [06/Jan/2012:14:05:22 +0100] "GET /system/modules/isotope/html/delete.png HTTP/1.1" 404 488 "http://winkel.nl/system/scripts/9061b66191c5.css" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1"
    xxx.xxx.54.75 - - [06/Jan/2012:14:05:22 +0100] "GET /cron.php HTTP/1.1" 200 583 "http://winkel.nl/afrekenen/step/process.html" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1"
    xxx.xxx.54.75 - - [06/Jan/2012:14:06:36 +0100] "GET /afrekenen/step/complete/purchaseID/21/response/success.html HTTP/1.1" 200 3606 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1"

2 Jan (OK)
    xxx.xxx.169.214 - - [02/Jan/2012:10:39:09 +0100] "GET /afrekenen/step/complete/purchaseID/20/response/success.html HTTP/1.1" 303 499 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB7.2; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
    xxx.xxx.169.214 - - [02/Jan/2012:10:39:10 +0100] "GET /order-summary.html?uid=4f017b18389ff4.11461623 HTTP/1.1" 200 4001 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB7.2; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"

20 Dec 23:21 (OK)
    xxx.xxx.222.251 - - [20/Dec/2011:23:23:03 +0100] "GET /afrekenen/step/complete/purchaseID/19/response/success.html HTTP/1.1" 303 503 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
    xxx.xxx.222.251 - - [20/Dec/2011:23:23:03 +0100] "GET /order-summary.html?uid=4ef10a78d8dbe9.82559880 HTTP/1.1" 200 3949 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"

20 Dec 10:03 (OK)
    xxx.xxx.204.144 - - [20/Dec/2011:10:03:48 +0100] "GET /afrekenen/step/complete/purchaseID/18/response/success.html HTTP/1.1" 303 498 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0"
    xxx.xxx.204.144 - - [20/Dec/2011:10:03:50 +0100] "GET /order-summary.html?uid=4ef04f6aa23bd2.00810314 HTTP/1.1" 200 3722 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0"```

The only non "native" Isotope code is my payment module, it has a processPayment function which is executed. I checked the database and looked over the script; the outcome must be "true", but here is the script, just to be sure:
``` public function processPayment() {
        $status = 'error';
// Now deal with the payment
$objOrder = $this->Database->prepare("SELECT * FROM `tl_iso_orders` WHERE `id`=?")->limit(1)->execute($this->Input->get('purchaseID'));

if (!$objOrder->numRows) {
    return false;
}

// Set the current system to the language when the user placed the order.
// This will result in correct e-mails and payment description.
$GLOBALS['TL_LANGUAGE'] = $objOrder->language;
$this->loadLanguageFile('default');

// Load / initialize data
$arrPayment = deserialize($objOrder->payment_data, true);

// Store request data in order for future references
$arrPayment['POSTSALE'][] = $_GET;

$arrData = $objOrder->row();
$arrData['old_payment_status'] = $arrPayment['status'];
$arrPayment['status'] = $this->Input->get('response');
$arrData['new_payment_status'] = $arrPayment['status'];

// array('success', 'cancel', 'error'),
switch( $arrPayment['status'] ) {
    case 'success':
        $this->Database->execute("UPDATE tl_iso_orders SET date_payed=" . time() . " WHERE id=" . $objOrder->id);
        $this->Database->prepare("UPDATE tl_iso_orders SET payment_data=? WHERE id=?")->execute(serialize($arrPayment), $objOrder->id);

        // Set the current system to the language when the user placed the order.
        // This will result in correct e-mails and payment description.
        $GLOBALS['TL_LANGUAGE'] = $objOrder->language;
        $this->loadLanguageFile('default');

        if ($this->postsale_mail) {
            try {
                $this->Isotope->overrideConfig($objOrder->config_id);
                $this->Isotope->sendMail($this->postsale_mail, $GLOBALS['TL_CONFIG']['adminEmail'], $GLOBALS['TL_LANGUAGE'], $arrData);
            }
            catch (Exception $e) {}
        }

        break;

    case 'cancel':
    case 'error':
    default:
        global $objPage;
        $this->redirect($this->generateFrontendUrl($objPage->row(), '/step/failed'));
        return false;
        break;
}

return true;

}```



_--- Originally created by Ruud on 2012-01-14 09:22:54 (ID 2801)_
aschempp commented 11 years ago

I fixed an issue that could be related to postsale requests today. Can you please check if it works now?

--- Originally created by andreas.schempp on 2012-01-16 20:25:26

ghost commented 11 years ago

The last change in the repository was from December 20th. (Rev 2600). I cannot test your change. Did you also move the repository? If so, where is it now?

--- Originally created by Ruud on 2012-01-19 09:31:52

aschempp commented 11 years ago

https://github.com/isotope/core

--- Originally created by andreas.schempp on 2012-01-19 09:42:21

ghost commented 11 years ago

I've added it to my store. The thing is though that I can't tell you if it works. Before I've put it in we've had 5 or 6 orders through that store and none seemed to be missing. I never found a way to make sure this goes wrong...

--- Originally created by Ruud on 2012-01-24 16:30:05

ghost commented 11 years ago

I've got the same problem using the new extension https://github.com/isotope/isotope_sofortueberweisung. Payment is successful, however Isotope does not show the order. Neither in the Contao logs nor in the orders section. E-mails are not sent.

Tested with Isotope 1.3.0 rc1 and rc2 (after manual upgrade).

--- Originally created by JaiBee on 2012-03-21 12:02:08

ghost commented 11 years ago

Access logs look similar (status code 200 for the confirmation page), by the way.

--- Originally created by JaiBee on 2012-03-21 12:03:30

aschempp commented 11 years ago

Probably related to the FE_USER_LOGGED_IN issue / cron jobs.

--- Originally created by andreas.schempp on 2012-04-02 22:32:20