I'm seeing a lot of these errors in the Umbraco log but not sure what is causing the issue.
2015-04-28 10:00:36,075 [8] ERROR Umbraco.Core.UmbracoApplicationBase - [Thread 37] An unhandled exception occurred
System.NullReferenceException: Could not find the Payment with PaymentId: '462' or PaymentGuid: ''.
at UCommerce.Transactions.Payments.UrlPaymentExtractor.Extract(HttpRequest httpRequest)
at UCommerce.Transactions.Payments.GenericPaymentHandler.Execute(HttpContext context, IPaymentWindow& paymentWindow, Payment& payment)
at UCommerce.Transactions.Payments.PaymentProcessor.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Basically it seems what is happening is when an order is placed, the payment ID that is being passed to SagePay is different from the one that is finally saved in the database against the order. In this example, the order that was placed actually has a payment in [uCommerce_Payment] with ID of 468 somehow, not 462.
Here is the code that requests the payment:
var sagePay = TransactionLibrary.GetPaymentMethods(country).FirstOrDefault(x => x.Name == "SagePay" && x.Enabled);
var payment = TransactionLibrary.CreatePayment(sagePay.Id, (decimal)order.OrderTotal, false);
Session["orderId"] = _orderService.GetBasket().OrderId;
TransactionLibrary.RequestPayment(payment.Id);
This strongly indicates that CreatePayment is being called multiple times, before the response from SagePay returns, converting the basket to an actual order.
Perhaps you can log calls to CreatePayment and RequestPayment?
Incidentally, you can get the purchase order like this, instead of using your _orderService:
Could not find the Payment with PaymentId
Hi guys,
I'm seeing a lot of these errors in the Umbraco log but not sure what is causing the issue.
Basically it seems what is happening is when an order is placed, the payment ID that is being passed to SagePay is different from the one that is finally saved in the database against the order. In this example, the order that was placed actually has a payment in [uCommerce_Payment] with ID of 468 somehow, not 462.
Here is the code that requests the payment:
Any pointers would be much appreciated.
Thanks, Craig
Hello Craig,
This strongly indicates that CreatePayment is being called multiple times, before the response from SagePay returns, converting the basket to an actual order.
Perhaps you can log calls to CreatePayment and RequestPayment?
Incidentally, you can get the purchase order like this, instead of using your _orderService:
What version of uCommerce are you running?
Kind regards,
Jesper
is working on a reply...