protected void Page_Load(object sender, EventArgs e)
        {
            // Verify user has completed the checkout process.
            if ((string)Session["userCheckoutCompleted"] != "true")
            {
                Session["userCheckoutCompleted"] = string.Empty;
                Response.Redirect("CheckoutError.aspx?" + "Desc=Unvalidated%20Checkout.");
            }

            string finalPaymentAmount = "";
            string PayerID            = "";

            //bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg);
            if (true)
            {
                // Clear shopping cart.
                using (WingtipToys.Logic.ShoppingCartActions usersShoppingCart =
                           new WingtipToys.Logic.ShoppingCartActions())
                {
                    usersShoppingCart.ReduceStock();
                    usersShoppingCart.EmptyCart();
                }

                // Clear order id.
                Session["currentOrderId"] = string.Empty;
            }
        }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         // Verify user has completed the checkout process.
         if ((string)Session["userCheckoutCompleted"] != "true")
         {
             Session["userCheckoutCompleted"] = string.Empty;
             Response.Redirect("CheckoutError.aspx?" + "Desc=Unvalidated%20Checkout.");
         }
         NVPAPICaller payPalCaller       = new NVPAPICaller();
         string       retMsg             = "";
         string       token              = "";
         string       finalPaymentAmount = "";
         string       PayerID            = "";
         NVPCodec     decoder            = new NVPCodec();
         token              = Session["token"].ToString();
         PayerID            = Session["payerId"].ToString();
         finalPaymentAmount = Session["payment_amt"].ToString();
         bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg);
         if (ret)
         {
             // Retrieve PayPal confirmation value.
             string PaymentConfirmation = decoder["PAYMENTINFO_0_TRANSACTIONID"].ToString();
             TransactionId.Text = PaymentConfirmation;
             ProductContext _db = new ProductContext();
             // Get the current order id.
             int currentOrderId = -1;
             if ((string)Session["currentOrderId"] != string.Empty)
             {
                 currentOrderId = Convert.ToInt32(Session["currentOrderID"]);
             }
             Order myCurrentOrder;
             if (currentOrderId >= 0)
             {
                 // Get the order based on order id.
                 myCurrentOrder = _db.Orders.Single(o => o.OrderId == currentOrderId);
                 // Update the order to reflect payment has been completed.
                 myCurrentOrder.PaymentTransactionId = PaymentConfirmation;
                 // Save to DB.
                 _db.SaveChanges();
             }
             // Clear shopping cart.
             using (WingtipToys.Logic.ShoppingCartActions usersShoppingCart = new WingtipToys.Logic.ShoppingCartActions())  {
                 usersShoppingCart.EmptyCart();
             }     // Clear order id.
             Session["currentOrderId"] = string.Empty;
         }
         else
         {
             Response.Redirect("CheckoutError.aspx?" + retMsg);
         }
     }
 }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Verify user has completed the checkout process.
                if ((string)Session["userCheckoutCompleted"] != "true")
                {
                    Session["userCheckoutCompleted"] = string.Empty;
                    Response.Redirect("CheckoutError.aspx?" + "Desc=Unvalidated%20Checkout.");
                }
                NVPAPICaller payPalCaller       = new NVPAPICaller();
                string       retMsg             = "";
                string       token              = "";
                string       finalPaymentAmount = "";
                string       PayerID            = "";
                NVPCodec     decoder            = new NVPCodec();
                //token = Session["token"].ToString();
                PayerID            = Session["payerId"].ToString();
                finalPaymentAmount = GetFromCookie("total", null).ToString();
                //bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg);
                if (true)
                {
                    // Retrieve PayPal confirmation value.
                    string PaymentConfirmation = GetFromCookie("transactionID", null).ToString();
                    TransactionId.Text = PaymentConfirmation;
                    ProductContext _db = new ProductContext();
                    // Get the current order id.

                    // Clear shopping cart.
                    using (WingtipToys.Logic.ShoppingCartActions usersShoppingCart = new WingtipToys.Logic.ShoppingCartActions())
                    {
                        usersShoppingCart.EmptyCart();
                    }
                    // Clear order id.
                    Session["currentOrderId"] = string.Empty;
                }
                else
                {
                    Response.Redirect("CheckoutError.aspx?" + retMsg);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Verify user has completed the checkout process.
                if ((string)Session["userCheckoutCompleted"] != "true")
                {
                    Session["userCheckoutCompleted"] = string.Empty;
                    Response.Redirect("CheckoutError.aspx?" + "Desc=Unvalidated%20Checkout.");
                }

                NVPAPICaller payPalCaller = new NVPAPICaller();

                string retMsg = "";
                string token = "";
                string finalPaymentAmount = "";
                string PayerID = "";
                NVPCodec decoder = new NVPCodec();

                token = Session["token"].ToString();
                PayerID = Session["payerId"].ToString();
                finalPaymentAmount = Session["payment_amt"].ToString();

                bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg);
                if (ret)
                {
                    // Retrieve PayPal confirmation value.
                    string PaymentConfirmation = decoder["PAYMENTINFO_0_TRANSACTIONID"].ToString();
                    TransactionId.Text = PaymentConfirmation;

                    ProductContext _db = new ProductContext();
                    // Get the current order id.
                    int currentOrderId = -1;
                    if (Session["currentOrderId"] != string.Empty)
                    {
                        currentOrderId = Convert.ToInt32(Session["currentOrderID"]);
                    }
                    Order myCurrentOrder;
                    if (currentOrderId >= 0)
                    {
                        // Get the order based on order id.
                        myCurrentOrder = _db.Orders.Single(o => o.OrderId == currentOrderId);
                        // Update the order to reflect payment has been completed.
                        myCurrentOrder.PaymentTransactionId = PaymentConfirmation;
                        // Save to DB.
                        _db.SaveChanges();
                    }

                    // Clear shopping cart.
                    using (WingtipToys.Logic.ShoppingCartActions usersShoppingCart =
                        new WingtipToys.Logic.ShoppingCartActions())
                    {
                        usersShoppingCart.EmptyCart();
                    }

                    // Clear order id.
                    Session["currentOrderId"] = string.Empty;
                }
                else
                {
                    Response.Redirect("CheckoutError.aspx?" + retMsg);
                }
            }
        }