Example #1
0
        private static void HandlePayCommand(HttpContext context, CommandDetails commandDetails)
        {
            if (!bool.TryParse(context.Request.Form["isPayed"], out var isPayed))
            {
                WriteToResponse(context, "IsPayed field is not valid.");
                return;
            }

            if (isPayed && GatewayConfiguration.HasPassword())
            {
                var password = context.Request.Form["password"];

                if (password.IsNullOrEmpty())
                {
                    WriteToResponse(context, "Password is required.");
                    return;
                }

                if (!IsGatewayPasswordValid(password))
                {
                    WriteToResponse(context, "Password is not correct.");
                    return;
                }
            }

            var html = GeneratePayCommandHtml(commandDetails.OrderNumber, commandDetails.OrderNumber.ToString(), commandDetails.Amount, commandDetails.RedirectUrl, isPayed);

            WriteToResponse(context, html);
        }
Example #2
0
        private static void HandleRequestCommand(HttpContext context, CommandDetails commandDetails)
        {
            var parbadGatewayUrl = context.Request.Url.Authority + context.Request.Url.AbsolutePath;

            if (!parbadGatewayUrl.StartsWith(context.Request.Url.Scheme + "://"))
            {
                parbadGatewayUrl = $"{context.Request.Url.Scheme}://{parbadGatewayUrl}";
            }

            var html = GenerateRequestCommandHtml(commandDetails.OrderNumber, commandDetails.Amount, commandDetails.RedirectUrl, parbadGatewayUrl, GatewayConfiguration.HasPassword());

            WriteToResponse(context, html);
        }