public ActionResult Create(FormCollection collection) { var model = new PaypalApi() { UserId = this.UserContext.LoginInfo.UserID, UserName = this.UserContext.LoginInfo.LoginName }; this.TryUpdateModel <PaypalApi>(model); try { if (ModelState.IsValid) { this.ImsService.SavePaypalApi(model); string url = Url.Action("Index", "PaypalApi"); return(Json(new { success = true, url = url })); } return(PartialView("Edit", model)); } catch (BusinessException e) { this.ModelState.AddModelError(e.Name, e.Message); return(PartialView("Edit", model)); } }
private void VerifyPaypalCheckout(SubscriberPaymentProviderInfo subscriberPaymentProvider) { string token = Request["token"]; if (subscriberPaymentProvider != null) { string[] userCredentials = subscriberPaymentProvider.PaymentProviderProperties.Split(','); PaypalUserCredentials cred = new PaypalUserCredentials(userCredentials[0], userCredentials[1], userCredentials[2]); PaypalApi.UseSandbox = (userCredentials.Length == 3 || (userCredentials.Length > 3 && Convert.ToBoolean(userCredentials[3]) == true)); string response = PaypalApi.GetExpressCheckoutDetails(cred, token); PaypalCommonResponse ppCommon = new PaypalCommonResponse(response); if (ppCommon.Ack == PaypalAckType.Success) { // TODO: Paypal Payerinfo auswerten ? PaypalPayerInfo payer = new PaypalPayerInfo(response); CustomerPaymentProviderInfo customerPaymentProvider = Controller.GetCustomerPaymentProvider(MainControl.Cart.CustomerPaymentProviderID); // Save token and payerid in customerpaymentprovider for later confirmation of payment in paypal customerPaymentProvider.PaymentProviderValues = ppCommon.Token + "," + payer.PayerId; Controller.UpdateCustomerPaymentProvider(customerPaymentProvider); Response.Redirect(Globals.NavigateURL(TabId, "", "action=" + MainControl.GetNextAction())); } else { string message = ""; foreach (PaypalError error in ppCommon.Errors) { message += String.Format("ErrorNo:{0} Message {1}<br/>\r\n", error.ErrorNo, error.LongMessage); } MainControl.ErrorText += message; } } }
public string PayPalTransactionProcessLongRunningAction(string id, int PaypalApi, string RangeDate) { using (ImsDbContext dbContext = new ImsDbContext()) { dbContext.Configuration.AutoDetectChangesEnabled = false; PaypalApi paypalApi = dbContext.PaypalApis.Find(PaypalApi); dbContext.Configuration.AutoDetectChangesEnabled = true; this.ImsService.PayPalHelper(paypalApi); string dataRange = RangeDate; string[] date = dataRange.Split(new char[] { '-' }); DateTime startDate = DateTime.Parse(date[0].Trim()); DateTime endDate = DateTime.Parse(date[1].Trim()); IEnumerable <PaymentTransactionSearchResultType> PaypalTransactionSearch = this.ImsService.ApiTransactionSearch(startDate, endDate); int total = PaypalTransactionSearch.Count <PaymentTransactionSearchResultType>(); if (PaypalTransactionSearch.Count() > 0) { var lastsearch = PaypalTransactionSearch.Last(); var lastdetail = this.ImsService.ApiTransactionDetail(lastsearch); ProcessLastDate = lastdetail.PaymentTransactionDetails.PaymentInfo.PaymentDate; } else { ProcessLastDate = startDate.ToCnDataString(); } int i = 0; // List<PayPalTransaction> pptlist = new List<PayPalTransaction>(); PaypalTransactionSearch.ToList().ForEach(a => { GetTransactionDetailsResponseType PaypalTransactionDetails = this.ImsService.ApiTransactionDetail(a); if (PaypalTransactionDetails.Ack.Equals(AckCodeType.SUCCESS)) { i++; int d = Precentage(i, total); lock (syncRoot) { ProcessStatus[id] = d; ProcessTotal = total; ProcessNumber = i + 1; } dbContext.Configuration.AutoDetectChangesEnabled = false; bool flag = dbContext.PayPalTransactions.AsNoTracking().Count(j => j.TransactionId == a.TransactionID) == 0; dbContext.Configuration.AutoDetectChangesEnabled = true; if (flag) { var detail = this.ImsService.PayPayTransaction(PaypalTransactionDetails); // pptlist.Add(detail); dbContext.Insert <PayPalTransaction>(detail); } } }); // dbContext.PayPalTransactions.AddRange(pptlist); // dbContext.SaveChanges(); } return(id); }
public string PaymentTransactionProcessLongRunningAction(string id, int PaypalApi, string RangeDate) { PaypalApi paypalApi = this.ImsService.GetPaypalApi(PaypalApi); this.ImsService.PayPalHelper(paypalApi); string dataRange = RangeDate; string[] date = dataRange.Split(new char[] { '-' }); DateTime startDate = DateTime.Parse(date[0].Trim()); DateTime endDate = DateTime.Parse(date[1].Trim()); IEnumerable <PaymentTransactionSearchResultType> PaypalTransactionSearch = this.ImsService.ApiTransactionSearch(startDate, endDate); var total = PaypalTransactionSearch.Count <PaymentTransactionSearchResultType>(); int i = 0; foreach (var item in PaypalTransactionSearch) { GetTransactionDetailsResponseType PaypalTransactionDetails = this.ImsService.ApiTransactionDetail(item); if (PaypalTransactionDetails.Ack.Equals(AckCodeType.SUCCESS)) { i++; int d = Precentage(i, total); lock (syncRoot) { ProcessStatus[id] = d; } /*TransactionDetailRequest request = new TransactionDetailRequest * { * TransactionID = item.TransactionID * };*/ PaymentTransactionRequest request = new PaymentTransactionRequest { TransactionID = item.TransactionID }; if (this.ImsService.GetPaymentTransactionList(request).Count() == 0) { var detail = this.ImsService.PaymentTransaction(PaypalTransactionDetails); using (var dbContext = new ImsDbContext()) { dbContext.Insert <Evisou.Ims.Contract.Model.PayPal.PaymentTransactionType>(detail); } } } } return(id); }
public ActionResult Create(FormCollection collection) { var model = new PaypalApi() { UserId = this.UserContext.LoginInfo.UserID, UserName = this.UserContext.LoginInfo.LoginName }; this.TryUpdateModel <PaypalApi>(model); this.ImsService.SavePaypalApi(model); return(this.RefreshParent()); }
private void StartPaypalCheckout(string properties, int paymentProviderId) { string[] props = properties.Split(','); PaypalApi.UseSandbox = (props.Length == 3 || (props.Length > 3 && Convert.ToBoolean(props[3]) == true)); PaypalUserCredentials cred = new PaypalUserCredentials(props[0], props[1], props[2]); PaypalSetExpressCheckoutParameters param = new PaypalSetExpressCheckoutParameters() { CancelUrl = Globals.NavigateURL(this.TabId, "", "action=payment", "provider=" + paymentProviderId.ToString(), "result=cancel"), ReturnUrl = Globals.NavigateURL(this.TabId, "", "action=payment", "provider=" + paymentProviderId.ToString(), "result=success"), NoShipping = 1, // PayPal does not display shipping address fields whatsoever. AllowNote = 0, // The buyer is unable to enter a note to the merchant. }; PaypalPaymentDetails request = new PaypalPaymentDetails(); CartInfo cart = Controller.GetCart(PortalId, MainControl.CartId); request.Amt = cart.OrderTotal + cart.AdditionalTotal + cart.OrderTax + cart.AdditionalTax; request.TaxAmt = cart.OrderTax + cart.AdditionalTax; request.ItemAmt = cart.OrderTotal + cart.AdditionalTotal; request.InvNum = cart.CartID.ToString(); request.CurrencyCode = "EUR"; List <PaypalPaymentDetailsItem> items = new List <PaypalPaymentDetailsItem>(); PaypalPaymentDetailsItem item = new PaypalPaymentDetailsItem(); item.Amt = request.ItemAmt; item.Name = String.Format(Localization.GetString("PPCart.Text", this.LocalResourceFile), Controller.GetStoreSettings(PortalId)["VendorName"] ?? "BBStore"); List <CartProductInfo> products = Controller.GetCartProducts(cart.CartID); item.Desc = ""; foreach (CartProductInfo product in products) { item.Desc += string.Format("{0} {1}\r\n", (product.Quantity % 1 == 0 ? (int)product.Quantity : product.Quantity), product.Name); } item.TaxAmt = request.TaxAmt; items.Add(item); string response = PaypalApi.SetExpressCheckout(cred, request, items, param); PaypalCommonResponse ppCommon = new PaypalCommonResponse(response); if (ppCommon.Ack == PaypalAckType.Success) { if (PaypalApi.UseSandbox) { Response.Redirect("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppCommon.Token); } else { Response.Redirect("https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppCommon.Token); } } else { string message = ""; foreach (PaypalError error in ppCommon.Errors) { message += String.Format("ErrorNo:{0} Message {1}<br/>\r\n", error.ErrorNo, error.LongMessage); } MainControl.ErrorText += message; } }
public ActionResult Create() { var model = new PaypalApi(); return(View("Edit", model)); }