Пример #1
0
        private string PaymentWithZaloPay(InvoiceOrderViewModel order)
        {
            try
            {
                string clientIP = this.ClientIP;

                string desc       = "Gói " + order.ServiceName + " - Số tiền: " + ((long)order.Amount).ToString();
                string appTransId = $"{DateTime.Now.ToString("yyMMddHHmmss")}-{order.Code}";
                string bankCode   = order.IsCreditCard ? "CC" : "";
                string phone      = "";

                var resp = new ZalopayPaygateService().CreateOrderURL(order.UserId, (long)order.Amount, appTransId, bankCode, desc, phone);

                if (resp != null)
                {
                    _uow.ZaloPayTransaction.IU(new Core.Entities.Model.ZaloPayTransaction
                    {
                        InvoiceId      = order.Id,
                        UserId         = order.UserId,
                        InvoiceCode    = order.Code,
                        Amount         = order.Amount,
                        AppTransId     = appTransId,
                        TransDesc      = desc,
                        BankCode       = bankCode,
                        PayGateTransId = string.Empty,
                        PayGateChannel = 0,
                        IsCreditCard   = order.IsCreditCard,
                        ClientIP       = clientIP
                    });
                }

                return(resp);
            }catch (Exception ex)
            {
                _log.Error(ex);
                return(null);
            }
        }
Пример #2
0
        private Dictionary <string, object> PaymentWithZaloPayQR(InvoiceOrderViewModel order)
        {
            try
            {
                string clientIP = this.ClientIP;
                string desc     = string.Format("Mua dịch vụ {0} - Số tiền {1}", order.ServiceName, order.Amount);

                string appTransId = $"{DateTime.Now.ToString("yyMMddHHmmss")}-{order.Code}";
                string bankCode   = "QRCode";

                var res = new ZalopayPaygateService().CreateOrderQR("", (long)order.Amount, appTransId, "{}", order.ServiceName, desc);

                if (res != null)
                {
                    _uow.ZaloPayTransaction.IU(new Core.Entities.Model.ZaloPayTransaction
                    {
                        InvoiceId      = order.Id,
                        UserId         = order.UserId,
                        InvoiceCode    = order.Code,
                        Amount         = order.Amount,
                        AppTransId     = appTransId,
                        TransDesc      = desc,
                        BankCode       = bankCode,
                        PayGateTransId = string.Empty,
                        PayGateChannel = 0,
                        IsCreditCard   = false,
                        ClientIP       = clientIP
                    });
                }
                res.Add("appTransId", appTransId);
                return(res);
            }catch (Exception ex)
            {
                _log.Error(ex);
                return(null);
            }
        }