Try our conversational search powered by Generative AI!

How to remove purchaseorder from orderrepository when payment fails?


I have a thiry party payment gateway. When payment fails, i delete order reference from orderrepository. But purchnase order is still there in orderrepository. How to remove purchaseorder from orderrepository? My code is as shown below. purchnase order is showing line items.

if (paymentResponse.ResultCode != PaymentsResponse.ResultCodeEnum.Authorised)

var purchaseOrders = _orderRepository.Load<IPurchaseOrder>(_customerContext.CurrentContactId)
                                             .OrderByDescending(x => x.Created)

Aug 16, 2019 6:22

Could you do 


after you've deleted your order? Right now you're loading the customer's purchase orders, so if the customer had previous orders, you'll see them and not the one you deleted.

Aug 16, 2019 7:05

_orderRepository.Delete(orderReference); is the correct code to delete the order, but only if you pass the correct orderReference. Where does your orderReference point to?

Aug 16, 2019 9:31
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.