Payment module Nop 2.0 orderNumberGuid fails

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 12 ans
I´m trying to make a new payment module for Nop 2.0, but I have problems to get the order from the ordernumber.
For testing I set the correct ordernumber manually, at order 45 I set it to "45", but it always fails in the catch Exception orderNumberGuid = new Guid(orderNumber)... I´m stuck on this so please advise.
I leave the site for the Payment site and when payment is done, I go back to my site.
Leaving the Exception out then I get a servererror.



[ValidateInput(false)]
        public ActionResult PAYHandler(FormCollection form)
        {
            string tx = _webHelper.QueryString<string>("tx");
            var processor = _paymentService.LoadPaymentMethodBySystemName("Payments.ewire") as ewirePaymentProcessor;
            if (processor == null ||
                !processor.IsPaymentMethodActive(_paymentSettings) || !processor.PluginDescriptor.Installed)
                throw new NopException("Fejl, ewire modulet kan ikke indlæses!");

            var sb = new StringBuilder();
                string orderNumber = string.Empty;
                string orderNumber2 = string.Empty;
                // Find orderNumber
                string tempStr = tx;
                //int startindex = tempStr.IndexOf("customerOrderId=") + 16;
                //int endIndex = tempStr.IndexOf("&validateMD");
                //orderNumber2 = tempStr.Substring(startindex, endIndex - startindex);
     *          orderNumber = "45"; I MANUALLY SET THE CORRECT ORDERNUMBER EACH TIME FOR FAULTFINDING

               //values.TryGetValue("customerOrderId", out orderNumber);
            
                Guid orderNumberGuid = Guid.Empty;
                try
                {
     *               orderNumberGuid = new Guid(orderNumber); THIS MUST FAIL AS THE CODE AFTER IS NOT EXECUTED
                }
                catch { }
     *         Order order = _orderService.GetOrderByGuid(orderNumberGuid); THIS IS NOT EXECUTED!
Il y a 12 ans
TCH wrote:

orderNumber = "45"; I MANUALLY SET THE CORRECT ORDERNUMBER EACH TIME FOR FAULTFINDING

orderNumberGuid = new Guid(orderNumber); THIS MUST FAIL AS THE CODE AFTER IS NOT EXECUTED

You're set "orderNumber" to 45, but then you're trying to convert it to Guid. That's the problem.
Il y a 12 ans
Thanks Andrei

I got that wrong in the late hours.
instead of  Order order = _orderService.GetOrderByGuid(orderNumberGuid);
it should be  var order = _orderService.GetOrderById(orderNumber);

That worked perfectly :-)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.