I've noticed that when the user clicks the final confirm button when checking out, the order is placed in the database (with a payment status of 'pending') and the items are removed from their shopping carts. The issue I've found with this is that if the user then closes the paypal window or there is an error somewhere along the line, nopCommerce shows them having an empty cart (typically indicating that they have purchased the items that were previously in it) and they have to then choose their items again and create a new order, leaving the previous "pending" order in the database and viewable from the administration console until the order is manually deleted.

My question is, is it possible to either:
a) Create the order in the database and empty the shopping cart AFTER payment has been received (and set the payment status automatically to "paid")
or (possibly more likely)
b) Create the order when the user clicks checkout but only empty the cart after payment has been received AND if payment isn't received (the website doesn't get the confirmation from paypal that the order has been paid for), delete the "pending" order from the database.

My eternal thanks to anyone who can help me with this, I've really been wracking my brains on it.

EDIT: I did notice in Nop.BusinessLogic.OrderService.PlaceOrder(...) (the method that gets called when the cart is checked out), the code creates an Order object and then calls "InsertOrder(order)" which places it in the database. Would it be possible to call that "InsertOrder(order)" after payment has been made, or would that break all the subsequent references to the order?