示例#1
0
        private async Task HandleRequestPage(HttpContext httpContext, VirtualGatewayCommandDetails commandDetails)
        {
            var template = await GetTemplate("VirtualGatewayRequestTemplate.html");

            var html = template
                       .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());

            await httpContext.Response.WriteAsync(html);
        }
示例#2
0
        private static async Task HandleResultPage(HttpContext httpContext, VirtualGatewayCommandDetails commandDetails)
        {
            if (!httpContext.Request.Form.TryGetValue("isPaid", out var isPaid) ||
                !bool.TryParse(isPaid, out var boolIsPaid))
            {
                await httpContext.Response.WriteAsync($"{nameof(isPaid)} field is not valid.");

                return;
            }

            var template = await GetTemplate("VirtualGatewayResultTemplate.html");

            var html = template
                       .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");

            await httpContext.Response.WriteAsync(html);
        }