public static void NotifHandler(string status_code, string status_message, string transaction_id, string masked_card, string order_id, string gross_amount, string payment_type, string transaction_time, string transaction_status, string fraud_status, string signature_key) { //HttpContext.Current.Response.Write("asdasd"); //HttpContext.Current.Response.Write(status_code + " " + status_message + " " + transaction_id + " " + masked_card + " " + order_id + " " + gross_amount + " " + payment_type + " " + transaction_time + " " + transaction_status + " " + fraud_status + " " + approval_code + " " + signature_key + " " + bank + " " + eci); try { DataClassesDataContext db = new DataClassesDataContext(); TBOrder order = db.TBOrders.Where(x => x.IDOrder.ToString() == order_id).FirstOrDefault(); if (order != null) { HttpContext.Current.Response.Write("ada"); if (status_code == "200") { Class_Order class_order = new Class_Order(); ReturnData result = class_order.AJAX_UpdateOrderStatus_vt(order.IDOrder, 2, ""); HttpContext.Current.Response.Write(result.message); } else { Class_Order class_order = new Class_Order(); class_order.AJAX_UpdateOrderStatus_vt(order.IDOrder, 2, ""); HttpContext.Current.Response.Write("not updated"); } } } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); } }
/* HELPER METHODS FOR UPDATING COMPANY VARIABLES */ //updating company variables, through helpers public void UpdateCompanyHelper(Class_Order order) { setNetChangeHelper(order.getPrice()); setPercentChangeHelper(); setLastSale(order.getPrice()); setIconHelper(); }
public static void HandlerVA(string status_code, string order_id) { //HttpContext.Current.Response.Write("asdasd"); //HttpContext.Current.Response.Write(status_code + " " + status_message + " " + transaction_id + " " + masked_card + " " + order_id + " " + gross_amount + " " + payment_type + " " + transaction_time + " " + transaction_status + " " + fraud_status + " " + approval_code + " " + signature_key + " " + bank + " " + eci); try { DataClassesDataContext db = new DataClassesDataContext(); TBOrder order = db.TBOrders.Where(x => x.Reference == order_id).FirstOrDefault(); if (order != null) { if (status_code == "200") { Class_Order class_order = new Class_Order(); class_order.AJAX_UpdateOrderStatus_vt(order.IDOrder, 2, ""); //sukses } else if (status_code == "202") { Class_Order class_order = new Class_Order(); class_order.AJAX_UpdateOrderStatus_vt(order.IDOrder, 10, ""); //Transaksi ditolak oleh bank atau Fraud Detection System (FDS). } else if (status_code == "201") { Class_Order class_order = new Class_Order(); class_order.AJAX_UpdateOrderStatus_vt(order.IDOrder, 13, ""); //Transaksi ditolak oleh FDS. Anda harus melakukan konfirmasi di Merchant Administration Portal (MAP). } } } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); } }
public static int CheckCurrencyCart() { Class_Order _order = new Class_Order(); string anonID = HttpContext.Current.Request.AnonymousID; TBOrder_temp _cookie = _order.GetEncodedDataOrder(anonID); string _token = ""; if (_cookie == null) { return(0); } else { _token = _cookie.EncodedData; dynamic tmp = (OurClass.DecryptToken(_token) as IDictionary <string, dynamic>); if ((tmp as Dictionary <string, dynamic>).ContainsKey("IDCurrency")) { return(tmp["IDCurrency"]); } else { return(0); } } }
public dynamic DYNAMIC_AddToCart_Renew(int idProduct, int idCustomer, int idCustomerProduct) { try { DataClassesDataContext db = new DataClassesDataContext(); Class_Order _Order = new Class_Order(); var dataOrder = db.TBProducts.Where(x => x.IDProduct == idProduct).FirstOrDefault(); //HttpCookie _cookie = HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()]; string anonID = HttpContext.Current.Request.AnonymousID; TBOrder_temp _cookie = _Order.GetEncodedDataOrder(anonID); string _token = ""; Dictionary <string, dynamic> _product = new Dictionary <string, dynamic>(); List <Dictionary <string, dynamic> > _listProduct = new List <Dictionary <string, dynamic> >(); Dictionary <string, dynamic> _tokenData = new Dictionary <string, dynamic>(); TBProduct_Combination productCombination = db.TBProduct_Combinations.Where(x => !x.Deflag && x.IDProduct_Combination == dataOrder.TBProduct_Combinations.FirstOrDefault().IDProduct_Combination).FirstOrDefault(); if (productCombination == null) { return(ReturnData.MessageFailed("Data not found", null)); } _product.Add("IDProduct", dataOrder.IDProduct); _product.Add("IDCombination", dataOrder.TBProduct_Combinations.FirstOrDefault().IDProduct_Combination); _product.Add("Price", dataOrder.Price * 1); _product.Add("CombinationName", dataOrder.TBProduct_Combinations.FirstOrDefault().Name); _product.Add("Quantity", 1); _product.Add("ProductName", dataOrder.Name); _product.Add("PricePerUnit", dataOrder.Price); _product.Add("Weight", productCombination.Weight); _product.Add("WeightPerUnit", productCombination.Weight); _listProduct.Add(_product); _tokenData.Add("Product", _listProduct); _tokenData.Add("TotalPrice", dataOrder.Price); _tokenData.Add("TotalQuantity", 1); _tokenData.Add("TotalWeight", productCombination.Weight); _tokenData.Add("Subtotal", dataOrder.Price); _tokenData.Add("IDCurrency", Class_Currency.GetActiveCurrencyID()); _tokenData.Add("OrderType", "renew"); _tokenData.Add("IDCustomerProduct", idCustomerProduct); _token = OurClass.EncryptToken(_tokenData); //HttpContext.Current.Response.Cookies.Add(new HttpCookie(System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString(), _token)); _Order.SaveEncodeDataOrder(HttpContext.Current.Request.AnonymousID, _token); //HttpContext.Current.Response.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()].Expires = DateTime.Now.AddMinutes(120); return(ReturnData.MessageSuccess("Product add to cart successfully", _tokenData)); //cek cookies nya ada ngga, kalo ada ganti token //kalo ga ada tambahin dulu _witcomcrt_ //cek kalo token nya kosong // kalo ngga kosong, decrypt dulu, ambil object nya. //trus tambahin sama cart yang baru } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public ReturnData AJAX_FE_RegisterGuest(string firstName, string lastName, string gender, string email, string password, string phoneNumber, DateTime birthday, bool isSubscribe, string addressname, string address, string postalCode, int idCountry, int idProvince, int idCity, int idDistrict) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { //if (IsExistsEmail(db, email)) // return ReturnData.MessageFailed("Email is already registered", null); SP_RegisterGuestCustomerResult result = db.SP_RegisterGuestCustomer(firstName, lastName, gender, email, EncryptPassword(password), phoneNumber, birthday, idCountry, idProvince, idCity, idDistrict, address, postalCode, "").FirstOrDefault(); if (result != null) { if (AJAX_FE_Login(email, password).success) { Class_Order order = new Class_Order(); order.AJAX_SaveAddressToCart(result.IDAddress.Value, result.IDAddress.Value, ""); return(ReturnData.MessageSuccess("Register success", result.IDCustomer)); } else { return(ReturnData.MessageFailed("authentication invalid", null)); } } else { return(ReturnData.MessageFailed("Result null", null)); } } } catch (Exception ex) { return(ReturnData.MessageFailed(ex.Message, null)); } }
public ReturnData AJAX_SaveShippingToCart(int idShipping) { try { //var cartCookies = HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()]; Class_Order order = new Class_Order(); var cartCookies = order.GetEncodedDataOrder(HttpContext.Current.Request.AnonymousID); if (cartCookies == null) { return(ReturnData.MessageFailed("Invalid token", null)); } DataClassesDataContext db = new DataClassesDataContext(); Class_Shipping shipping = new Class_Shipping(); var token = cartCookies.EncodedData; dynamic CartData = OurClass.DecryptToken(token); dynamic address = CartData["DeliveryAddress"]; int idDistrict = address["IDDistrict"]; dynamic shippingData = shipping.Dynamic_GetShipping_ByIDShipping(idShipping); dynamic resultShipping = new Dictionary <string, dynamic>(); decimal totalPrice = 0; decimal price = 0; totalPrice = Class_Currency.GetPriceConversionCurrency(shippingData.Price * Math.Ceiling((decimal)CartData["TotalWeight"])); price = Class_Currency.GetPriceConversionCurrency(shippingData.Price); if (CartData["TotalWeight"] < 1) { totalPrice = Class_Currency.GetPriceConversionCurrency(shippingData.Price); } resultShipping["IDCarrier"] = shippingData.IDCarrier; resultShipping["IDShipping"] = shippingData.IDShipping; resultShipping["IDDistrict"] = shippingData.IDDistrict; resultShipping["Image"] = shippingData.Image; resultShipping["Name"] = shippingData.Name; resultShipping["Price"] = price; resultShipping["Information"] = shippingData.Information; resultShipping["TotalPrice"] = totalPrice; CartData["Shipping"] = resultShipping; token = OurClass.EncryptToken(CartData); //HttpContext.Current.Response.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()].Value = token; order.SaveEncodeDataOrder(HttpContext.Current.Request.AnonymousID, token); return(ReturnData.MessageSuccess("OK", CartData)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public dynamic Dynamic_GetData_CustomerDetail(int id) { try { DataClassesDataContext db = new DataClassesDataContext(); Class_Address _address = new Class_Address(); Class_Voucher _voucher = new Class_Voucher(); Class_Order _order = new Class_Order(); return(db.TBCustomers.Where(x => !x.Deflag && x.Active && x.IDCustomer == id).AsEnumerable().Select(x => new { x.IDCustomer, x.FirstName, x.LastName, x.Email, x.Birthday, x.Gender, x.PhoneNumber, Subscribe = x.IsSubscribe, Status = x.Active, Age = DateTime.Now.Year - x.Birthday.Year, DateRegistered = x.DateInsert, CustomerGroup = x.TBCustomer_Group.Name, TotalValidOrder = db.TBOrders.Where(y => y.IDCustomer == x.IDCustomer && !y.Deflag && y.TBOrder_Status.Paid).Count(), TotalInvalidOrder = db.TBOrders.Where(y => y.IDCustomer == x.IDCustomer && !y.Deflag && !y.TBOrder_Status.Paid).Count(), TotalValidBuy = db.TBOrders.Where(y => y.IDCustomer == x.IDCustomer && !y.Deflag && y.TBOrder_Status.Paid).Sum(y => y.TotalPaid), TotalInvalidBuy = db.TBOrders.Where(y => y.IDCustomer == x.IDCustomer && !y.Deflag && !y.TBOrder_Status.Paid).Sum(y => y.TotalPaid), Address = _address.Dynamic_GetAll_ByEmail(x.Email), Voucher = _voucher.Dynamic_GetData_ByIDCustomer(x.IDCustomer), Order = _order.Dynamic_GetData_ByIDCustomer(x.IDCustomer), Product = _order.Dynamic_GetData_ProductBought_ByIDCustomer(x.IDCustomer) }).FirstOrDefault()); } catch (Exception) { throw; } }
public ReturnData AJAX_Insert_ToCart(int idPaymentMethod) { try { Class_Order order = new Class_Order(); //var cartCookies = HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()]; var cartCookies = order.GetEncodedDataOrder(HttpContext.Current.Request.AnonymousID); if (cartCookies == null) { return(ReturnData.MessageFailed("Invalid token", null)); } DataClassesDataContext db = new DataClassesDataContext(); Class_Shipping shipping = new Class_Shipping(); var token = cartCookies.EncodedData; dynamic CartData = OurClass.DecryptToken(token); dynamic address = CartData["DeliveryAddress"]; int idDistrict = address["IDDistrict"]; dynamic paymentData = Dynamic_GetDetail_ByIDPayment_Method(idPaymentMethod); CartData["PaymentMethod"] = paymentData; token = OurClass.EncryptToken(CartData); //HttpContext.Current.Response.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()].Value = token; order.SaveEncodeDataOrder(HttpContext.Current.Request.AnonymousID, token); return(ReturnData.MessageSuccess("OK", CartData)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
protected void Page_Load(object sender, EventArgs e) { Class_Order class_order = new Class_Order(); //class_order.AJAX_UpdateOrderStatus_vt(27, 2, ""); }