protected void Page_Load(object sender, System.EventArgs e) { Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); Customer ThisCustomer = Context.GetCustomer(); pnlOrderNumberInput.Visible = false; pnlSubscriptionIdInput.Visible = false; pnlResults.Visible = false; if (!ThisCustomer.IsAdminUser) // safety check { ctrlAlertMessage.PushAlertMessage("PERMISSION DENIED", AlertMessage.AlertType.Error); } else { String RecurringSubscriptionID = CommonLogic.QueryStringCanBeDangerousContent("RecurringSubscriptionID"); int OriginalRecurringOrderNumber = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber"); if (RecurringSubscriptionID.Length == 0 && OriginalRecurringOrderNumber > 0) { RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber); } if (OriginalRecurringOrderNumber == 0 && RecurringSubscriptionID.Length != 0) { OriginalRecurringOrderNumber = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(RecurringSubscriptionID); } if (OriginalRecurringOrderNumber == 0 || RecurringSubscriptionID.Length == 0) { ctrlAlertMessage.PushAlertMessage("Need Original Order Number or Subscription ID", AlertMessage.AlertType.Error); pnlOrderNumberInput.Visible = true; pnlSubscriptionIdInput.Visible = true; } else if (OriginalRecurringOrderNumber > 0 && RecurringSubscriptionID.Length == 0) { ctrlAlertMessage.PushAlertMessage("Subscription ID was not found for Order Number", AlertMessage.AlertType.Error); pnlOrderNumberInput.Visible = true; pnlSubscriptionIdInput.Visible = true; } else { pnlResults.Visible = true; String GW = AppLogic.ActivePaymentGatewayCleaned(); if (GW == Gateway.ro_GWPAYFLOWPRO) { txtResults.Text = PayFlowProController.RecurringBillingInquiryDisplay(RecurringSubscriptionID); } else { ctrlAlertMessage.PushAlertMessage("Gateway " + GW + " not supported.", AlertMessage.AlertType.Error); } } } Page.Form.DefaultFocus = txtOrderNumber.ClientID; }
public ActionResult Ok() { var customer = HttpContext.GetCustomer(); var formString = Request.Form.ToString(); var postData = string.IsNullOrEmpty(formString) ? Request.QueryString.ToString() : formString; //Successful order callback - make the order and send to confirmation if (!string.IsNullOrEmpty(postData)) { var parameterDictionary = PayFlowProController.GetParameterStringAsDictionary(postData, true); var processor = new PayPalEmbeddedCheckoutCallBackProcessor(parameterDictionary, customer); var redirectRoute = processor.ProcessCallBack(); return(new RedirectResult(redirectRoute)); } //Customer ended up here after the order was created - send them to confirmation var orderNumber = DB.GetSqlN( "select MAX(OrderNumber) N from dbo.orders where CustomerID = @customerId", new SqlParameter("customerId", customer.CustomerID)); var confirmationUrl = Url.Action( ActionNames.Confirmation, ControllerNames.CheckoutConfirmation, new { orderNumber = orderNumber }); return(Redirect(confirmationUrl)); }
public String ProcessAutoBillRestartPayment(int OriginalRecurringOrderNumber) { // retry a payment for the current billing period after the gateway auto-bill attempt failed String Status = AppLogic.ro_OK; String GW = AppLogic.ActivePaymentGatewayCleaned(); String RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber); if (RecurringSubscriptionID.Length != 0) { if (GW == Gateway.ro_GWPAYFLOWPRO) { if (Status == AppLogic.ro_OK) { Status = PayFlowProController.RecurringBillingRestartPayment(RecurringSubscriptionID, OriginalRecurringOrderNumber); } } else { Status = "Invalid Gateway"; } } if (AppLogic.AppConfigBool("AuditLog.Enabled")) { StringBuilder sbDetails = new StringBuilder("Result=" + Status); sbDetails.Append(", RecurringSubscriptionID=" + RecurringSubscriptionID); int ProcessCustomerID = Order.GetOrderCustomerID(OriginalRecurringOrderNumber); AppLogic.AuditLogInsert(0, ProcessCustomerID, OriginalRecurringOrderNumber, "ProcessAutoBillRestartPayment", sbDetails.ToString(), CommonLogic.GetThisPageName(true), "RecurringOrderMgr"); } return(Status); }
public override void Initialize() { string returnUrl = string.Format("{0}fp-paypalembeddedcheckoutok.aspx", AppLogic.GetStoreHTTPLocation(true)); string errorUrl = string.Format("{0}fp-paypalembeddedcheckoutok.aspx", AppLogic.GetStoreHTTPLocation(true)); string cancelUrl = string.Format("{0}fp-shoppingcart.aspx", AppLogic.GetStoreHTTPLocation(true)); string notifyUrl = string.Format("{0}paypalnotification.aspx", AppLogic.GetStoreHTTPLocation(true)); string silentPostURL = string.Format("{0}paypalembeddedcheckoutok.aspx", AppLogic.GetStoreHTTPLocation(true)); PayPalEmbeddedCheckoutSecureTokenResponse response = PayFlowProController.GetFramedHostedCheckout(returnUrl, errorUrl, cancelUrl, notifyUrl, silentPostURL); if (response.Result != 0) { throw new Exception(AppLogic.GetString("paypalpaymentsadvanced.configerror", ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer.LocaleSetting)); } Session["PayPalEmbeddedCheckoutSecureToken"] = response.SecureToken; Session["PayPalEmbeddedCheckoutSecureTokenId"] = response.SecureTokenID; if (CommonLogic.QueryStringNativeInt("ErrorMsg") > 0) { ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("ErrorMsg")); ShowError(e.Message); } string frameSrc = response.GetFrameSrc(0, 400); litPayPalEmbeddedCheckoutFrame.Text = frameSrc; }
public String ProcessAutoBillGetGatewayStatus(int OriginalRecurringOrderNumber, out String RecurringSubscriptionID, out DateTime StartDate, out DateTime NextPaymentDate, out decimal AggregateAmount, out String RecurringStatus, out String LatestPaymentIdentifier, out DateTime EndingDate) { // retry a payment for the current billing period after the gateway auto-bill attempt failed String Status = AppLogic.ro_OK; String GW = AppLogic.ActivePaymentGatewayCleaned(); RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber); StartDate = DateTime.MinValue; NextPaymentDate = DateTime.MinValue; AggregateAmount = 0.0M; RecurringStatus = String.Empty; LatestPaymentIdentifier = String.Empty; EndingDate = DateTime.MinValue; if (RecurringSubscriptionID.Length != 0) { if (GW == Gateway.ro_GWPAYFLOWPRO) { Status = PayFlowProController.RecurringBillingInquiry(RecurringSubscriptionID, out StartDate, out NextPaymentDate, out AggregateAmount, out RecurringStatus, out LatestPaymentIdentifier, out EndingDate); } else { Status = "Invalid Gateway"; } } return(Status); }
public void Initialize() { //btnContCheckout.Visible = false; string returnUrl = string.Format("{0}fp-paypalembeddedcheckoutok.aspx", AppLogic.GetStoreHTTPLocation(true)); string errorUrl = string.Format("{0}fp-paypalembeddedcheckoutok.aspx", AppLogic.GetStoreHTTPLocation(true)); string cancelUrl = string.Format("{0}fp-shoppingcart.aspx", AppLogic.GetStoreHTTPLocation(true)); string notifyUrl = string.Format("{0}paypalnotification.aspx", AppLogic.GetStoreHTTPLocation(true)); string silentPostURL = string.Format("{0}paypalembeddedcheckoutok.aspx", AppLogic.GetStoreHTTPLocation(true)); PayPalEmbeddedCheckoutSecureTokenResponse response = PayFlowProController.GetFramedHostedCheckout(returnUrl, errorUrl, cancelUrl, notifyUrl, silentPostURL); if (response.Result != 0) throw new Exception("PayPal Embedded Checkout is not configured properly."); Session["PayPalEmbeddedCheckoutSecureToken"] = response.SecureToken; Session["PayPalEmbeddedCheckoutSecureTokenId"] = response.SecureTokenID; if (CommonLogic.QueryStringNativeInt("ErrorMsg") > 0) { ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("ErrorMsg")); ShowError(e.Message); } string frameSrc = response.GetFrameSrc(0, 400); litPayPalEmbeddedCheckoutFrame.Text = frameSrc; }
public String ProcessAutoBillRetryPayment(int OriginalRecurringOrderNumber) { // retry a payment for the current billing period after the gateway auto-bill attempt failed String Status = AppLogic.ro_OK; String GW = AppLogic.ActivePaymentGatewayCleaned(); String RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber); if (RecurringSubscriptionID.Length != 0) { if (GW == Gateway.ro_GWPAYFLOWPRO) { DateTime StartDate = DateTime.MinValue; DateTime NextPaymentDate = DateTime.MinValue; Decimal AggregateAmount = 0.0M; String RecurringStatus = String.Empty; String LatestPaymentIdentifier = String.Empty; DateTime EndingDate = DateTime.MinValue; String tmpSubID = String.Empty; // Need to get the Current Payment Identifier before we attemp the retry. Status = ProcessAutoBillGetGatewayStatus(OriginalRecurringOrderNumber, out tmpSubID, out StartDate, out NextPaymentDate, out AggregateAmount, out RecurringStatus, out LatestPaymentIdentifier, out EndingDate); if (Status == AppLogic.ro_OK) { Status = PayFlowProController.RecurringBillingRetryPayment(RecurringSubscriptionID, OriginalRecurringOrderNumber, LatestPaymentIdentifier); } } else { Status = "Invalid Gateway"; } } if (AppLogic.AppConfigBool("AuditLog.Enabled")) { StringBuilder sbDetails = new StringBuilder("Result=" + Status); sbDetails.Append(", RecurringSubscriptionID=" + RecurringSubscriptionID); int ProcessCustomerID = Order.GetOrderCustomerID(OriginalRecurringOrderNumber); AppLogic.AuditLogInsert(0, ProcessCustomerID, OriginalRecurringOrderNumber, "ProcessAutoBillRetryPayment", sbDetails.ToString(), CommonLogic.GetThisPageName(true), "RecurringOrderMgr"); } return(Status); }
protected void Page_Load(object sender, System.EventArgs e) { Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); SectionTitle = "Recurring Subscription Gateway Details"; Customer ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer; pnlInput1.Visible = false; pnlInput2.Visible = false; pnlResults.Visible = false; if (!ThisCustomer.IsAdminUser) // safety check { ltError.Text = "<b><font color=red>PERMISSION DENIED</b></font>"; } else { String RecurringSubscriptionID = CommonLogic.QueryStringCanBeDangerousContent("RecurringSubscriptionID"); int OriginalRecurringOrderNumber = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber"); if (RecurringSubscriptionID.Length == 0 && OriginalRecurringOrderNumber > 0) { RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber); } if (OriginalRecurringOrderNumber == 0 && RecurringSubscriptionID.Length != 0) { OriginalRecurringOrderNumber = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(RecurringSubscriptionID); } if (OriginalRecurringOrderNumber == 0 || RecurringSubscriptionID.Length == 0) { ltError.Text = "<b><font color=red>Need Original Order Number or Subscription ID</b></font>"; pnlInput1.Visible = true; pnlInput2.Visible = true; } else if (OriginalRecurringOrderNumber > 0 && RecurringSubscriptionID.Length == 0) { ltError.Text = "<b><font color=red>Subscription ID was not found for Order Number " + OriginalRecurringOrderNumber.ToString() + "</b></font>"; pnlInput1.Visible = true; pnlInput2.Visible = true; } else { pnlResults.Visible = true; String GW = AppLogic.ActivePaymentGatewayCleaned(); ltResults.Text = "<strong>Results from Gateway:</strong><br />"; if (GW == Gateway.ro_GWVERISIGN || GW == Gateway.ro_GWPAYFLOWPRO) { ltResults.Text += PayFlowProController.RecurringBillingInquiryDisplay(RecurringSubscriptionID); } else { ltError.Text = "<b><font color=red>Gateway " + GW + " not supported.</b></font>"; } } } Page.Form.DefaultFocus = txtOrderNumber.ClientID; }
public String ProcessAutoBillGetAdminButtons(int OriginalRecurringOrderNumber, out bool ShowCancelButton, out bool ShowRetryButton, out bool ShowRestartButton, out String GatewayStatus) { String result = AppLogic.ro_OK; // These are the default values that will be returned for gateways // that don't support getting realtime status. ShowCancelButton = true; ShowRetryButton = false; ShowRestartButton = false; GatewayStatus = String.Empty; DateTime StartDate = DateTime.MinValue; DateTime NextPaymentDate = DateTime.MinValue; Decimal AggregateAmount = 0.0M; String RecurringStatus = String.Empty; String LatestPaymentIdentifier = String.Empty; DateTime EndingDate = DateTime.MinValue; String GW = AppLogic.ActivePaymentGatewayCleaned(); String RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber); if (RecurringSubscriptionID.Length != 0) { if (GW == Gateway.ro_GWPAYFLOWPRO) { result = PayFlowProController.RecurringBillingInquiry(RecurringSubscriptionID, out StartDate, out NextPaymentDate, out AggregateAmount, out RecurringStatus, out LatestPaymentIdentifier, out EndingDate); if (result == AppLogic.ro_OK) { GatewayStatus = "Payflow Gateway Status: " + RecurringStatus; switch (RecurringStatus) { case "VENDOR INACTIVE": ShowCancelButton = false; ShowRetryButton = false; ShowRestartButton = false; break; case "DEACTIVATED BY MERCHANT": ShowCancelButton = false; ShowRetryButton = false; ShowRestartButton = true; break; case "EXPIRED": ShowCancelButton = false; ShowRetryButton = false; ShowRestartButton = true; break; case "TOO MANY FAILURES": ShowCancelButton = false; ShowRetryButton = true; ShowRestartButton = true; break; case "ACTIVE": ShowCancelButton = true; ShowRetryButton = false; ShowRestartButton = false; break; case "RETRYING CURRENT PAYMENT": ShowCancelButton = true; ShowRetryButton = true; ShowRestartButton = false; break; } } } } return(result); }
protected void Page_Load(object sender, System.EventArgs e) { Customer thisCustomer; int customerId = 0; String postData = String.IsNullOrEmpty(Request.Form.ToString()) ? Request.QueryString.ToString() : Request.Form.ToString(); if (Request.Form["USER1"] != null && Request.Form["USER1"] != "" && int.TryParse(Request.Form["USER1"], out customerId)) //silent post { thisCustomer = new Customer(customerId, true); PayPalEmbeddedCheckoutCallBackProcessor processor = new PayPalEmbeddedCheckoutCallBackProcessor(PayFlowProController.GetParameterStringAsDictionary(postData, true), thisCustomer); string redirectPage = processor.ProccessCallBack(); } else if (!String.IsNullOrEmpty(Request.Form.ToString())) //notification (ipn) { } else // customer returning to site { if (QSResultCode == 0) { int OrderNumber = DB.GetSqlN("select MAX(OrderNumber) N from dbo.orders where CustomerID = " + ThisCustomer.CustomerID.ToString()); Response.Redirect("orderconfirmation.aspx?ordernumber=" + OrderNumber.ToString() + "&paymentmethod=PayPalEmbeddedCheckout", true); return; } ErrorMessage er = new ErrorMessage(QSResponseMessage); ShoppingCart cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false); var checkoutController = CheckOutPageControllerFactory.CreateCheckOutPageController(ThisCustomer, cart); Response.Redirect(checkoutController.GetCheckoutPaymentPage() + "?ErrorMsg=" + er.MessageId, true); } }
protected void Page_Load(object sender, System.EventArgs e) { Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); /****************************************************************************/ // * WARNING TO DEVELOPERS // * The redirect below is a SAFETY feature. Removing the redirect will not // * enable ML-only features on a lower version of AspDotNetStorefront. // * Attempting to do so can very easily result in a partially implemented // * feature, invalid or incomplete data in your DB, and other serious // * conditions that will cause your store to be non-functional. // * // * If you break your store attempting to enable ML-only features in PRO or // * Standard, our staff cannot help you fix it, and it will also invalidate // * your AspDotNetStorefront License. /***************************************************************************/ if (!AppLogic.m_ProductIsML()) { Response.Redirect(AppLogic.AdminLinkUrl("restrictedfeature.aspx")); } SectionTitle = "Recurring Subscription Gateway Details"; Customer ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer; pnlInput1.Visible = false; pnlInput2.Visible = false; pnlResults.Visible = false; if (!ThisCustomer.IsAdminUser) // safety check { ltError.Text = "<b><font color=red>PERMISSION DENIED</b></font>"; } else { String RecurringSubscriptionID = CommonLogic.QueryStringCanBeDangerousContent("RecurringSubscriptionID"); int OriginalRecurringOrderNumber = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber"); if (RecurringSubscriptionID.Length == 0 && OriginalRecurringOrderNumber > 0) { RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber); } if (OriginalRecurringOrderNumber == 0 && RecurringSubscriptionID.Length != 0) { OriginalRecurringOrderNumber = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(RecurringSubscriptionID); } if (OriginalRecurringOrderNumber == 0 || RecurringSubscriptionID.Length == 0) { ltError.Text = "<b><font color=red>Need Original Order Number or Subscription ID</b></font>"; pnlInput1.Visible = true; pnlInput2.Visible = true; } else if (OriginalRecurringOrderNumber > 0 && RecurringSubscriptionID.Length == 0) { ltError.Text = "<b><font color=red>Subscription ID was not found for Order Number " + OriginalRecurringOrderNumber.ToString() + "</b></font>"; pnlInput1.Visible = true; pnlInput2.Visible = true; } else { pnlResults.Visible = true; String GW = AppLogic.ActivePaymentGatewayCleaned(); ltResults.Text = "<strong>Results from Gateway:</strong><br />"; if (GW == Gateway.ro_GWVERISIGN || GW == Gateway.ro_GWPAYFLOWPRO) { ltResults.Text += PayFlowProController.RecurringBillingInquiryDisplay(RecurringSubscriptionID); } else { ltError.Text = "<b><font color=red>Gateway " + GW + " not supported.</b></font>"; } } } Page.Form.DefaultFocus = txtOrderNumber.ClientID; }
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 })); }