public void ExecutePayStatus(string paykey, string strmaxAmount) { StringBuilder dataToSend = new StringBuilder(); string strRequest = null; strRequest = strRequest + "requestEnvelope.errorLanguage=" + NopContext.Current.WorkingLanguage.LanguageCulture; strRequest = strRequest + "&requestEnvelope.detailLevel=ReturnAll"; strRequest = strRequest + "&payKey=" + paykey; strRequest = strRequest + "&returnUrl=" + ConfigurationManager.AppSettings["returnUrl"];// "https://localhost:8091/SewbieDemo/PaypalAPRedirect.aspx"; dataToSend.Append(strRequest); string Execute_strEndpointURL = ConfigurationManager.AppSettings["ExecuteDetails_strEndpointURL"]; try { string strResponse = this.GetResponce(dataToSend, Execute_strEndpointURL); string[] strSplited = strResponse.Split('&'); string strPayKey = null; string strTmp = strSplited[1]; strTmp = strTmp.Substring(21, 7); if (strTmp == "Success") { strPayKey = strSplited[4]; strPayKey = strPayKey.Substring(7, 20); int j = 0; string strTransactionIds = ""; string strStatus = ""; for (int i = 0; i < strSplited.Length; i++) { if (strSplited[i].Contains("paymentInfoList.paymentInfo(" + j.ToString() + ").senderTransactionId=")) { if (string.IsNullOrEmpty(strTransactionIds)) strTransactionIds = strSplited[i].Split('=')[1].ToString(); else strTransactionIds += "," + strSplited[i].Split('=')[1].ToString(); j++; } if (strSplited[i].Contains("status=")) strStatus = strSplited[i].Split('=')[1].ToString(); } if (strStatus == "CREATED") { Response.Redirect(ConfigurationManager.AppSettings["PayPalSuccessReturnUrl"] + strmaxAmount + "&strTransactionIds=" + strTransactionIds + "&strStatus=" + strStatus); } var paymentInfo = this.PaymentInfo; paymentInfo = new BusinessLogic.Payment.PaymentInfo(); paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress; paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress; paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage; paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency; paymentInfo.PaymentMethodId = 43; int orderId = 0; string result = this.OrderService.PlaceOrder(paymentInfo, NopContext.Current.User, out orderId); this.PaymentInfo = null; var order = this.OrderService.GetOrderById(orderId); if (txtNoteToSeller.Value.Trim().Length > 0) { OrderService.InsertOrderNote(orderId, txtNoteToSeller.Value.Trim(), DateTime.Now); } if (!String.IsNullOrEmpty(result)) { lConfirmOrderError.Text = Server.HtmlEncode(result); return; } else { // hidPaypalURL.Value = this.PaymentService.PostProcessPayment(order); } var args2 = new CheckoutStepEventArgs() { OrderConfirmed = true }; if (hidPaypalURL.Value != String.Empty) { //redirect via javascript, directly into the frame. //Response.Redirect(hidPaypalURL.Value, false); } else { OnCheckoutStepChanged(args2); } Response.Redirect(ConfigurationManager.AppSettings["PayPalSuccessReturnUrl"] + strmaxAmount + "&strTransactionIds=" + strTransactionIds + "&strStatus=" + strStatus); } } catch (Exception ex) { Response.Redirect(ConfigurationManager.AppSettings["PayPalSuccessReturnUrl"] + strmaxAmount + "&strStatus=Failed" + "&strTransactionIds="); } }
protected void btnNextStep_Click(object sender, EventArgs e) { if (Page.IsValid) { try { var paymentInfo = this.PaymentInfo; if (paymentInfo == null) { var args1 = new CheckoutStepEventArgs() { OrderConfirmed = false }; OnCheckoutStepChanged(args1); if (!this.OnePageCheckout) { Response.Redirect("~/checkoutpaymentinfo.aspx"); } } if (!this.OnePageCheckout) Response.Redirect("~/checkoutcompleted.aspx"); else { if (txtNoteToSeller.Value.Trim().Length > 0) { Session["txtNoteToSeller"]= txtNoteToSeller.Value.Trim(); } if (Session["Vendor_Based_amt_List"] != null) { List<ShoppingCartItem> vendorList = (List<ShoppingCartItem>)Session["Vendor_Based_amt_List"]; decimal tempamount = 0; foreach (ShoppingCartItem item in vendorList) { tempamount += item.CustomerEnteredPrice; } if (paymentInfo == null) paymentInfo = new BusinessLogic.Payment.PaymentInfo(); paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress; paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress; paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage; paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency; paymentInfo.PaymentMethodId = 43; Order result = this.OrderService.TotalAmountForPayment(paymentInfo, NopContext.Current.User); foreach (ShoppingCartItem item in vendorList) { Order result1 = this.OrderService.VendorBasedTotalAmountForPayment(paymentInfo, NopContext.Current.User, item.VendorID); if (result1 != null) item.CustomerEnteredPrice = result1.OrderTotalInCustomerCurrency; } Session["Vendor_Based_amt_List"] = vendorList; amount =result.OrderTotalInCustomerCurrency.ToString(); PreApproved(amount.ToString()); } else Response.Redirect("~/shoppingcart.aspx"); } } catch (Exception exc) { this.LogService.InsertLog(LogTypeEnum.OrderError, exc.Message, exc); lConfirmOrderError.Text = Server.HtmlEncode(exc.ToString()); } } else { foreach (System.Web.UI.IValidator poo in Page.Validators) { if (!poo.IsValid) { if (lConfirmOrderError.Text == String.Empty) { lConfirmOrderError.Text = poo.ErrorMessage; } else { lConfirmOrderError.Text += poo.ErrorMessage; } } } } }
public void OrderTotalCalculation() { var paymentInfo = this.PaymentInfo; if (paymentInfo == null) paymentInfo = new BusinessLogic.Payment.PaymentInfo(); paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress; paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress; paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage; paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency; paymentInfo.PaymentMethodId = 10; Order result; if (NopContext.Current.User.IsGuest) { result = this.OrderService.VendorBasedTotalAmountForGuestPayment(paymentInfo, NopContext.Current.User, vendorId); } else { result = this.OrderService.VendorBasedTotalAmountForPayment(paymentInfo, NopContext.Current.User, vendorId); } lblSubTotalAmount.Text = PriceHelper.FormatPrice(result.OrderSubtotalInclTaxInCustomerCurrency); lblSubTotalAmount.CssClass = "productPrice"; lblShippingAmount.Text = PriceHelper.FormatShippingPrice(result.OrderShippingInclTaxInCustomerCurrency, true); lblShippingAmount.CssClass = "productPrice"; lblTotalAmount.Text = PriceHelper.FormatPrice(result.OrderTotalInCustomerCurrency, true, false); lblTotalAmount.CssClass = "productPrice"; if (result.OrderSubTotalDiscountInclTaxInCustomerCurrency > 0) { lblOrderSubTotalDiscountAmount.Text = PriceHelper.FormatPrice(-result.OrderSubTotalDiscountInclTaxInCustomerCurrency); phOrderSubTotalDiscount.Visible = true; } else phOrderSubTotalDiscount.Visible = false; if (result.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency > 0) { lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(result.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, true); } else phPaymentMethodAdditionalFee.Visible = false; //if (result.OrderTaxInCustomerCurrency > 0) //{ lblTaxAmount.Text = PriceHelper.FormatPrice(result.OrderTaxInCustomerCurrency, true, false); //} //else // phTaxTotal.Visible = false; if (result.OrderDiscountInCustomerCurrency > 0) { lblOrderTotalDiscountAmount.Text = PriceHelper.FormatPrice(-result.OrderDiscountInCustomerCurrency, true, false); phOrderTotalDiscount.Visible = true; } else phOrderTotalDiscount.Visible = false; if (result.RedeemedRewardPoints != null) { phRewardPoints.Visible = true; lRewardPointsTitle.Text = string.Format(GetLocaleResourceString("ShoppingCart.Totals.RewardPoints"), result.RedeemedRewardPoints.Points.ToString()); lblRewardPointsAmount.Text = PriceHelper.FormatPrice(-result.RedeemedRewardPoints.UsedAmountInCustomerCurrency, true, false); } else { phRewardPoints.Visible = false; } }