Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null reference in log #10

Open
bjarnef opened this issue May 14, 2018 · 0 comments
Open

Null reference in log #10

bjarnef opened this issue May 14, 2018 · 0 comments

Comments

@bjarnef
Copy link

bjarnef commented May 14, 2018

When test mode is enabled and "cancel test orders" is enabled, it returns a null exception in the log file.

System.NullReferenceException: Object reference not set to an instance of an object.
   at Pragmasoft.QuickpayV10.Extensions.Services.QuickpayV10PaymentMethodService.ProcessCallback(Payment payment)
05/14/2018 09:50:47: Exception: 
System.NullReferenceException: Object reference not set to an instance of an object.
   at Pragmasoft.QuickpayV10.Extensions.Services.QuickpayV10PaymentMethodService.ProcessCallback(Payment payment)
05/14/2018 09:56:45: Exception: 
System.NullReferenceException: Object reference not set to an instance of an object.
   at Pragmasoft.QuickpayV10.Extensions.Services.QuickpayV10PaymentMethodService.ProcessCallback(Payment payment)
05/14/2018 10:08:48: Exception: 
System.NullReferenceException: Object reference not set to an instance of an object.
   at Pragmasoft.QuickpayV10.Extensions.Services.QuickpayV10PaymentMethodService.ProcessCallback(Payment payment)
05/14/2018 10:11:57: Order () was canceled because the payment was in testmode.

if (callbackObject.test_mode && paymentProperties.CancelTestCardOrders)
{
_quickpayRepository.ChangeOrderStatus(payment, "Cancelled",
PaymentStatus.Get((int)PaymentStatusCode.Cancelled));
_logger.Log("Order (" + payment.PurchaseOrder.OrderNumber + ") was canceled because the payment was in testmode.");
return;
}

The OrderNumber property on PurchaseOrder is null until the OrderNumber is assigned at last in the Checkout pipeline in the UCommerce core pipeline tasks.

Also I am not sure if OrderNumber is available here:

{
_logger.Log("Payment for order '" + payment.PurchaseOrder.OrderNumber + "' not validated");
payment.PaymentStatus = PaymentStatus.Get((int)PaymentStatusCode.Declined);
payment.Save(); //Save payment to ensure transactionId not lost.

I think Checkout pipeline (or another pipeline) selected on the payment method first is executed on payment success callback, so if something fails in the payment, it doesn't continue to Checkout pipeline, where the OrderNumber by default is assigned.

From UCommerce Basket.Checkout.config

<!-- Pipeline Instance -->
		<component id="Checkout"
				   service="UCommerce.Pipelines.IPipeline`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce"
				   type="UCommerce.Pipelines.Transactions.Baskets.Checkout.CheckoutPipeline, UCommerce.Pipelines">
			<parameters>
				<tasks>
					<array>
						<value>${Checkout.ValidatePaymentsMadeAgainstOrderTotal}</value>
						<value>${Checkout.AssignOrderNumber}</value>
						<value>${Checkout.CreateCustomer}</value>
						<value>${Checkout.CreateMemberForCustomer}</value>
						<value>${Checkout.ConvertBasketToPurchaseOrder}</value>
						<value>${Checkout.AddAuditTrailForCurrentOrderStatus}</value>
						<value>${Checkout.SetVoucherUses}</value>
						<value>${Checkout.ClearBasketInformation}</value>
						<value>${Checkout.SavePurchaseOrder}</value>
						<value>${Checkout.SendConfirmationEmail}</value>
					</array>
				</tasks>
			</parameters>
		</component> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant