When using paypal on magento there are two clear choices, standard and express.
Its quite confusing the differences actually between them, but one of the main differences is that paypal standard completes the order straight away at the point of redirecting to paypal whereas express doesnt.
This essentially means that a users basket gets cleared using paypal standard at the point of transfer to paypal and if they click back they will not have basket.
At which exact point in the code is this occurring?
I can see the two payment methods in magento:
app\code\core\Mage\Paypal\Model\Express.php
and
app\code\core\Mage\Paypal\Model\Standard.php
but i cannot see where magento allows express to keep the order ongoing
The actual flow between Express and Standard is different…
PayPal Express
User gets redirected to PayPal directly after the payment method has been chosen (and obviously before the order has been completed). They return to the site to complete the order after authorising payment with PayPal.
PayPal Standard
User goes through entire checkout process and completes the order on site. They then get redirected to PayPal to sort out payment. They do not need to come back to the site to complete the order as it has already been completed before redirecting to PayPal. This is why you see the empty basket if you return to the site regardless of whether you pay at PayPal or not – the quote has already been converted to an order.
So in this sense PayPal express is essentially checkout method and PayPal standard is a payment method.
With regards to the exact place in code that this all happens…
PayPal Express
Uses the getCheckoutRedirectUrl() method which gets called in the savePayment() action of Mage_Checkout_OnepageController – so you get redirected before the order is completed as described above.
PayPal Standard
Uses the getOrderPlaceRedirectUrl() which gets called in the saveOrder() method of Mage_Checkout_Model_Type_Onepage
Please see the links for exact code points that everything happens.