예제 #1
0
파일: BAL.cs 프로젝트: lchambaka/WorkPad
        public long CreateCMEDShopTransaction(CMEDShopTransaction transaction)
        {
            DB db = new DB();

            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "CreateCMEDShopTransaction";

            cmd.Parameters.AddWithValue("@order_id", transaction.order_id);
            cmd.Parameters.AddWithValue("@first_name", transaction.first_name);
            cmd.Parameters.AddWithValue("@last_name", transaction.last_name);
            cmd.Parameters.AddWithValue("@address", transaction.address);
            cmd.Parameters.AddWithValue("@city", transaction.city);
            cmd.Parameters.AddWithValue("@state", transaction.state);
            cmd.Parameters.AddWithValue("@postal_code", transaction.postal_code);
            cmd.Parameters.AddWithValue("@email", transaction.email);
            cmd.Parameters.AddWithValue("@phone_number", transaction.phone_number);
            cmd.Parameters.AddWithValue("@transaction_type", transaction.transaction_type);
            cmd.Parameters.AddWithValue("@Status", transaction.status);

            DataTable dt = db.Execute(cmd);

            DataRow row = dt.Rows[0];

            return long.Parse(row["transaction_id"].ToString());
        }
예제 #2
0
파일: BAL.cs 프로젝트: lchambaka/WorkPad
        public CMEDShopTransaction GetCMEDShopTransactionByOrderID(long order_id)
        {
            DB db = new DB();

            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "GetCMEDShopTransactionByOrderID";
            cmd.Parameters.AddWithValue("@order_id", order_id);

            DataTable dt = db.Execute(cmd);

            DataRow dr = dt.Rows[0];

            CMEDShopTransaction transaction = new CMEDShopTransaction
            {
                order_id = long.Parse(dr["order_id"].ToString()),
                address = dr["address"].ToString(),
                email = dr["email"].ToString(),
                first_name = dr["first_name"].ToString(),
                last_name = dr["last_name"].ToString(),
                city = dr["city"].ToString(),
                state = dr["state"].ToString(),
                postal_code = dr["posta_code"].ToString(),
                phone_number = dr["phone_number"].ToString(),
                date_created = DateTime.Parse(dr["date_created"].ToString()),
                created_by = dr["created_by"].ToString(),
                date_updated = DateTime.Parse(dr["date_updated"].ToString()),
                updated_by = dr["updated_by"].ToString(),

            };

            return transaction;
        }
예제 #3
0
        protected void RegisterButton_Click(object sender, ImageClickEventArgs e)
        {
            var id = txtID.Value;

            if (Request.Cookies["email"] == null)
            {
                FormsAuthentication.SignOut();
                FormsAuthentication.RedirectToLoginPage();

            }

            var email = Request.Cookies["email"].Value;

            CMEDWorkShopBalance objbalance = controller.GetCMEDWorkShopBalancePayment(Convert.ToInt32(id), email.ToString());
            workshop = controller.GetCMEDWorkShop(Convert.ToInt32(id));

            if (!string.IsNullOrEmpty(id))
            {
                if (Helper.IsNumeric(id))
                {

                    Price = Convert.ToInt32(objbalance.balance);

                }
                else
                {
                    Response.Redirect("http://www.myss.com/");
                }

                var amt = 0m;

                try
                {

                    decimal charge = Price;

                    if (charge > 0)
                    {
                        long ShoppingCartID = controller.IssueNewGlobalID();

                        try
                        {
                            controller.SaveCartItem(workshop.ProductID, Price, ShoppingCartID, EmailTextBox.Text.Trim(), GetUserIP());
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }

                        string auth_status = string.Empty;
                        string auth_code = string.Empty;
                        string auth_message = string.Empty;
                        string auth_response_code = string.Empty;
                        string auth_transaction_id = string.Empty;

                        CMEDShopTransaction transaction = new CMEDShopTransaction
                        {
                            order_id = ShoppingCartID,
                            first_name = FirstNameTextBox.Text,
                            last_name = LastNameTextBox.Text,
                            address = AddressTextBox.Text,
                            city = CityTextBox.Text,
                            state = State.SelectedValue,
                            postal_code = ZipTextBox.Text,
                            email = EmailTextBox.Text,
                            phone_number = PhoneNumberTextBox.Text,
                            transaction_type = "Credit Card",
                            status = "Status"
                        };

                        try
                        {

                            long transaction_id = controller.CreateCMEDShopTransaction(transaction);

                            CreateCharge(out auth_status,
                                         out auth_code,
                                         out auth_message,
                                         out auth_response_code,
                                         out auth_transaction_id,
                                         out amt,
                                         charge,
                                         transaction_id);

                            controller.UpateCMEDShopTransaction(transaction_id,
                                                                auth_status,
                                                                auth_code,
                                                                auth_message,
                                                                auth_response_code,
                                                                auth_transaction_id);

                            long order_id = controller.CreateOrderFromCart(ShoppingCartID);

                            HttpCookie Checkout = new HttpCookie("Confirmation");
                            Checkout["Email"] = transaction.email;
                            Checkout["WorkShopName"] = workshop.Title;
                            Checkout.Expires = DateTime.Now.AddMinutes(30);
                            Response.Cookies.Add(Checkout);

                            Util.SendWelcomeMailWorkShopBalance(transaction, amt, workshop.Title);

                            String s = "CMEDWorkshopPurchaseThankYou.aspx";

                            Response.Redirect(s);
                        }
                        catch (Exception ex)
                        {
                            string error = ex.Message;
                            lblErrorMessage.Text = "Unable to create customer record, please contact myss.com support:  ";
                            return;
                        }
                    }

                }
                catch (Exception ex)
                {
                    string error = ex.Message;
                    lblErrorMessage.Text = "Unable to process your credit card. Please verify the information or try another card. ";
                    return;
                }

            }
        }
예제 #4
0
        protected void btn_SubmitPaypal_Click(object sender, ImageClickEventArgs e)
        {
            var id = txtID.Value;

            if (Request.Cookies["email"] == null)
            {
                FormsAuthentication.SignOut();
                FormsAuthentication.RedirectToLoginPage();

            }

            var email = Request.Cookies["email"].Value;

            CMEDWorkShopBalance objbalance = controller.GetCMEDWorkShopBalancePayment(Convert.ToInt32(id), email.ToString());
            workshop = controller.GetCMEDWorkShop(Convert.ToInt32(id));

            if (!string.IsNullOrEmpty(id))
            {
                if (Helper.IsNumeric(id))
                {

                    Price = Convert.ToInt32(objbalance.balance);

                }
                else
                {
                    Response.Redirect("http://www.myss.com/");
                }

                long ShoppingCartID = controller.IssueNewGlobalID();
                Response.Cookies["ShoppingCartID"].Value = ShoppingCartID.ToString();

                try
                {
                    controller.SaveCartItem(workshop.ProductID, Price, ShoppingCartID, EmailTextBox.Text.Trim(), GetUserIP());
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                string auth_status = string.Empty;
                string auth_code = string.Empty;
                string auth_message = string.Empty;
                string auth_response_code = string.Empty;
                string auth_transaction_id = string.Empty;

                CMEDShopTransaction transaction = new CMEDShopTransaction
                {
                    order_id = ShoppingCartID,
                    first_name = FirstNameTextBox.Text,
                    last_name = LastNameTextBox.Text,
                    address = AddressTextBox.Text,
                    city = CityTextBox.Text,
                    state = State.SelectedValue,
                    postal_code = ZipTextBox.Text,
                    email = EmailTextBox.Text,
                    phone_number = PhoneNumberTextBox.Text,
                    transaction_type = "Credit Card",
                    status = "in-progress"
                };

                try
                {
                    if (Request.Cookies["TransactionID"] == null)
                    {
                        long transaction_id = controller.CreateCMEDShopTransaction(transaction);

                        //write the cookie of transaction_id for use later
                        Response.Cookies["TransactionID"].Value = transaction_id.ToString();

                    }

                    Cart cart = controller.LoadCart(ShoppingCartID);
                    if (cart.order_amount == 0)
                    {
                        Response.Redirect(redirectPage);
                    }

                    NVPAPICaller payPalCaller = new NVPAPICaller();
                    string retTokenMsg = "";
                    string token = "";
                    NVPCodec decoder = new NVPCodec();
                    string amt01 = cart.order_amount.ToString();

                    bool retToken = payPalCaller.ShortcutExpressCheckout(amt01, ShoppingCartID, ref token, ref retTokenMsg, true);
                    if (retToken)
                    {
                        HttpContext.Current.Session["token"] = token;
                        Response.Redirect(retTokenMsg);
                    }
                    else
                    {
                        lblErrorMessage.Text = "PayPal is not responding, please try again in a few moments.";
                    }

                }
                catch (Exception ex)
                {

                    throw ex;

                }

            }
        }
예제 #5
0
        protected void btn_SubmitPaypal_Click(object sender, ImageClickEventArgs e)
        {
            //grab shopping cart id cookie

            if (Request.Cookies["ShoppingCartID"] != null)
            {
                ShoppingCartID = long.Parse(Request.Cookies["ShoppingCartID"].Value);
            }
            else
            {
                Response.Redirect(redirectPage);
            }

            //decimal amt = 0;

            CMEDShopTransaction transaction = new CMEDShopTransaction
            {
                order_id = ShoppingCartID,
                first_name = FirstNameTextBox.Text,
                last_name = LastNameTextBox.Text,
                address = AddressTextBox.Text,
                city = CityTextBox.Text,
                state = drpState.SelectedValue,
                postal_code = ZipTextBox.Text,
                email = EmailTextBox.Text,
                phone_number = PhoneNumberTextBox.Text,
                transaction_type = "PayPal",
                status = "in-progress"
            };

            try
            {
                //check transaction_id cookie and if there then dont call create transaction
                if (Request.Cookies["TransactionID"] == null)
                {

                    long transaction_id = controller.CreateCMEDShopTransaction(transaction);

                    //write the cookie of transaction_id for use later
                    Response.Cookies["TransactionID"].Value = transaction_id.ToString();
                }

                Cart cart = controller.LoadCart(ShoppingCartID);
                if (cart.order_amount == 0)
                {
                    Response.Redirect(redirectPage);
                }

                NVPAPICaller payPalCaller = new NVPAPICaller();
                string retTokenMsg = "";
                string token = "";
                NVPCodec decoder = new NVPCodec();
                string amt01 = cart.order_amount.ToString();

                bool retToken = payPalCaller.ShortcutExpressCheckout(amt01, ShoppingCartID, ref token, ref retTokenMsg, false);
                if (retToken)
                {
                    HttpContext.Current.Session["token"] = token;
                    Response.Redirect(retTokenMsg);
                }
                else
                {
                    lblErrorMessage.Text = "PayPal is not responding, please try again in a few moments.";
                }

            }
            catch (Exception ex)
            {

                throw ex;

            }
        }
예제 #6
0
        protected void btn_Submit_Click(object sender, ImageClickEventArgs e)
        {
            //grag shopping cart id cookie

            if (Request.Cookies["ShoppingCartID"] != null)
            {
                ShoppingCartID = long.Parse(Request.Cookies["ShoppingCartID"].Value);
            }
            else
            {
                Response.Redirect(redirectPage);
            }
            //save transaction information to the database

            string auth_status = string.Empty;
            string auth_code = string.Empty;
            string auth_message = string.Empty;
            string auth_response_code = string.Empty;
            string auth_transaction_id = string.Empty;
            CMEDShopTransaction transaction = new CMEDShopTransaction
            {
                order_id = ShoppingCartID,
                first_name = FirstNameTextBox.Text,
                last_name = LastNameTextBox.Text,
                address = AddressTextBox.Text,
                city = CityTextBox.Text,
                state = drpState.SelectedValue,
                postal_code = ZipTextBox.Text,
                email = EmailTextBox.Text,
                phone_number = PhoneNumberTextBox.Text,
                transaction_type = "Credit Card",
                status = "in-progress"
            };

            decimal amt = 0;
            try
            {
                long transaction_id = controller.CreateCMEDShopTransaction(transaction);
                Cart cart = controller.LoadCart(ShoppingCartID);
                if (cart.order_amount == 0)
                {
                    Response.Redirect(redirectPage);
                }

                CreateCharge(out auth_status,
                             out auth_code,
                             out auth_message,
                             out auth_response_code,
                             out auth_transaction_id,
                             out amt,
                             (decimal)cart.order_amount,
                             transaction_id);

                //update transaction information
                controller.UpateCMEDShopTransaction(transaction_id,
                                                    auth_status,
                                                    auth_code,
                                                    auth_message,
                                                    auth_response_code,
                                                    auth_transaction_id);

                //create order from cart
                long order_id = controller.CreateOrderFromCart(ShoppingCartID);

                CMEDShopOrder order = controller.LoadOrder(order_id);

                //send out order confirmation email
                Util.SendOrderConfirmation(order);

                //send customer to purchase thank you page
                Response.Redirect("CMEDPurchase_ThankYou.aspx");
            }

            catch (CardAuthourize iex)
            {
                lblErrorMessage.Text = iex.Message;
                return;
            }
            catch (Exception ex)
            {

                throw ex;

            }

            //Charge Card
            //Update Transaction Status (Passed, Failed, Failed Reason)
        }
예제 #7
0
파일: Util.cs 프로젝트: lchambaka/WorkPad
    public static void SendWelcomeMailWorkShopBalance(CMEDShopTransaction transaction, decimal amt, string ProductName)
    {
        var InfoEmail = System.Configuration.ConfigurationManager.AppSettings["InfoEmail"];
        var CustServiceEmail = System.Configuration.ConfigurationManager.AppSettings["CustServiceEmail"];

        var TestInfoEmail = System.Configuration.ConfigurationManager.AppSettings["TestInfoEmail"];
        var TestCustServiceEmail = System.Configuration.ConfigurationManager.AppSettings["TestCustServiceEmail"];

        var sb = new StringBuilder();
        sb.Append("Name: ").Append(transaction.first_name).Append(" ").AppendLine(transaction.last_name);
        sb.Append("Email: ").AppendLine(transaction.email);
        sb.Append("Address: ").AppendLine(transaction.address);
        sb.Append("City: ").AppendLine(transaction.city);
        sb.Append("State: ").AppendLine(transaction.state);
        sb.Append("Zip: ").AppendLine(transaction.postal_code);
        sb.Append("Phone: ").AppendLine(transaction.phone_number);
        sb.Append("Amount Paid: $").AppendLine(amt.ToString());
        sb.AppendLine();
        sb.Append("WorkShop Purchased: ").AppendLine(ProductName);
        sb.AppendLine();
        sb.Append("This is confirmation of your purchase of the Workshop.");
        sb.Append("If you have any questions please e-mail at: [email protected]");

        var sbAdmin = new StringBuilder();
        sbAdmin.Append("Name: ").Append(transaction.first_name).Append(" ").AppendLine(transaction.last_name);
        sbAdmin.Append("Email: ").AppendLine(transaction.email);
        sbAdmin.Append("Address: ").AppendLine(transaction.address);
        sbAdmin.Append("City: ").AppendLine(transaction.city);
        sbAdmin.Append("State: ").AppendLine(transaction.state);
        sbAdmin.Append("Zip: ").AppendLine(transaction.postal_code);
        sbAdmin.Append("Phone: ").AppendLine(transaction.phone_number);
        sbAdmin.Append("Amount Paid: $").AppendLine(amt.ToString());
        sbAdmin.AppendLine();
        sbAdmin.Append("Product Purchased: ").AppendLine(ProductName);

        var isTest = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsTestMode"]);
        var IsTestEmailDelivery = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsTestEmailDelivery"]);

        var TestString = String.Empty;
        if (isTest)
        {
            TestString = " - Testing Please Ignore";
        }

        if (IsTestEmailDelivery)
        {
            SendMail(transaction.email, TestCustServiceEmail, "Thank you for Purchasing The Myss.com Workshop" + TestString, sb.ToString(), false);

            SendMail(TestCustServiceEmail, TestInfoEmail, "New Myss.com Workshop Customer" + TestString, sbAdmin.ToString(), false);
        }
        else
        {
            SendMail(transaction.email, CustServiceEmail, "Thank you for Purchasing The Myss.com Workshop" + TestString, sb.ToString(), false);

            SendMail(CustServiceEmail, InfoEmail, "New Myss.com Workshop Customer" + TestString, sbAdmin.ToString(), false);
        }
    }