public IActionResult RegisterPayment(PaymentInfoModel payment) { try { if (payment == null) { return(View()); } if (payment.IdZelle == 0) { var model = new PaymentZelle { IssuingEmail = payment.IssuingEmail, OrderId = payment.Order, ReferenceNumber = payment.Reference }; _zelleService.InsertPaymentZelle(model); } else { var model = new PaymentZelle { Id = payment.IdZelle, IssuingEmail = payment.IssuingEmail, ReferenceNumber = payment.Reference }; _zelleService.UpdatePaymentZelle(model); } ViewBag.RefreshPage = true; // return JavaScript("window.close();"); return(RedirectToRoute("OrderDetails", new { orderId = payment.Order })); } catch (Exception ex) { throw new NopException(ex.Message, ex); } }
public void InsertPayment(Consolidate payment) { try { if (payment == null) { throw new ArgumentNullException(nameof(payment)); } var order2 = _orderService.GetOrderById(payment.OrdenId); if (order2 == null) { throw new ArgumentNullException(nameof(payment.OrdenId)); } // datos de la orden payment.MetodoPago = order2.PaymentMethodSystemName; payment.CodigoMoneda = order2.CustomerCurrencyCode; payment.TiendaId = order2.StoreId; payment.ClienteId = order2.CustomerId; payment.StatusPaymentOrder = order2.PaymentStatusId; switch (payment.MetodoPago) { case "Payments.Transfer": { try { var paymentTransfer = _transferServices.GetPaymentTransferByOrderId(payment.OrdenId); payment.BancoEmisor = _bankServices.GetBankById(payment.BancoEmisorId).Name; payment.BancoReceptor = payment.BancoEmisor; var mnt = order2.OrderTotal; payment.MontoTotalOrden = mnt.ToString("N", new CultureInfo("es-VE")); if (paymentTransfer == null) { var model = new PaymentTransfer { IssuingBankId = payment.BancoEmisorId, OrderId = payment.OrdenId, ReceiverBankId = payment.BancoReceptorId, ReferenceNumber = payment.Referencia, OrderTotal = order2.OrderTotal }; _transferServices.InsertPaymentTransfer(model); } else { UpdatePayment(payment); } } catch (Exception ex) { throw new NopException("Error en insert transferencia: " + ex.Message, ex); } break; } default: { try { var paymentZelle = _zelleServices.GetPaymentZelleByOrderId(payment.OrdenId); if (paymentZelle == null) { var model = new PaymentZelle { IssuingEmail = payment.EmailEmisor, OrderId = payment.OrdenId, ReferenceNumber = payment.Referencia, OrderTotal = order2.OrderTotal * order2.CurrencyRate }; _zelleServices.InsertPaymentZelle(model); } else { UpdatePayment(payment); } var mnto = order2.OrderTotal * order2.CurrencyRate; payment.MontoTotalOrden = mnto.ToString("N", new CultureInfo("es-VE")); //paymentZelle.PaymentStatusOrder = (int)order2.PaymentStatus; //_zelleServices.UpdatePaymentZelle(paymentZelle); } catch (Exception ex) { throw new NopException("Error en insert zelle: " + ex.Message, ex); } break; } } if (payment.Id == 0) { _paymentRepository.Insert(payment); } _cacheManager.RemoveByPattern(PAYMENT_PATTERN_KEY); } catch (Exception ex) { throw new NopException("Error al insertar el pago: " + ex.Message, ex); } }