protected void CreateUser_Click(object sender, EventArgs e) { var manager = new ApplicationUserManager(); var user = new ApplicationUser() { UserName = UserName.Text }; IdentityResult result = manager.Create(user, Password.Text); if (result.Succeeded) { IdentityHelper.SignIn(manager, user, isPersistent: false); using (BCM.WebFormsApplication.BLL.ShoppingCartActions usersShoppingCart = new BCM.WebFormsApplication.BLL.ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); usersShoppingCart.MigrateCart(cartId, user.Id); } IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Benutzerkennwort überprüfen var manager = new ApplicationUserManager(); ApplicationUser user = manager.Find(UserName.Text, Password.Text); if (user != null) { IdentityHelper.SignIn(manager, user, RememberMe.Checked); BCM.WebFormsApplication.BLL.ShoppingCartActions usersShoppingCart = new BCM.WebFormsApplication.BLL.ShoppingCartActions(); String cartId = usersShoppingCart.GetCartId(); usersShoppingCart.MigrateCart(cartId, UserName.Text); IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { FailureText.Text = "Invalid username or password."; ErrorMessage.Visible = true; } } }
//public bool ShortcutExpressCheckout(string amt, ref string token, ref string retMsg) public bool ShortcutExpressCheckout(decimal amt, ref string token, ref string retMsg) { if (bSandbox) { pEndPointURL = pEndPointURL_SB; host = host_SB; } string returnURL = "http://localhost:12345/Checkout/CheckoutReview.aspx"; string cancelURL = "http://localhost:12345/Checkout/CheckoutCancel.aspx"; NVPCodec encoder = new NVPCodec(); encoder["METHOD"] = "SetExpressCheckout"; encoder["RETURNURL"] = returnURL; encoder["CANCELURL"] = cancelURL; encoder["BRANDNAME"] = "Book Collection Manager"; //encoder["PAYMENTREQUEST_0_AMT"] = amt; encoder["PAYMENTREQUEST_0_AMT"] = amt.ToString(CultureInfo.InvariantCulture); //encoder["PAYMENTREQUEST_0_ITEMAMT"] = amt; encoder["PAYMENTREQUEST_0_ITEMAMT"] = amt.ToString(CultureInfo.InvariantCulture); encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale"; //encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "USD"; encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = new RegionInfo(CultureInfo.CurrentCulture.Name).ISOCurrencySymbol; // Get the Shopping Cart Products decimal price; using (BCM.WebFormsApplication.BLL.ShoppingCartActions myCartOrders = new BCM.WebFormsApplication.BLL.ShoppingCartActions()) { List <CartItem> myOrderList = myCartOrders.GetCartItems(); for (int i = 0; i < myOrderList.Count; i++) { price = myOrderList[i].Book.ListPrice ?? 0.0m; encoder["L_PAYMENTREQUEST_0_NAME" + i] = myOrderList[i].Book.Title.ToString(); encoder["L_PAYMENTREQUEST_0_AMT" + i] = price.ToString(CultureInfo.InvariantCulture); encoder["L_PAYMENTREQUEST_0_QTY" + i] = myOrderList[i].Quantity.ToString(); } } string pStrrequestforNvp = encoder.Encode(); string pStresponsenvp = HttpCall(pStrrequestforNvp); NVPCodec decoder = new NVPCodec(); decoder.Decode(pStresponsenvp); string strAck = decoder["ACK"].ToLower(); if (strAck != null && (strAck == "success" || strAck == "successwithwarning")) { token = decoder["TOKEN"]; string ECURL = "https://" + host + "/cgi-bin/webscr?cmd=_express-checkout" + "&token=" + token; retMsg = ECURL; return(true); } else { retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" + "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" + "Desc2=" + decoder["L_LONGMESSAGE0"]; return(false); } }