From e3e49b8db2f9048e75eadb382fc1bede7c53258d Mon Sep 17 00:00:00 2001 From: Khwezi Mngoma Date: Fri, 12 Jun 2026 23:30:13 +0200 Subject: [PATCH] Honoring the mandatory field sequence --- .../Payments/PayfastService.cs | 62 ++++++++++++++----- 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/LiteCharms.Features.MidrandBooks/Payments/PayfastService.cs b/LiteCharms.Features.MidrandBooks/Payments/PayfastService.cs index 8aa1eec..8d440d8 100644 --- a/LiteCharms.Features.MidrandBooks/Payments/PayfastService.cs +++ b/LiteCharms.Features.MidrandBooks/Payments/PayfastService.cs @@ -147,23 +147,56 @@ public sealed partial class PayfastService(IDbContextFactory m.Value.ToUpperInvariant()); - string key = kvp.Key; - - // 1. Payfast requires spaces to be '+' signs. HttpUtility does this perfectly. - string encodedVal = HttpUtility.UrlEncode(kvp.Value.Trim()); - - // 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}&"); + pfOutput.Append($"{key}={val}&"); + } } string getString = pfOutput.Length > 0 @@ -172,7 +205,6 @@ public sealed partial class PayfastService(IDbContextFactory m.Value.ToUpperInvariant());