Ejemplo n.º 1
0
        private Task HandleRequestCommand(HttpContext httpContext, VirtualGatewayCommandDetails commandDetails)
        {
            var html = Properties.Resources.VirtualGatewayRequestHtml
                       .Replace("#VirtualGatewayPath#", _options.Value.GatewayPath)
                       .Replace("#TrackingNumber#", commandDetails.TrackingNumber.ToString())
                       .Replace("#Amount#", commandDetails.Amount.ToString())
                       .Replace("#DisplayAmount#", ((long)commandDetails.Amount).ToString("N0"))
                       .Replace("#RedirectUrl#", commandDetails.RedirectUrl)
                       .Replace("#YearNow#", DateTime.Now.Year.ToString());

            return(httpContext.Response.WriteAsync(html));
        }
Ejemplo n.º 2
0
        private Task HandlePayCommand(HttpContext httpContext, VirtualGatewayCommandDetails commandDetails)
        {
            if (!httpContext.Request.Form.TryGetValue("isPaid", out var isPaid) ||
                !bool.TryParse(isPaid, out var boolIsPaid))
            {
                return(httpContext.Response.WriteAsync($"{nameof(isPaid)} field is not valid."));
            }

            var html = Properties.Resources.VirtualGatewayResultHtml
                       .Replace("#TrackingNumber#", commandDetails.TrackingNumber.ToString())
                       .Replace("#DisplayAmount#", ((long)commandDetails.Amount).ToString("N0"))
                       .Replace("#TransactionCode#", boolIsPaid ? Guid.NewGuid().ToString("N") : string.Empty)
                       .Replace("#RedirectUrl#", commandDetails.RedirectUrl)
                       .Replace("#IsPaid#", isPaid.ToString().ToLower())
                       .Replace("#YearNow#", DateTime.Now.Year.ToString())
                       .Replace("#CssStatusName#", boolIsPaid ? "success" : "danger")
                       .Replace("#StatusText#", boolIsPaid ? "Succeed" : "Failed");

            return(httpContext.Response.WriteAsync(html));
        }