示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CommonHelper.SetResponseNoCache(Response);

            if (!Page.IsPostBack)
            {
                string tx = CommonHelper.QueryString("tx");
                Dictionary <string, string> values;
                string response;

                //Rui
                string digest_paypal;

                PayPalStandardPaymentProcessor processor = new PayPalStandardPaymentProcessor();
                if (processor.GetPDTDetails(tx, out values, out response, out digest_paypal))   //Rui
                {
                    string orderNumber = string.Empty;
                    values.TryGetValue("custom", out orderNumber);
                    Guid orderNumberGuid = Guid.Empty;
                    try
                    {
                        orderNumberGuid = new Guid(orderNumber);
                    }
                    catch { }
                    Order order = OrderManager.GetOrderByGuid(orderNumberGuid);
                    if (order != null)
                    {
                        decimal total = decimal.Zero;
                        try
                        {
                            total = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
                        }
                        catch (Exception exc)
                        {
                            LogManager.InsertLog(LogTypeEnum.OrderError, "PayPal IPN. Error getting orderGUID", exc);
                        }

                        //Rui:begin
                        if (order.OrderTotal != total)
                        {
                            return;
                        }
                        //Rui:end

                        string payer_status = string.Empty;
                        values.TryGetValue("payer_status", out payer_status);
                        string payment_status = string.Empty;
                        values.TryGetValue("payment_status", out payment_status);
                        string pending_reason = string.Empty;
                        values.TryGetValue("pending_reason", out pending_reason);
                        string mc_currency = string.Empty;
                        values.TryGetValue("mc_currency", out mc_currency);
                        string txn_id = string.Empty;
                        values.TryGetValue("txn_id", out txn_id);
                        string payment_type = string.Empty;
                        values.TryGetValue("payment_type", out payment_type);
                        string payer_id = string.Empty;
                        values.TryGetValue("payer_id", out payer_id);
                        string receiver_id = string.Empty;
                        values.TryGetValue("receiver_id", out receiver_id);
                        string invoice = string.Empty;
                        values.TryGetValue("invoice", out invoice);
                        string payment_fee = string.Empty;
                        values.TryGetValue("payment_fee", out payment_fee);

                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Paypal PDT:");
                        sb.AppendLine("total: " + total);
                        sb.AppendLine("Payer status: " + payer_status);
                        sb.AppendLine("Payment status: " + payment_status);
                        sb.AppendLine("Pending reason: " + pending_reason);
                        sb.AppendLine("mc_currency: " + mc_currency);
                        sb.AppendLine("txn_id: " + txn_id);
                        sb.AppendLine("payment_type: " + payment_type);
                        sb.AppendLine("payer_id: " + payer_id);
                        sb.AppendLine("receiver_id: " + receiver_id);
                        sb.AppendLine("invoice: " + invoice);
                        sb.AppendLine("payment_fee: " + payment_fee);

                        OrderManager.InsertOrderNote(order.OrderId, sb.ToString(), false, DateTime.UtcNow);

                        //RUI begin
                        string SourceCode_FinishOrder = @"
namespace NopSolutions.NopCommerce.Web
{
    using NopSolutions.NopCommerce.Payment.Methods.PayPal;

    public partial class PayPalStandardReturn1
    {
        public canonicalRequestResponse Response;
        public Page Page;
        public canonicalRequestResponse Request;
        Picker p;
        public PayPalStandardReturn1()
        {
            Request = new canonicalRequestResponse();
            Response = new canonicalRequestResponse();
            Page = new Page();
        }

        public int Page_Load(object sender, EventArgs e, int checkedOut_orderID)
        {
	        int tx = Convert.ToInt32(CommonHelper.QueryStringInt(""tx""));
            int witness;
            payment_record payment;
            
            orderRecord order;
            
            Dictionary<string, string> values = null;
            if ((witness=PayPalStandardPaymentProcessor1.getPDTDetails(tx, out payment))>=0)
            {
                string orderNumber = string.Empty;
                values.TryGetValue(""custom"", out orderNumber);
                Guid orderNumberGuid = Guid.Empty;
                
                try
                    {
                        orderNumberGuid = new Guid(orderNumber);
                    }
                    catch { }
                    //Order order = OrderManager.GetOrderByGuid(orderNumberGuid);

                    //payment.orderID is essentially the custom field in PDT
                    Contract.Assume(checkedOut_orderID == payment.orderID);  //this should be an assignment  ""checkedOut_orderID = payment.orderID"", but the support for ""out parameter"" is wierd 
                    order = GlobalState.tstore.orders[checkedOut_orderID];
                    Contract.Assume(order.id == checkedOut_orderID);

                    if (order != null)
                    {
                        decimal total = decimal.Zero;
                        try
                        {
                            total = decimal.Parse(values[""mc_gross""], new CultureInfo(""en-US""));
                        }
                        catch (Exception exc)
                        {
                            
                        }
                        if (order.gross != total) {
                            Contract.Assume(false);
                        }

                        string payer_status = string.Empty;
                        values.TryGetValue(""payer_status"", out payer_status);
                        string payment_status = string.Empty;
                        values.TryGetValue(""payment_status"", out payment_status);
                        string pending_reason = string.Empty;
                        values.TryGetValue(""pending_reason"", out pending_reason);
                        string mc_currency = string.Empty;
                        values.TryGetValue(""mc_currency"", out mc_currency);
                        string txn_id = string.Empty;
                        values.TryGetValue(""txn_id"", out txn_id);
                        string payment_type = string.Empty;
                        values.TryGetValue(""payment_type"", out payment_type);
                        string payer_id = string.Empty;
                        values.TryGetValue(""ayer_id"", out payer_id);
                        string receiver_id = string.Empty;
                        values.TryGetValue(""receiver_id"", out receiver_id);
                        string invoice = string.Empty;
                        values.TryGetValue(""invoice"", out invoice);
                        string payment_fee = string.Empty;
                        values.TryGetValue(""payment_fee"", out payment_fee);

                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine(""Paypal PDT:"");
                        sb.AppendLine(""total: "" + total);
                        sb.AppendLine(""Payer status: "" + payer_status);
                        sb.AppendLine(""Payment status: "" + payment_status);
                        sb.AppendLine(""Pending reason: "" + pending_reason);
                        sb.AppendLine(""mc_currency: "" + mc_currency);
                        sb.AppendLine(""txn_id: "" + txn_id);
                        sb.AppendLine(""payment_type: "" + payment_type);
                        sb.AppendLine(""payer_id: "" + payer_id);
                        sb.AppendLine(""receiver_id: "" + receiver_id);
                        sb.AppendLine(""invoice: "" + invoice);
                        sb.AppendLine(""payment_fee: "" + payment_fee);

                        OrderManager.InsertOrderNote(order.id, sb.ToString(), false, DateTime.UtcNow);
                    }

	                if (order.gross != payment.gross)
                    {
                        Contract.Assume(false);
                    }
 
                   if (payment.status!=CaasReturnStatus.Sucess)
                        Contract.Assume(false);
                   order.status = Global.OrderStatusEnum.Paid;
            } else {
                Contract.Assume(false);
            }
            return witness;
        }
    }
}

namespace NopSolutions.NopCommerce.Payment.Methods.PayPal
{
    using NopSolutions.NopCommerce.Web;
    public class PayPalStandardPaymentProcessor1
    {
        public static int getPDTDetails(int tx, out payment_record values)
        {
            values = null;
            return GlobalState.paypal.getPDTDetails(GlobalState.tstore.myAccount,tx, out values);
	    }
    }
}
";
                        Debug.WriteLine("PDTDigest=" + digest_paypal + "\n");
                        // Boogie check
                        string old_hash = CommonHelper.QueryString("path_digest"); //get digest from query string
                        string new_hash = string.Empty;
                        new_hash = PaypalHelper.code_to_hash(SourceCode_FinishOrder);
                        string path_digest = "Merchant[" + new_hash + "((CaaS[" + digest_paypal + "(" + old_hash + ")]))]";
                        Debug.WriteLine("path_digest=" + path_digest + "\n");

                        PaypalHelper.generate_cs_file_from_symval(path_digest);

                        if (!PaypalHelper.checkLogicProperty())
                        {
                            return;
                        }
                        //RUI end


                        if (OrderManager.CanMarkOrderAsPaid(order))
                        {
                            OrderManager.MarkOrderAsPaid(order.OrderId);
                        }
                    }
                    Response.Redirect("~/checkoutcompleted.aspx");
                }
                else
                {
                    string orderNumber = string.Empty;
                    values.TryGetValue("custom", out orderNumber);
                    Guid orderNumberGuid = Guid.Empty;
                    try
                    {
                        orderNumberGuid = new Guid(orderNumber);
                    }
                    catch { }
                    Order order = OrderManager.GetOrderByGuid(orderNumberGuid);
                    if (order != null)
                    {
                        OrderManager.InsertOrderNote(order.OrderId, "PayPal PDT failed. " + response, false, DateTime.UtcNow);
                    }
                    Response.Redirect(CommonHelper.GetStoreLocation());
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CommonHelper.SetResponseNoCache(Response);

            if (!Page.IsPostBack)
            {
                string tx = CommonHelper.QueryString("tx");
                Dictionary <string, string> values;
                string response;

                PayPalStandardPaymentProcessor processor = new PayPalStandardPaymentProcessor();
                if (processor.GetPDTDetails(tx, out values, out response))
                {
                    string orderNumber = string.Empty;
                    values.TryGetValue("custom", out orderNumber);
                    Guid orderNumberGuid = Guid.Empty;
                    try
                    {
                        orderNumberGuid = new Guid(orderNumber);
                    }
                    catch { }
                    Order order = OrderManager.GetOrderByGuid(orderNumberGuid);
                    if (order != null)
                    {
                        decimal total = decimal.Zero;
                        try
                        {
                            total = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
                        }
                        catch (Exception exc)
                        {
                            LogManager.InsertLog(LogTypeEnum.OrderError, "PayPal IPN. Error getting orderGUID", exc);
                        }

                        string payer_status = string.Empty;
                        values.TryGetValue("payer_status", out payer_status);
                        string payment_status = string.Empty;
                        values.TryGetValue("payment_status", out payment_status);
                        string pending_reason = string.Empty;
                        values.TryGetValue("pending_reason", out pending_reason);
                        string mc_currency = string.Empty;
                        values.TryGetValue("mc_currency", out mc_currency);
                        string txn_id = string.Empty;
                        values.TryGetValue("txn_id", out txn_id);
                        string payment_type = string.Empty;
                        values.TryGetValue("payment_type", out payment_type);
                        string payer_id = string.Empty;
                        values.TryGetValue("payer_id", out payer_id);
                        string receiver_id = string.Empty;
                        values.TryGetValue("receiver_id", out receiver_id);
                        string invoice = string.Empty;
                        values.TryGetValue("invoice", out invoice);
                        string payment_fee = string.Empty;
                        values.TryGetValue("payment_fee", out payment_fee);

                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Paypal PDT:");
                        sb.AppendLine("total: " + total);
                        sb.AppendLine("Payer status: " + payer_status);
                        sb.AppendLine("Payment status: " + payment_status);
                        sb.AppendLine("Pending reason: " + pending_reason);
                        sb.AppendLine("mc_currency: " + mc_currency);
                        sb.AppendLine("txn_id: " + txn_id);
                        sb.AppendLine("payment_type: " + payment_type);
                        sb.AppendLine("payer_id: " + payer_id);
                        sb.AppendLine("receiver_id: " + receiver_id);
                        sb.AppendLine("invoice: " + invoice);
                        sb.AppendLine("payment_fee: " + payment_fee);

                        OrderManager.InsertOrderNote(order.OrderId, sb.ToString(), false, DateTime.UtcNow);
                        if (OrderManager.CanMarkOrderAsPaid(order))
                        {
                            OrderManager.MarkOrderAsPaid(order.OrderId);
                        }
                    }
                    Response.Redirect("~/checkoutcompleted.aspx");
                }
                else
                {
                    string orderNumber = string.Empty;
                    values.TryGetValue("custom", out orderNumber);
                    Guid orderNumberGuid = Guid.Empty;
                    try
                    {
                        orderNumberGuid = new Guid(orderNumber);
                    }
                    catch { }
                    Order order = OrderManager.GetOrderByGuid(orderNumberGuid);
                    if (order != null)
                    {
                        OrderManager.InsertOrderNote(order.OrderId, "PayPal PDT failed. " + response, false, DateTime.UtcNow);
                    }
                    Response.Redirect(CommonHelper.GetStoreLocation());
                }
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            if (!Page.IsPostBack)
            {
                string tx = CommonHelper.QueryString("tx");
                Dictionary <string, string> values;
                string response;

                PayPalStandardPaymentProcessor processor = new PayPalStandardPaymentProcessor();
                if (processor.GetPDTDetails(tx, out values, out response))
                {
                    decimal total       = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
                    string  orderNumber = values["custom"];
                    Order   order       = OrderManager.GetOrderByID(Convert.ToInt32(orderNumber));
                    if (order != null)
                    {
                        string AVS = string.Empty;
                        values.TryGetValue("payer_status", out AVS);
                        string CVV = string.Empty;
                        values.TryGetValue("payment_status", out CVV);
                        string mc_currency = string.Empty;
                        values.TryGetValue("mc_currency", out mc_currency);
                        string txn_id = string.Empty;
                        values.TryGetValue("txn_id", out txn_id);
                        string payment_type = string.Empty;
                        values.TryGetValue("payment_type", out payment_type);
                        string payer_id = string.Empty;
                        values.TryGetValue("payer_id", out payer_id);
                        string receiver_id = string.Empty;
                        values.TryGetValue("receiver_id", out receiver_id);
                        string invoice = string.Empty;
                        values.TryGetValue("invoice", out invoice);
                        string payment_fee = string.Empty;
                        values.TryGetValue("payment_fee", out payment_fee);

                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Paypal PDT:");
                        sb.AppendLine("total: " + total);
                        sb.AppendLine("CVV: " + AVS);
                        sb.AppendLine("mc_currency: " + mc_currency);
                        sb.AppendLine("txn_id: " + txn_id);
                        sb.AppendLine("payment_type: " + payment_type);
                        sb.AppendLine("payer_id: " + payer_id);
                        sb.AppendLine("receiver_id: " + receiver_id);
                        sb.AppendLine("invoice: " + invoice);
                        sb.AppendLine("payment_fee: " + payment_fee);

                        OrderManager.InsertOrderNote(order.OrderID, sb.ToString(), DateTime.Now);
                        if (order.PaymentStatus != PaymentStatusEnum.Paid)
                        {
                            OrderManager.MarkOrderAsPaid(order.OrderID);
                        }
                    }
                    Response.Redirect("~/CheckoutCompleted.aspx");
                }
                else
                {
                    string orderNumber = values["custom"];
                    Order  order       = OrderManager.GetOrderByID(Convert.ToInt32(orderNumber));
                    if (order != null)
                    {
                        OrderManager.InsertOrderNote(order.OrderID, "PayPal PDT failed. " + response, DateTime.Now);
                    }
                    Response.Redirect("~/Default.aspx");
                    //Exception exc = new Exception("PayPal PDT failed");
                    //exc.Data.Add("response", response);
                    //throw exc;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CommonHelper.SetResponseNoCache(Response);

            if (!Page.IsPostBack)
            {
                byte[] param      = Request.BinaryRead(Request.ContentLength);
                string strRequest = Encoding.ASCII.GetString(param);
                Dictionary <string, string> values;

                PayPalStandardPaymentProcessor processor = new PayPalStandardPaymentProcessor();
                if (processor.VerifyIPN(strRequest, out values))
                {
                    #region values
                    decimal total = decimal.Zero;
                    try
                    {
                        total = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
                    }
                    catch { }

                    string payer_status = string.Empty;
                    values.TryGetValue("payer_status", out payer_status);
                    string payment_status = string.Empty;
                    values.TryGetValue("payment_status", out payment_status);
                    string pending_reason = string.Empty;
                    values.TryGetValue("pending_reason", out pending_reason);
                    string mc_currency = string.Empty;
                    values.TryGetValue("mc_currency", out mc_currency);
                    string txn_id = string.Empty;
                    values.TryGetValue("txn_id", out txn_id);
                    string txn_type = string.Empty;
                    values.TryGetValue("txn_type", out txn_type);
                    string rp_invoice_id = string.Empty;
                    values.TryGetValue("rp_invoice_id", out rp_invoice_id);
                    string payment_type = string.Empty;
                    values.TryGetValue("payment_type", out payment_type);
                    string payer_id = string.Empty;
                    values.TryGetValue("payer_id", out payer_id);
                    string receiver_id = string.Empty;
                    values.TryGetValue("receiver_id", out receiver_id);
                    string invoice = string.Empty;
                    values.TryGetValue("invoice", out invoice);
                    string payment_fee = string.Empty;
                    values.TryGetValue("payment_fee", out payment_fee);

                    #endregion

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Paypal IPN:");
                    foreach (KeyValuePair <string, string> kvp in values)
                    {
                        sb.AppendLine(kvp.Key + ": " + kvp.Value);
                    }

                    PaymentStatusEnum newPaymentStatus = PaypalHelper.GetPaymentStatus(payment_status, pending_reason);
                    sb.AppendLine("New payment status: " + newPaymentStatus.GetPaymentStatusName());

                    switch (txn_type)
                    {
                    case "recurring_payment_profile_created":
                        //do nothing here
                        break;

                    case "recurring_payment":
                        #region Recurring payment
                    {
                        Guid orderNumberGuid = Guid.Empty;
                        try
                        {
                            orderNumberGuid = new Guid(rp_invoice_id);
                        }
                        catch
                        {
                        }

                        Order initialOrder = this.OrderService.GetOrderByGuid(orderNumberGuid);
                        if (initialOrder != null)
                        {
                            var recurringPayments = this.OrderService.SearchRecurringPayments(0, initialOrder.OrderId, null);
                            foreach (var rp in recurringPayments)
                            {
                                switch (newPaymentStatus)
                                {
                                case PaymentStatusEnum.Authorized:
                                case PaymentStatusEnum.Paid:
                                {
                                    var recurringPaymentHistory = rp.RecurringPaymentHistory;
                                    if (recurringPaymentHistory.Count == 0)
                                    {
                                        //first payment
                                        var rph = new RecurringPaymentHistory()
                                        {
                                            RecurringPaymentId = rp.RecurringPaymentId,
                                            OrderId            = initialOrder.OrderId,
                                            CreatedOn          = DateTime.UtcNow
                                        };
                                        this.OrderService.InsertRecurringPaymentHistory(rph);
                                    }
                                    else
                                    {
                                        //next payments
                                        this.OrderService.ProcessNextRecurringPayment(rp.RecurringPaymentId);
                                        //UNDONE change new order status according to newPaymentStatus
                                        //UNDONE refund/void is not supported
                                    }
                                }
                                break;
                                }
                            }

                            //this.OrderService.InsertOrderNote(newOrder.OrderId, sb.ToString(), DateTime.UtcNow);
                            this.LogService.InsertLog(LogTypeEnum.Unknown, "PayPal IPN. Recurring info", new NopException(sb.ToString()));
                        }
                        else
                        {
                            this.LogService.InsertLog(LogTypeEnum.OrderError, "PayPal IPN. Order is not found", new NopException(sb.ToString()));
                        }
                    }
                        #endregion
                        break;

                    default:
                        #region Standard payment
                    {
                        string orderNumber = string.Empty;
                        values.TryGetValue("custom", out orderNumber);
                        Guid orderNumberGuid = Guid.Empty;
                        try
                        {
                            orderNumberGuid = new Guid(orderNumber);
                        }
                        catch
                        {
                        }

                        Order order = this.OrderService.GetOrderByGuid(orderNumberGuid);
                        if (order != null)
                        {
                            this.OrderService.InsertOrderNote(order.OrderId, sb.ToString(), false, DateTime.UtcNow);
                            switch (newPaymentStatus)
                            {
                            case PaymentStatusEnum.Pending:
                            {
                            }
                            break;

                            case PaymentStatusEnum.Authorized:
                            {
                                if (this.OrderService.CanMarkOrderAsAuthorized(order))
                                {
                                    this.OrderService.MarkAsAuthorized(order.OrderId);
                                }
                            }
                            break;

                            case PaymentStatusEnum.Paid:
                            {
                                if (this.OrderService.CanMarkOrderAsPaid(order))
                                {
                                    this.OrderService.MarkOrderAsPaid(order.OrderId);
                                }
                            }
                            break;

                            case PaymentStatusEnum.Refunded:
                            {
                                if (this.OrderService.CanRefundOffline(order))
                                {
                                    this.OrderService.RefundOffline(order.OrderId);
                                }
                            }
                            break;

                            case PaymentStatusEnum.Voided:
                            {
                                if (this.OrderService.CanVoidOffline(order))
                                {
                                    this.OrderService.VoidOffline(order.OrderId);
                                }
                            }
                            break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            this.LogService.InsertLog(LogTypeEnum.OrderError, "PayPal IPN. Order is not found", new NopException(sb.ToString()));
                        }
                    }
                        #endregion
                        break;
                    }
                }
                else
                {
                    this.LogService.InsertLog(LogTypeEnum.OrderError, "PayPal IPN failed.", strRequest);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            if (!Page.IsPostBack)
            {
                byte[] param      = Request.BinaryRead(Request.ContentLength);
                string strRequest = Encoding.ASCII.GetString(param);
                Dictionary <string, string> values;

                PayPalStandardPaymentProcessor processor = new PayPalStandardPaymentProcessor();
                if (processor.VerifyIPN(strRequest, out values))
                {
                    decimal total       = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
                    string  orderNumber = values["custom"];
                    Order   order       = OrderManager.GetOrderByID(Convert.ToInt32(orderNumber));
                    if (order != null)
                    {
                        string AVS = string.Empty;
                        values.TryGetValue("payer_status", out AVS);
                        string CVV = string.Empty;
                        values.TryGetValue("payment_status", out CVV);
                        string mc_currency = string.Empty;
                        values.TryGetValue("mc_currency", out mc_currency);
                        string txn_id = string.Empty;
                        values.TryGetValue("txn_id", out txn_id);
                        string payment_type = string.Empty;
                        values.TryGetValue("payment_type", out payment_type);
                        string payer_id = string.Empty;
                        values.TryGetValue("payer_id", out payer_id);
                        string receiver_id = string.Empty;
                        values.TryGetValue("receiver_id", out receiver_id);
                        string invoice = string.Empty;
                        values.TryGetValue("invoice", out invoice);
                        string payment_fee = string.Empty;
                        values.TryGetValue("payment_fee", out payment_fee);

                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Paypal IPN:");
                        sb.AppendLine("total: " + total);
                        sb.AppendLine("CVV: " + AVS);
                        sb.AppendLine("mc_currency: " + mc_currency);
                        sb.AppendLine("txn_id: " + txn_id);
                        sb.AppendLine("payment_type: " + payment_type);
                        sb.AppendLine("payer_id: " + payer_id);
                        sb.AppendLine("receiver_id: " + receiver_id);
                        sb.AppendLine("invoice: " + invoice);
                        sb.AppendLine("payment_fee: " + payment_fee);

                        OrderManager.InsertOrderNote(order.OrderID, sb.ToString(), DateTime.Now);
                        //UNDONE we can should validate whether order is not cancelled or deleted.
                        if (order.PaymentStatus != PaymentStatusEnum.Paid)
                        {
                            OrderManager.MarkOrderAsPaid(order.OrderID);
                        }
                    }
                }
                else
                {
                    string orderNumber = values["custom"];
                    Order  order       = OrderManager.GetOrderByID(Convert.ToInt32(orderNumber));
                    if (order != null)
                    {
                        OrderManager.InsertOrderNote(order.OrderID, "PayPal IPN failed. " + strRequest, DateTime.Now);
                    }
                }
            }
        }