public IViewComponentResult Invoke(int id)
        {
            try
            {
                if (id == 0)
                {
                    throw new ArgumentNullException(nameof(id));
                }

                var zelle = _zelleService.GetPaymentZelleByOrderId(id);

                var model = new PaymentInfoModel();
                if (zelle != null)
                {
                    model = new PaymentInfoModel
                    {
                        IdZelle            = zelle.Id,
                        Order              = zelle.OrderId,
                        IssuingEmail       = zelle.IssuingEmail,
                        Reference          = zelle.ReferenceNumber,
                        PaymentStatusOrder = zelle.PaymentStatusOrder
                    };
                }
                else
                {
                    model.Order = id;
                }
                return(View("~/Plugins/Payments.Zelle/Views/RegisterPayment.cshtml", model));
            }
            catch (Exception ex)
            {
                throw new NopException(ex.Message, ex);
            }
        }
Пример #2
0
        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);
            }
        }