protected void Page_Load(object sender, EventArgs e) { RegisterStoreEvents(); if (Request.QueryString["Token"] != null) { PayPalProExpressPaymentMethod payment = ( PayPalProExpressPaymentMethod ) StoreContext.CheckoutDetails.PaymentMethod; if (!payment.ProcessPostLoginDetails(Request.QueryString["Token"], StoreContext.CheckoutDetails)) { CheckoutNotCompletePage.RedirectToPage( "Error Message", payment.GetErrorMessage(), "ShoppingCart.aspx", "Return To Shopping"); } } else { if (DataAccessContext.Configurations.GetValue("CheckoutMode").ToString() != "Normal") { if (!IsAnonymousCheckout()) { Response.Redirect("OnePageCheckout.aspx"); } else { Response.Redirect("OnePageCheckout.aspx?skiplogin=true"); } } } }
private void ProcessCreditCardPaymentFailure(string errorMessage) { CheckoutNotCompletePage.RedirectToPage( "<h4>Error Message</h4>", errorMessage, "~/DirectPaymentSale.aspx", "Click here to re-enter payment information"); }
private void ProcessCreditCardPaymentFailure(string errorMessage) { CheckoutNotCompletePage.RedirectToPage( "Error Message", errorMessage, "OrderCreatePaymentDetails.ascx", String.Format("StoreID={0}&CurrencyCode={1}", SelectedStoreID, CurrencyCode), "Click here to re-enter payment information", String.Format("Default.aspx#OrderCreatePaymentDetails,StoreID={0}&CurrencyCode={1}&PaymentFailure=true", SelectedStoreID, CurrencyCode) ); }
private void ProcessAnonymousPayment(CheckoutDetails checkout) { AnonymousPaymentMethod payment = (AnonymousPaymentMethod)checkout.PaymentMethod; ProcessPaymentResult paymentResult; bool result = payment.ProcessPayment( StoreContext.GetOrderAmount().Total, DataAccessContext.Configurations.GetValue("PaymentCurrency"), checkout, out paymentResult); if (result) { OrderCreateService orderCreateService = new OrderCreateService( StoreContext.ShoppingCart, checkout, StoreContext.Culture, StoreContext.Currency, AffiliateHelper.GetAffiliateCode(), WebUtilities.GetVisitorIP()); OrderAmount orderAmount; Order order = PlaceOrderAnonymous( (Page.User.Identity.IsAuthenticated) ? Membership.GetUser().UserName : SystemConst.AnonymousUser, orderCreateService, checkout, out orderAmount); AffiliateOrder affiliateorder = new AffiliateOrder(); affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode(); affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount); OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID); ProcessCreditCardPaymentSuccess( orderBusiness, paymentResult.GatewayOrderID, paymentResult.PaymentLog, paymentResult.CvvStatus, paymentResult.AvsAddrStatus, paymentResult.AvsZipStatus); } else { CheckoutNotCompletePage.RedirectToPage( "Error Message", paymentResult.ErrorMessage, "ShoppingCart.aspx", "Return To Shopping Cart"); } }
protected void Page_Load(object sender, EventArgs e) { RegisterStoreEvents(); if (Request.QueryString["Token"] != null) { PayPalProExpressPaymentMethod payment = (PayPalProExpressPaymentMethod) StoreContext.CheckoutDetails.PaymentMethod; //if (!payment.ProcessPostLoginDetails( Request.QueryString["Token"], StoreContext.CheckoutSession )) //{ // payment.RedirectToErrorPage(); //} if (!payment.ProcessPostLoginDetails(Request.QueryString["Token"], StoreContext.CheckoutDetails)) { //payment.RedirectToErrorPage(); CheckoutNotCompletePage.RedirectToPage( "Error Message", payment.GetErrorMessage(), "ShoppingCart.aspx", "Return To Shopping"); } } }
protected void Page_PreRender(object sender, EventArgs e) { if (GetShippingOptionAmount() <= 0) { SwitchPanelByState(CheckoutPageState.Error); uxValidateMessage.DisplayError("[$NoShippingOptionError]"); return; } if (GetPaymentGatewayAmount() <= 0) { SwitchPanelByState(CheckoutPageState.Error); uxValidateMessage.DisplayError("[$NoPaymentGatewayError]"); return; } if (CurrentState == CheckoutPageState.ShippingAddress) { if (!Roles.IsUserInRole("Customers") && !IsAnonymousCheckout()) { Response.Redirect("UserLogin.aspx?ReturnUrl=Checkout.aspx"); } if (!DataAccessContext.Configurations.GetBoolValue("ShippingAddressMode")) { uxCheckoutShippingAddress.SetShippingAddress(); SwitchPanelByState(CheckoutPageState.ShippingOptions); uxCheckoutShippingOption.PopulateControls(); if (isRestoredShippingOption == false) { uxCheckoutShippingOption.RestoreSelectedShippingOption(); isRestoredShippingOption = true; } } } else if (CurrentState == CheckoutPageState.ShippingOptions) { uxCheckoutShippingAddress.SetBillingAddressAnonymous(); if (Request.QueryString["Token"] != null) { PayPalProExpressPaymentMethod payment = ( PayPalProExpressPaymentMethod ) StoreContext.CheckoutDetails.PaymentMethod; if (!payment.ProcessPostLoginDetails(Request.QueryString["Token"], StoreContext.CheckoutDetails)) { CheckoutNotCompletePage.RedirectToPage( "Error Message", payment.GetErrorMessage(), "ShoppingCart.aspx", "Return To Shopping"); } } if (uxCheckoutShippingOption.ShippingOptionList.Items.Count <= 0) { uxShippingOptionNextImageButton.Visible = false; uxCheckoutShippingOption.DisplayNoShippingOption(); } if ((StoreContext.ShoppingCart.GetCartItems().Length > 0 && !StoreContext.ShoppingCart.ContainsShippableItem()) || !DataAccessContext.Configurations.GetBoolValue("ShippingAddressMode")) { StoreContext.CheckoutDetails.SetShipping(ShippingMethod.Null); SwitchPanelByState(CheckoutPageState.PaymentMethods); uxCheckoutPaymentMethods.PopulateControls(); if (isRestoredShippingMethod == false) { uxCheckoutPaymentMethods.RestorePaymentMethod(); isRestoredShippingMethod = true; } } } else if (CurrentState == CheckoutPageState.PaymentMethods) { PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne( StoreContext.Culture, StoreContext.CheckoutDetails.PaymentMethod.Name); if (!StoreContext.ShoppingCart.ContainsRecurringProduct()) { if (!paymentOption.PaymentMethodSelectionAllowed) { if (!(Request.QueryString["skiplogin"] == "true")) { Response.Redirect("OrderSummary.aspx"); } else { Response.Redirect("OrderSummary.aspx?skiplogin=true"); } } if (StoreContext.GetOrderAmount().Total <= 0) { string paymentMethodName = PaymentOption.NoPaymentName; string secondaryName = String.Empty; if (HasCoupon() || HasGiftCertificate()) { if (HasCoupon()) { secondaryName += "Coupon"; } if (HasGiftCertificate()) { if (HasCoupon()) { secondaryName += " / "; } secondaryName += "Gift Certificate"; } } PaymentOption zeroPaymentOption = DataAccessContext.PaymentOptionRepository.GetOne( StoreContext.Culture, paymentMethodName); PaymentMethod paymentMethod = zeroPaymentOption.CreatePaymentMethod(); paymentMethod.SecondaryName = secondaryName; StoreContext.CheckoutDetails.SetPaymentMethod(paymentMethod); if (!(Request.QueryString["skiplogin"] == "true")) { Response.Redirect("OrderSummary.aspx"); } else { Response.Redirect("OrderSummary.aspx?skiplogin=true"); } } } if (StoreContext.ShoppingCart.ContainsRecurringProduct()) { if (uxCheckoutPaymentMethods.PaymentList.Items.Count > 1) { uxCheckoutPaymentMethods.DisplayError("[$RecurringPaymentError]"); } } } else if (CurrentState == CheckoutPageState.PaymentInfo) { PaymentMethod paymentMethod = StoreContext.CheckoutDetails.PaymentMethod; PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(StoreContext.Culture, paymentMethod.Name); if (!paymentOption.CreditCardRequired) { uxCheckoutPaymentInfo.SetCheckoutBillingAddress(); if (!IsAnonymousCheckout()) { Response.Redirect("OrderSummary.aspx"); } else { Response.Redirect("OrderSummary.aspx?skiplogin=true"); } } } }
private void SetExpressCheckout() { string storefrontUrl = String.Empty; if (UrlManager.IsMobile()) { storefrontUrl = UrlPath.StorefrontUrl + "Mobile/"; } else { storefrontUrl = UrlPath.StorefrontUrl; } string returnURL = storefrontUrl + "Shipping.aspx"; string cancelURL = storefrontUrl + "ShoppingCart.aspx"; IList <decimal> discountLines; decimal discount = GetDiscountLine(StoreContext.ShoppingCart.GetCartItems(), out discountLines); NVPCallerServices caller = PayPalProExpressUtilities.Instance.PayPalAPIInitialize(); NVPCodec encoder = new NVPCodec(); encoder["METHOD"] = "SetExpressCheckout"; encoder["AMT"] = Vevo.Domain.Currency.ConvertPriceToUSFormat(GetShoppingCartTotal().ToString("f2")); encoder["RETURNURL"] = returnURL; encoder["CANCELURL"] = cancelURL; if (Request.QueryString["Token"] != null) { encoder["TOKEN"] = Request.QueryString["Token"]; } encoder["PAYMENTACTION"] = PayPalProExpressUtilities.PaymentType; encoder["CURRENCYCODE"] = DataAccessContext.Configurations.GetValue("PaymentCurrency"); if (DataAccessContext.Configurations.GetBoolValue("ShippingAddressMode")) { encoder["NOSHIPPING"] = "0"; } else { encoder["NOSHIPPING"] = "1"; } encoder["L_NAME0"] = "Payment for " + DataAccessContext.Configurations.GetValue(StoreContext.Culture.CultureID, "SiteName"); encoder["L_AMT0"] = Vevo.Domain.Currency.ConvertPriceToUSFormat(GetShoppingCartTotal().ToString("f2")); if (!UrlManager.IsMobile()) { encoder["VERSION"] = "65.0"; } string pStrrequestforNvp = encoder.Encode(); string pStresponsenvp = caller.Call(pStrrequestforNvp); NVPCodec decoder = new NVPCodec(); decoder.Decode(pStresponsenvp); string strAck = decoder["ACK"]; if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning")) { PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne( StoreContext.Culture, PaymentOption.PayPalProExpress); StoreContext.CheckoutDetails.PaymentMethod = paymentOption.CreatePaymentMethod(); //PayPalProExpressUtilities.Instance.Token = decoder["TOKEN"]; StoreContext.CheckoutDetails.CustomParameters[CheckoutDetails.PayPalProExpress_TokenID] = decoder["TOKEN"]; if (UrlManager.IsFacebook()) { string script = "window.parent.location.href='" + PayPalProExpressUtilities.Instance.UrlSetExpressCheckout(UrlManager.IsMobile()) + "&useraction=commit&token=" + decoder["TOKEN"] + "'"; ScriptManager.RegisterStartupScript(this, typeof(Page), "startScript", script, true); } else { Response.Redirect(PayPalProExpressUtilities.Instance.UrlSetExpressCheckout(UrlManager.IsMobile()) + "&useraction=commit&token=" + decoder["TOKEN"]); } } else { //PayPalProExpressUtilities.RedirectToErrorPage( decoder ); CheckoutNotCompletePage.RedirectToPage( "Error Message", PayPalProExpressUtilities.GetErrorMessage(decoder), "ShoppingCart.aspx", "Return To Shopping"); } }