public DeleteRecurringOrderResult DeleteRecurringOrder(Order order) { var recurringOrderManager = new RecurringOrderMgr(); var expressApiType = PayPalController.GetAppropriateExpressType(); var result = string.Empty; if (order.PaymentMethod == AppLogic.ro_PMPayPalExpress && expressApiType == ExpressAPIType.PayPalExpress) { result = recurringOrderManager.CancelPPECRecurringOrder(order.OrderNumber, false); } else { result = recurringOrderManager.CancelRecurringOrder(order.OrderNumber); } if (result == AppLogic.ro_OK) { return(new DeleteRecurringOrderResult()); } else { return(new DeleteRecurringOrderResult(RecurringOrderActionStatus.Failure, result)); } }
protected void btnStopBilling_Click(Object sender, EventArgs e) { try { var originalOrder = new Order(OriginalRecurringOrderNumber); var recurringOrderManager = new RecurringOrderMgr(); var result = string.Empty; if (originalOrder.PaymentMethod == AppLogic.ro_PMPayPalExpress && PayPalController.GetAppropriateExpressType() == ExpressAPIType.PayPalExpress) { result = recurringOrderManager.CancelPPECRecurringOrder(originalOrder.OrderNumber, false); } else { result = recurringOrderManager.CancelRecurringOrder(originalOrder.OrderNumber); } if (result == AppLogic.ro_OK) { AlertMessage.PushAlertMessage("admin.recurringorder.OrderCancelSuccess".StringResource(), AspDotNetStorefrontControls.AlertMessage.AlertType.Success); } else { AlertMessage.PushAlertMessage(result, AspDotNetStorefrontControls.AlertMessage.AlertType.Error); } } catch (Exception ex) { AlertMessage.PushAlertMessage(ex.Message, AspDotNetStorefrontControls.AlertMessage.AlertType.Error); } }
private void RenderHtml() { StringBuilder writer = new StringBuilder(); if (authorized) { //If there is a DeleteID remove it from the cart int DeleteRecurringOrderNumber = CommonLogic.QueryStringUSInt("DeleteID"); String DeleteRecurringOrderResult = String.Empty; if (DeleteRecurringOrderNumber != 0) { Order originalOrder = new Order(DeleteRecurringOrderNumber); RecurringOrderMgr rmgr = new RecurringOrderMgr(); ExpressAPIType expressApiType = PayPalController.GetAppropriateExpressType(); if (originalOrder.PaymentMethod == AppLogic.ro_PMPayPalExpress && expressApiType == ExpressAPIType.PayPalExpress) { DeleteRecurringOrderResult = rmgr.CancelPPECRecurringOrder(DeleteRecurringOrderNumber, false); } else { DeleteRecurringOrderResult = rmgr.CancelRecurringOrder(DeleteRecurringOrderNumber); } } //If there is a FullRefundID refund it int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID"); String FullRefundResult = String.Empty; if (FullRefundID != 0) { RecurringOrderMgr rmgr = new RecurringOrderMgr(); FullRefundResult = rmgr.ProcessAutoBillFullRefund(FullRefundID); } //If there is a PartialRefundID refund it int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID"); String PartialRefundResult = String.Empty; if (PartialRefundID != 0) { RecurringOrderMgr rmgr = new RecurringOrderMgr(); PartialRefundResult = rmgr.ProcessAutoBillPartialRefund(PartialRefundID); } //If there is a retrypaymentid, retry it int RetryPaymentID = CommonLogic.QueryStringUSInt("retrypaymentid"); String RetryPaymentResult = String.Empty; if (RetryPaymentID != 0) { RecurringOrderMgr rmgr = new RecurringOrderMgr(); RetryPaymentResult = rmgr.ProcessAutoBillRetryPayment(RetryPaymentID); } //If there is a restartid, restart it int RestartPaymentID = CommonLogic.QueryStringUSInt("restartid"); String RestartPaymentResult = String.Empty; if (RestartPaymentID != 0) { RecurringOrderMgr rmgr = new RecurringOrderMgr(); RestartPaymentResult = rmgr.ProcessAutoBillRestartPayment(RestartPaymentID); } if (AppLogic.AppConfigBool("AuditLog.Enabled")) { writer.Append("<p><a href=\"" + AppLogic.AdminLinkUrl("auditlog.aspx") + "?CustomerID=" + TargetCustomer.CustomerID.ToString() + "\">View Customer Activity Log</a></p>\n"); } if (ShoppingCart.NumItems(TargetCustomer.CustomerID, CartTypeEnum.RecurringCart) != 0) { writer.Append("<p align=\"left\"><b>" + AppLogic.GetString("admin.common.CstMsg9", SkinID, LocaleSetting) + "</b></p>\n"); // build JS code to show/hide address update block: StringBuilder tmpS = new StringBuilder(4096); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("function toggleLayer(DivID)\n"); tmpS.Append("{\n"); tmpS.Append(" var elem;\n"); tmpS.Append(" var vis;\n"); tmpS.Append(" if(document.getElementById)\n"); tmpS.Append(" {\n"); tmpS.Append(" // standards\n"); tmpS.Append(" elem = document.getElementById(DivID);\n"); tmpS.Append(" }\n"); tmpS.Append(" else if(document.all)\n"); tmpS.Append(" {\n"); tmpS.Append(" // old msie versions\n"); tmpS.Append(" elem = document.all[DivID];\n"); tmpS.Append(" }\n"); tmpS.Append(" else if(document.layers)\n"); tmpS.Append(" {\n"); tmpS.Append(" // nn4\n"); tmpS.Append(" elem = document.layers[DivID];\n"); tmpS.Append(" }\n"); tmpS.Append(" vis = elem.style;\n"); tmpS.Append(" if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)\n"); tmpS.Append(" {\n"); tmpS.Append(" vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';\n"); tmpS.Append(" }\n"); tmpS.Append(" vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block' ;\n"); tmpS.Append("}\n"); tmpS.Append("</script>\n"); tmpS.Append("\n"); tmpS.Append("<style type=\"text/css\">\n"); tmpS.Append(" .addressBlockDiv { margin: 0px 20px 0px 20px; display: none;}\n"); tmpS.Append("</style>\n"); writer.Append(tmpS.ToString()); var parser = new Parser(); using (var dbconn = DB.dbConn()) { dbconn.Open(); using (var rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber from ShoppingCart with (NOLOCK) where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and CustomerID=" + TargetCustomer.CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", dbconn)) { while (rsr.Read()) { bool ShowCancelButton = true; bool ShowRetryButton = false; bool ShowRestartButton = false; String GatewayStatus = String.Empty; RecurringOrderMgr rmgr1 = new RecurringOrderMgr(); rmgr1.ProcessAutoBillGetAdminButtons(DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), out ShowCancelButton, out ShowRetryButton, out ShowRestartButton, out GatewayStatus); if (DeleteRecurringOrderNumber == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber")) { writer.Append("<table class=\"table\">\n"); writer.Append("<tr><td>\n"); writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.StopBillingResult", SkinID, LocaleSetting) + " " + DeleteRecurringOrderResult + "</span>\n"); writer.Append("</td></tr>\n"); writer.Append("</table>\n"); } if (FullRefundID == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber")) { writer.Append("<table class=\"table\">\n"); writer.Append("<tr><td>\n"); writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.FullRefundResult", SkinID, LocaleSetting) + " " + FullRefundResult + "</span>\n"); writer.Append("</td></tr>\n"); writer.Append("</table>\n"); } if (PartialRefundID == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber")) { writer.Append("<table class=\"table\">\n"); writer.Append("<tr><td>\n"); writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.PartialRefundResult", SkinID, LocaleSetting) + " " + PartialRefundResult + "</span>\n"); writer.Append("</td></tr>\n"); writer.Append("</table>\n"); } if (RetryPaymentID == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber")) { writer.Append("<table class=\"table\">\n"); writer.Append("<tr><td>\n"); writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.RetryPaymentResult", SkinID, LocaleSetting) + " " + RetryPaymentResult + "</span>\n"); writer.Append("</td></tr>\n"); writer.Append("</table>\n"); } if (RestartPaymentID == DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber")) { writer.Append("<table class=\"table\">\n"); writer.Append("<tr><td>\n"); writer.Append("<span class=\"h4\">" + AppLogic.GetString("admin.cst_history.RestartPaymentResult", SkinID, LocaleSetting) + " " + RestartPaymentResult + "</span>\n"); writer.Append("</td></tr>\n"); writer.Append("</table>\n"); } writer.Append(AppLogic.GetRecurringCart(parser, TargetCustomer, DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false, ShowCancelButton, ShowRetryButton, ShowRestartButton, GatewayStatus)); } } } } writer.Append("<div class=\"admin-module\">\n"); writer.Append("<h3>" + AppLogic.GetString("admin.orderframe.OrderHistory", SkinID, LocaleSetting) + "</h3>\n"); int N = 0; writer.Append("<table class=\"table\">\n"); writer.Append("<tr>\n"); writer.Append("<td><b>" + AppLogic.GetString("admin.common.OrderNumber", SkinID, LocaleSetting) + "</b></td>\n"); writer.Append("<td><b>" + AppLogic.GetString("admin.common.OrderDate", SkinID, LocaleSetting) + "</b></td>\n"); writer.Append("<td><b>" + AppLogic.GetString("admin.cst_history.PaymentStatus", SkinID, LocaleSetting) + "</b></td>\n"); writer.Append("<td><b>" + AppLogic.GetString("admin.common.ShippingStatus", SkinID, LocaleSetting) + "</b></td>\n"); writer.Append("<td><b>" + AppLogic.GetString("admin.common.OrderTotal", SkinID, LocaleSetting) + "</b></td>\n"); if (AppLogic.AppConfigBool("ShowCustomerServiceNotesInReceipts")) { writer.Append("<td><b>" + AppLogic.GetString("admin.cst_history.CustomerServiceNotes", SkinID, LocaleSetting) + "</b></td>\n"); } writer.Append("</tr>\n"); using (var dbconn = DB.dbConn()) { dbconn.Open(); using (var rs = DB.GetRS("Select '' Failed, PaymentGateway, PaymentMethod, ShippedOn, ShippedVIA, ShippingTrackingNumber, OrderNumber, OrderDate, OrderTotal, cast(CustomerServiceNotes as nvarchar(4000)) CustomerServiceNotes, TransactionState, DownloadEMailSentOn, CustomerID, RecurringSubscriptionID from orders with (NOLOCK) where CustomerID=" + TargetCustomer.CustomerID.ToString() + " union select 'Failed' Failed, PaymentGateway, PaymentMethod, null ShippedOn, null ShippedVIA, null ShippingTrackingNumber, OrderNumber, OrderDate, null OrderTotal, cast(TransactionResult as nvarchar(4000)) CustomerServiceNotes, null TransactionState, null DownloadEMailSentOn, CustomerID, RecurringSubscriptionID from FailedTransaction with (NOLOCK) where CustomerID=" + TargetCustomer.CustomerID.ToString() + " order by OrderDate desc", dbconn)) { while (rs.Read()) { String PaymentStatus = String.Empty; if (DB.RSField(rs, "PaymentMethod").Length != 0) { PaymentStatus = AppLogic.GetString("admin.order.PaymentMethod", SkinID, LocaleSetting) + " " + DB.RSField(rs, "PaymentMethod") + "<br/>"; } else { PaymentStatus = AppLogic.GetString("admin.order.PaymentMethod", SkinID, LocaleSetting) + " " + CommonLogic.IIF(DB.RSField(rs, "CardNumber").StartsWith(AppLogic.ro_PMPayPal, StringComparison.InvariantCultureIgnoreCase), AppLogic.ro_PMPayPal, "Credit Card") + "<br/>"; } if (DB.RSField(rs, "RecurringSubscriptionID").Length > 0 && DB.RSField(rs, "PaymentGateway") == AspDotNetStorefrontGateways.Gateway.ro_GWPAYFLOWPRO) { // include link to recurringgatewaydetails.aspx for live gateway status PaymentStatus += "Subscription ID: <a href=\"" + AppLogic.AdminLinkUrl("recurringgatewaydetails.aspx") + "?RecurringSubscriptionID=" + DB.RSField(rs, "RecurringSubscriptionID") + "\">" + DB.RSField(rs, "RecurringSubscriptionID") + "</a><br/>"; } String ShippingStatus = String.Empty; if (AppLogic.OrderHasShippableComponents(DB.RSFieldInt(rs, "OrderNumber"))) { if (DB.RSFieldDateTime(rs, "ShippedOn") != System.DateTime.MinValue) { ShippingStatus = "Shipped"; if (DB.RSField(rs, "ShippedVIA").Length != 0) { ShippingStatus += " via " + DB.RSField(rs, "ShippedVIA"); } ShippingStatus += " on " + Localization.ToThreadCultureShortDateString(DB.RSFieldDateTime(rs, "ShippedOn")) + "."; if (DB.RSField(rs, "ShippingTrackingNumber").Length != 0) { ShippingStatus += " " + AppLogic.GetString("admin.orderframe.TrackingNumber", SkinID, LocaleSetting) + " "; String TrackURL = Shipping.GetTrackingURL(DB.RSField(rs, "ShippingTrackingNumber")); if (TrackURL.Length != 0) { ShippingStatus += "<a href=\"" + TrackURL + "\" target=\"_blank\">" + DB.RSField(rs, "ShippingTrackingNumber") + "</a>"; } else { ShippingStatus += DB.RSField(rs, "ShippingTrackingNumber"); } } } else { ShippingStatus = AppLogic.GetString("admin.cst_history.NotYetShipped", SkinID, LocaleSetting); } } if (AppLogic.OrderHasDownloadComponents(DB.RSFieldInt(rs, "OrderNumber"), true)) { if (DB.RSField(rs, "TransactionState") == AppLogic.ro_TXStateCaptured && DB.RSFieldDateTime(rs, "DownloadEMailSentOn") != System.DateTime.MinValue) { if (ShippingStatus.Length != 0) { ShippingStatus += "<hr size=\"1\"/>"; } } else { if (ShippingStatus.Length == 0) { ShippingStatus += AppLogic.GetString("admin.cst_history.DownloadListPendingPayment", SkinID, LocaleSetting); } } } writer.Append("<tr>\n"); writer.Append("<td>"); writer.Append("<a href=\"" + AppLogic.AdminLinkUrl("order.aspx") + "?ordernumber=" + DB.RSFieldInt(rs, "OrderNumber").ToString() + "\">" + DB.RSFieldInt(rs, "OrderNumber").ToString() + "</a>"); writer.Append("<br/><br/>"); if (string.IsNullOrEmpty(DB.RSField(rs, "Failed"))) { var urlHelper = DependencyResolver.Current.GetService <UrlHelper>(); writer.AppendFormat(@"<a href=""{0}"" target=""_blank"">{1}</a>", urlHelper.Action( actionName: ActionNames.Index, controllerName: ControllerNames.Receipt, routeValues: new { OrderNumber = DB.RSFieldInt(rs, "OrderNumber") }), AppLogic.GetString("admin.cst_history.PrintableReceipt", SkinID, LocaleSetting)); } else { writer.Append("<font color=\"red\">" + DB.RSField(rs, "Failed") + "</font>"); } writer.Append("</td>"); writer.Append("<td>" + Localization.ToNativeDateTimeString(DB.RSFieldDateTime(rs, "OrderDate"))); writer.Append("</td>"); writer.Append("<td>" + PaymentStatus + " " + "</td>"); writer.Append("<td>" + ShippingStatus + " " + "</td>"); writer.Append("<td>" + ThisCustomer.CurrencyString(DB.RSFieldDecimal(rs, "OrderTotal")) + "</td>"); if (AppLogic.AppConfigBool("ShowCustomerServiceNotesInReceipts")) { if (DB.RSField(rs, "CustomerServiceNotes").Length > 110) { writer.Append("<td><textarea READONLY rows=\"10\" cols=\"50\">" + DB.RSField(rs, "CustomerServiceNotes") + "</textarea></td>"); } else { writer.Append("<td>" + CommonLogic.IIF(DB.RSField(rs, "CustomerServiceNotes").Length == 0, "None", DB.RSField(rs, "CustomerServiceNotes")) + "</td>"); } } else { writer.Append(" "); } writer.Append("</tr>\n"); N++; } } } writer.Append("</table>\n"); if (N == 0) { writer.Append("<p align=\"left\">" + AppLogic.GetString("admin.common.NoOrdersFound", SkinID, LocaleSetting) + "</p>\n"); } } ltContent.Text = writer.ToString(); }
protected void Page_Load(object sender, System.EventArgs e) { if (ThisCustomer.IsAdminUser || AppLogic.AppConfigBool("UseStrongPwd")) { ctrlAccount.PasswordNote = AppLogic.GetString("account.strongPassword", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); } RequireSecurePage(); Checkout = CommonLogic.QueryStringBool("checkout"); RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING")); SectionTitle = AppLogic.GetString("account.aspx.56", SkinID, ThisCustomer.LocaleSetting); ctrlAccount.Attributes.Add("Disabled", ""); if (Checkout) { GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon(); if (checkoutByAmazon.IsCheckingOut) { pnlCBAAddressWidget.Visible = true; litCBAAddressWidget.Text = checkoutByAmazon.RenderAddressWidgetWithRedirect("CBAAddressWidgetContainer", Server.UrlEncode("account.aspx?checkout=true"), new Guid(ThisCustomer.CustomerGUID), 300, 200); litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource(); pnlAddress.Visible = false; } ThisCustomer.RequireCustomerRecord(); CheckoutSteps.Visible = true; } else { CheckoutSteps.Visible = false; } lblErrorMessage.Text = String.Empty; pnlErrorMsg.Visible = false; lblAcctUpdateMsg.Text = String.Empty; var status = new StringBuilder(); bool newAccount = CommonLogic.QueryStringBool("newaccount"); if (newAccount) { lblErrorMessage.Text = AppLogic.GetString("createaccount.aspx.86", SkinID, ThisCustomer.LocaleSetting); pnlErrorMsg.Visible = true; } ThisCustomer.ValidatePrimaryAddresses(); bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout"); if (!AllowShipToDifferentThanBillTo) { pnlShipping.Visible = false; } //If there is a DeleteID remove it from the cart int DeleteID = CommonLogic.QueryStringUSInt("DeleteID"); if (DeleteID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, DeleteID)) { Order originalOrder = new Order(DeleteID); RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser); ExpressAPIType expressApiType = PayPalController.GetAppropriateExpressType(); if (originalOrder.PaymentMethod == AppLogic.ro_PMPayPalExpress && expressApiType == ExpressAPIType.PayPalExpress) { status.Append(rmgr.CancelPPECRecurringOrder(DeleteID, false)); } else { status.Append(rmgr.CancelRecurringOrder(DeleteID)); } } //If there is a FullRefundID refund it int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID"); if (FullRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, FullRefundID)) { RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser); status.Append(rmgr.ProcessAutoBillFullRefund(FullRefundID)); } //If there is a PartialRefundID refund it int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID"); if (PartialRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, PartialRefundID)) { RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser); status.Append(rmgr.ProcessAutoBillPartialRefund(PartialRefundID)); } //do not display an error message saying OK lblErrorMessage.Text = status.ToString() != AppLogic.ro_OK ? status.ToString() : String.Empty; pnlErrorMsg.Visible = lblErrorMessage.Text.Length > 0; if (!this.IsPostBack) { RefreshPage(); SetAccountFields(); if (ThisCustomer.IsRegistered) { this.hdnCustomerLevel1.Text = ThisCustomer.CustomerLevelID.ToString(); } else { hdnCustomerLevel1.Text = "-1"; } } }
public ActionResult PlaceOrder(CheckoutIndexPostModel model) { // Get the current checkout state var customer = HttpContext.GetCustomer(); var storeId = AppLogic.StoreID(); var checkoutConfiguration = CheckoutConfigurationProvider.GetCheckoutConfiguration(); var selectedPaymentMethod = PaymentMethodInfoProvider .GetPaymentMethodInfo( paymentMethod: customer.RequestedPaymentMethod, gateway: AppLogic.ActivePaymentGatewayCleaned()); // update checkboxes UpdateOver13(model.Over13Selected, customer); UpdateOkToEmail(model.OkToEmailSelected, customer); UpdateTermsAndConditions(model.TermsAndConditionsAccepted, customer); var persistedCheckoutContext = PersistedCheckoutContextProvider .LoadCheckoutContext(customer); UpdateCustomerEmail(persistedCheckoutContext.Email, customer); var cartContext = CartContextProvider .LoadCartContext( customer: customer, configuration: checkoutConfiguration, persistedCheckoutContext: persistedCheckoutContext, selectedPaymentMethod: selectedPaymentMethod); var checkoutSelectionContext = CheckoutSelectionProvider .GetCheckoutSelection( customer: customer, persistedCheckoutContext: persistedCheckoutContext, selectedPaymentMethod: selectedPaymentMethod); var result = CheckoutEngine .EvaluateCheckout( customer: customer, configuration: checkoutConfiguration, persistedCheckoutContext: persistedCheckoutContext, checkoutSelectionContext: checkoutSelectionContext, storeId: storeId, cartContext: cartContext); var action = GetActionForState(result.State); var checkoutEngineUpdates = CheckoutSelectionProvider.ApplyCheckoutSelections(customer, result.Selections); customer = checkoutEngineUpdates.Customer; persistedCheckoutContext = checkoutEngineUpdates.PersistedCheckoutContext; selectedPaymentMethod = checkoutEngineUpdates.SelectedPaymentMethod; if (action != CheckoutAction.Complete) { NoticeProvider.PushNotice("Please complete the required areas below before you place your order", NoticeType.Failure); } // Only place the order if checkout is complete. if (action != CheckoutAction.Complete) { return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout, new RouteValueDictionary { { RouteDataKeys.ShowErrors, true } })); } var billingAddress = new Address(); billingAddress.LoadByCustomer(customer.CustomerID, customer.PrimaryBillingAddressID, AddressTypes.Billing); //Save customer context to the 'permanent' places it needs to go SaveCustomerContextToDB(selectedPaymentMethod, persistedCheckoutContext, customer, billingAddress); //Reload the customer so it's got the new CustomerSession values customer = new Customer(customer.CustomerID); var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()); var orderNumber = 0; var gatewayToUse = AppLogic.ActivePaymentGatewayCleaned(); var paymentMethod = selectedPaymentMethod == null ? null : selectedPaymentMethod.Name; var giftCardOrder = cart.GiftCardCoversTotal(); if (selectedPaymentMethod == null) { orderNumber = AppLogic.GetNextOrderNumber(); var status = Gateway.MakeOrder(string.Empty, AppLogic.TransactionMode(), cart, orderNumber, string.Empty, string.Empty, string.Empty, string.Empty); if (status != AppLogic.ro_OK) { NoticeProvider.PushNotice(status, NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } } else if (paymentMethod == AppLogic.ro_PMCreditCard) { //2checkout has own 3dsecure if (gatewayToUse == Gateway.ro_GWTWOCHECKOUT) { return(RedirectToAction(ActionNames.TwoCheckout, ControllerNames.TwoCheckout)); } //Set up some special info for Braintree if (gatewayToUse == Gateway.ro_GWBRAINTREE && !giftCardOrder) { customer.ThisCustomerSession[AppLogic.Braintree3dSecureKey] = persistedCheckoutContext.Braintree.ThreeDSecureApproved.ToString(); customer.ThisCustomerSession[AppLogic.BraintreeNonceKey] = persistedCheckoutContext.Braintree.Nonce.ToString(); customer.ThisCustomerSession[AppLogic.BraintreePaymentMethod] = persistedCheckoutContext.Braintree.PaymentMethod; } var status = string.Empty; orderNumber = AppLogic.GetNextOrderNumber(); if (Cardinal.EnabledForCheckout(cart.Total(true), billingAddress.CardType) && gatewayToUse != Gateway.ro_GWBRAINTREE) //Braintree has its own native 3dSecure support { if (Cardinal.PreChargeLookupAndStoreSession( customer, orderNumber, cart.Total(true), billingAddress.CardNumber, billingAddress.CardExpirationMonth, billingAddress.CardExpirationYear) && gatewayToUse != Gateway.ro_GWBRAINTREE) { return(RedirectToAction(ActionNames.ThreeDSecure, ControllerNames.ThreeDSecure)); } else { // user not enrolled or cardinal gateway returned error, so process card normally, using already created order #: var eciFlag = Cardinal.GetECIFlag(billingAddress.CardType); status = Gateway.MakeOrder(string.Empty, AppLogic.TransactionMode(), cart, orderNumber, string.Empty, eciFlag, string.Empty, string.Empty); CleanupPaymentMethod(new AppliedPaymentMethodCleanupContext( customer: customer, orderNumber: orderNumber, status: status, paymentMethod: paymentMethod)); if (status != AppLogic.ro_OK) { NoticeProvider.PushNotice(status, NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } DB.ExecuteSQL("update orders set CardinalLookupResult=" + DB.SQuote(customer.ThisCustomerSession["Cardinal.LookupResult"]) + " where OrderNumber=" + orderNumber.ToString()); } } else { status = Gateway.MakeOrder(string.Empty, AppLogic.TransactionMode(), cart, orderNumber, string.Empty, string.Empty, string.Empty, string.Empty); CleanupPaymentMethod(new AppliedPaymentMethodCleanupContext( customer: customer, orderNumber: orderNumber, status: status, paymentMethod: paymentMethod, gateway: gatewayToUse)); if (status == AppLogic.ro_3DSecure) { // If credit card is enrolled in a 3D Secure service (Verified by Visa, etc.) return(RedirectToAction(ActionNames.ThreeDSecure, ControllerNames.ThreeDSecure)); } if (status != AppLogic.ro_OK) { NoticeProvider.PushNotice(status, NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } } } else if (paymentMethod == AppLogic.ro_PMPayPalExpress || paymentMethod == AppLogic.ro_PMPayPalExpressMark) { if (persistedCheckoutContext.PayPalExpress == null || string.IsNullOrEmpty(persistedCheckoutContext.PayPalExpress.Token)) { NoticeProvider.PushNotice("The PaypalExpress checkout token has expired, please re-login to your PayPal account or checkout using a different method of payment.", NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } orderNumber = AppLogic.GetNextOrderNumber(); var effectiveBillingAddress = new Address(); effectiveBillingAddress.LoadByCustomer(customer.CustomerID, customer.PrimaryBillingAddressID, AddressTypes.Billing); effectiveBillingAddress.PaymentMethodLastUsed = paymentMethod; effectiveBillingAddress.CardNumber = string.Empty; effectiveBillingAddress.CardType = string.Empty; effectiveBillingAddress.CardExpirationMonth = string.Empty; effectiveBillingAddress.CardExpirationYear = string.Empty; effectiveBillingAddress.CardName = string.Empty; effectiveBillingAddress.CardStartDate = string.Empty; effectiveBillingAddress.CardIssueNumber = string.Empty; effectiveBillingAddress.UpdateDB(); var transactionContext = new Dictionary <string, string> { { "TENDER", "P" } }; gatewayToUse = PayPalController.GetAppropriateExpressType() == ExpressAPIType.PayFlowPro ? Gateway.ro_GWPAYFLOWPRO : string.Empty; var status = Gateway.MakeOrder( gatewayToUse, AppLogic.TransactionMode(), cart, orderNumber, persistedCheckoutContext.PayPalExpress.Token, persistedCheckoutContext.PayPalExpress.PayerId, persistedCheckoutContext.PayPalExpress.Token, string.Empty, transactionContext); CleanupPaymentMethod(new AppliedPaymentMethodCleanupContext( customer: customer, orderNumber: orderNumber, status: status, paymentMethod: selectedPaymentMethod.Name, gateway: gatewayToUse)); if (status != AppLogic.ro_OK) { NoticeProvider.PushNotice(status, NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } } else if (paymentMethod == AppLogic.ro_PMPayPalEmbeddedCheckout) { var returnUrl = Url.Action( actionName: ActionNames.Ok, controllerName: ControllerNames.PayPalPaymentsAdvanced, routeValues: null, protocol: Uri.UriSchemeHttps); var errorUrl = Url.Action( actionName: ActionNames.Error, controllerName: ControllerNames.PayPalPaymentsAdvanced, routeValues: null, protocol: Uri.UriSchemeHttps); var cancelUrl = Url.Action( actionName: ActionNames.Index, controllerName: ControllerNames.Checkout, routeValues: null, protocol: Uri.UriSchemeHttps); var notifyUrl = Url.Action( actionName: ActionNames.Index, controllerName: ControllerNames.PayPalNotifications, routeValues: null, protocol: Uri.UriSchemeHttps); var silentPostUrl = Url.Action( actionName: ActionNames.Ok, controllerName: ControllerNames.PayPalPaymentsAdvanced, routeValues: null, protocol: Uri.UriSchemeHttps); var shippingAddress = customer.PrimaryShippingAddress ?? new Address(); var response = PayFlowProController.GetFramedHostedCheckout( cart: cart, ShippingAddress: shippingAddress, returnUrl: returnUrl, errorUrl: errorUrl, cancelUrl: cancelUrl, notifyUrl: notifyUrl, silentPostUrl: silentPostUrl); if (response.Result != 0) { throw new Exception("PayPal Payments Advanced is not configured properly."); } Session["PayPalEmbeddedCheckoutSecureToken"] = response.SecureToken; Session["PayPalEmbeddedCheckoutSecureTokenId"] = response.SecureTokenID; var redirectUrl = response.GetRedirectUrl(); return(Redirect(redirectUrl)); } else if (paymentMethod == AppLogic.ro_PMAmazonPayments || paymentMethod == AppLogic.ro_PMPurchaseOrder || paymentMethod == AppLogic.ro_PMRequestQuote || paymentMethod == AppLogic.ro_PMCheckByMail || paymentMethod == AppLogic.ro_PMCOD || paymentMethod == AppLogic.ro_PMMicropay) { orderNumber = AppLogic.GetNextOrderNumber(); var status = Gateway.MakeOrder(string.Empty, AppLogic.TransactionMode(), cart, orderNumber, string.Empty, string.Empty, string.Empty, string.Empty); CleanupPaymentMethod(new AppliedPaymentMethodCleanupContext( customer: customer, orderNumber: orderNumber, status: status, paymentMethod: selectedPaymentMethod.Name)); if (status != AppLogic.ro_OK) { NoticeProvider.PushNotice(status, NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } } return(RedirectToAction( ActionNames.Confirmation, ControllerNames.CheckoutConfirmation, new { orderNumber = orderNumber, paymentMethod = paymentMethod })); }