diff --git a/LiteCharms.Features.MidrandBooks/Payments/PayfastService.cs b/LiteCharms.Features.MidrandBooks/Payments/PayfastService.cs index 1208667..8aa1eec 100644 --- a/LiteCharms.Features.MidrandBooks/Payments/PayfastService.cs +++ b/LiteCharms.Features.MidrandBooks/Payments/PayfastService.cs @@ -157,9 +157,11 @@ public sealed partial class PayfastService(IDbContextFactory m.Value.ToLowerInvariant()); + // 2. Payfast requires all OTHER percent-encoded hex arrays to be UPPERCASE (e.g., %3A instead of %3a) + string val = Regex.Replace(encodedVal, "%[0-9A-Fa-f]{2}", m => m.Value.ToUpperInvariant()); pfOutput.Append($"{key}={val}&"); } @@ -170,8 +172,9 @@ public sealed partial class PayfastService(IDbContextFactory m.Value.ToLowerInvariant()); + // Apply the exact same encoding rule to your passphrase + string encodedPassphrase = HttpUtility.UrlEncode(passPhrase.Trim()); + string safePassphrase = Regex.Replace(encodedPassphrase, "%[0-9A-Fa-f]{2}", m => m.Value.ToUpperInvariant()); getString += $"&passphrase={safePassphrase}"; }