public IActionResult BinControl(string cardnumber) { var customer = _customerService.GetCustomerById(_workContext.CurrentCustomer.Id); var cart = _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart) .LimitPerStore(_storeContext.CurrentStore.Id) .ToList(); RetrieveInstallmentInfoRequest request = new RetrieveInstallmentInfoRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = customer.CustomerGuid.ToString(); request.BinNumber = cardnumber; decimal price = 0; foreach (var shoppingCartItem in cart) { price += (shoppingCartItem.Product.Price * shoppingCartItem.Quantity); } request.Price = _currencyService.ConvertFromPrimaryStoreCurrency(price, _workContext.WorkingCurrency).ToString("##.###").Replace(',', '.'); InstallmentInfo installmentInfo = InstallmentInfo.Retrieve(request, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings)); return(Json(installmentInfo)); }
public IActionResult Success(IFormCollection form) { var processor = _paymentService.LoadPaymentMethodBySystemName(IyzicoPayPaymentDefaults.SystemName) as IyzicoPayPaymentProcessor; if (processor == null || !_paymentService.IsPaymentMethodActive(processor) || !processor.PluginDescriptor.Installed) { throw new NopException("Iyzico module cannot be loaded"); } var model = new SuccessModel(); CreateThreedsPaymentRequest threquest = new CreateThreedsPaymentRequest(); threquest.Locale = Locale.TR.ToString(); threquest.PaymentId = form["paymentId"]; threquest.ConversationData = form["conversationData"]; threquest.ConversationId = form["conversationId"]; ThreedsPayment threedsPayment = ThreedsPayment.Create(threquest, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings)); if (threedsPayment.Status == "success") { if (form["mdStatus"] == "1") { var customer = _customerService.GetCustomerByGuid(new Guid(threedsPayment.ConversationId)); var query = _orderService.SearchOrders(customerId: customer.Id).ToList(); var order = query.FirstOrDefault(); order.PaymentStatus = threedsPayment.FraudStatus == 1 ? PaymentStatus.Paid : PaymentStatus.Pending; order.OrderStatus = OrderStatus.Processing; order.AuthorizationTransactionId = threedsPayment.PaymentId; order.AuthorizationTransactionCode = threedsPayment.AuthCode; order.PaidDateUtc = DateTime.UtcNow; var paymentrequest = new ProcessPaymentRequest(); var ordernote = new OrderNote(); ordernote.DisplayToCustomer = false; ordernote.CreatedOnUtc = DateTime.UtcNow; ordernote.Note = "Fraud:" + threedsPayment.FraudStatus; paymentrequest.CustomValues.Add("fraudstatus", threedsPayment.FraudStatus); foreach (var item in threedsPayment.PaymentItems) { ordernote.Note += string.Format("{0}{1}", item.ItemId, item.PaymentTransactionId); } order.OrderNotes.Add(ordernote); _orderService.UpdateOrder(order);; _orderService.UpdateOrder(order); if (_orderSettings.OnePageCheckoutEnabled) { return(RedirectToRoute("HomePage")); } return(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id })); } else { switch (form["mdStatus"]) { case "0": model.Errorr = "3-D Secure imzası geçersiz veya doğrulama"; break; case "2": model.Errorr = "Kart sahibi veya bankası sisteme kayıtlı değil"; break; case "3": model.Errorr = "Kartın bankası sisteme kayıtlı değil"; break; case "4": model.Errorr = "Doğrulama denemesi, kart sahibi sisteme daha sonra kayıt olmayı seçmiş"; break; case "5": model.Errorr = "Doğrulama yapılamıyor"; break; case "6": model.Errorr = "3-D Secure hatası"; break; case "7": model.Errorr = "Sistem hatası"; break; case "8": model.Errorr = "Bilinmeyen kart no"; break; default: model.Errorr = "Hata Oluştu"; break; } return(View("~/Plugins/Payments.IyzicoPay/Views/Success.cshtml", model)); } } else { model.Errorr = threedsPayment.ErrorMessage; return(View("~/Plugins/Payments.IyzicoPay/Views/Success.cshtml", model)); } }