I am implementing a site in nopCommerce 1.50 and I found that the order is actually placed before the payment.
Debugging, I found that OrderManager.PlaceOrder is called before PaymentManager.PostProcessPayment. PlaceOrder method, besides storing the order in database, sends e-mail notifications and clears the shopping cart.
When the payment processor calls a gateway (for example, PayPal), it is called from PostProcessPayment, so the notifications and the shopping cart clear should be carried out after it, when the payment was successful.
Hello... I simply commented the lines that clears the shopping cart.
So the process is: before payment, the order is saved in Pending status, then the gateway is called, the payment is carried out, the return page is called if successful. Finally, the shopping cart is cleared, the order changes status to Processing and Paid, and the notifications are sent.
// Si el pago está pendiente, no se debe eliminar el carro ni tampoco se debe // descontar inventario. // Ese hecho sólo debe ocurrir cuando la orden esté PAGADA if (processPaymentResult.PaymentStatus == PaymentStatusEnum.Paid) { ShoppingCartManager.DeleteShoppingCartItem(sc.ShoppingCartItemID, false);