How to access current order after payment gateway redirection to "returnPage"

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
Hi,

When a user is redirected to return page by the payment gateway, I would like to access to access the customer Order properties.

The Payment Gateway doesn't send back parameters I sent.

How should I access current order?

Regards
13 年 前
You could do it the same as CheckoutCompleted.ascx which finds the last order and displays it as completed.

I have not used it because my method returns the order number but here is the rest of my return.aspx code that writes to the order and to illustrate the idea I slotted the code from CheckoutCompleted.ascx in down below
I haven’t tested but think it should work ??

//* In return.aspx - data returned with no error - store the returned data in the order                  
//  I could have just put the return values in the order directly below but decided to handle in the OrderManager with a new MarkOrderAsPaid routine

                    ProcessPaymentResult ProcessPaymentResult = new ProcessPaymentResult();
                    ProcessPaymentResult.AuthorizationTransactionCode = acqResponseCode;
                    ProcessPaymentResult.AuthorizationTransactionId = authorizeID;
                    ProcessPaymentResult.AuthorizationTransactionResult = receiptNo;
                    // I also did this ProcessPaymentResult.CardType = cardType; // added new variable to ProcessPaymentResult to hold card type
                    ProcessPaymentResult.CaptureTransactionId = transactionNr;
                    ProcessPaymentResult.CaptureTransactionResult = receiptNo;

                    // code from CheckoutCompleted.ascx
                    var orderCollection = NopContext.Current.User.Orders;
                    if (orderCollection.Count == 0)
                    {
                        Response.Redirect(CommonHelper.GetStoreLocation());
                    }
                    else
                    {
                        var lastOrder = orderCollection[0];

                        Order order = OrderManager.GetOrderById(Convert.ToInt32(lastOrder.OrderId));
                        if (order == null)
                            throw new NopException(string.Format("The order ID {0} doesn't exists", orderInfo));

                        if (order.CustomerId != NopContext.Current.User.CustomerId)
                            throw new NopException("Not your order");

                        if (OrderManager.CanMarkOrderAsPaid(lastOrder))
                        {
                            OrderManager.MarkOrderAsPaid(order, ProcessPaymentResult, OrderStatusEnum.Complete);
                        }

                        Response.Redirect("~/CheckoutCompleted.aspx");
                    }

Note: I also create a new MarkOrderAsPaid that takes the payment status, result and the order
13 年 前
Thank you man. That helped a lot
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.