Saturday, November 18, 2006

Bug Fix: Download Page with Large Orders

There was an issue where if a customer bought a lot of items from one seller in a single purchase (usually over 20 items), that when they were redirected to the download page from PayPal, not all of the products would have been processed by the system. That would leave a customer on the download page with less than their entire order.

The problem arises when the person clicks pay and PayPal's system contacts our IPN order processing script. That script loops through all of the items purchased and enters them into the system. Meanwhile, the PayPal system will redirect the customer back to the download page using either PDT or the "Continue to Download" button on the payment receipt page. In very large orders, not enough time has elapsed to record all of the items, so only the download links for the items that made it into the system appear. If the person visited the page a few seconds later, it would give them their entire order.

To resolve this issue, we are taking the number of cart items variable (num_cart_items) that is passed to us by PayPal in the customer redirect, and comparing it with the amount of items we have processed. If it is less, there will be a message on the download page asking the user to click to refresh the page. That should give it enough time to process the rest of the items. We were going to do an auto refresh, but that creates issues with mixed baskets of goods as num_cart_items would always be higher than the number of goods processed in the system.
Like I said, it affects one in every 2,000 orders, but those are big orders by bigger sellers, so we want to keep them happy :)