Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ed15b548f | |||
| 7d2bc7f1f2 | |||
| ef2428f8e3 | |||
| 5edff5e272 |
@@ -11,20 +11,12 @@ public class CustomerServiceFeatureTests(Fixture fixture) : IClassFixture<Fixtur
|
||||
[IntegrationFact]
|
||||
public async Task CreateCustomerAsync_ShouldReturn_ResultWithCustomerId()
|
||||
{
|
||||
//var request = new CreateCustomer
|
||||
//{
|
||||
// Company = "Book Lovers",
|
||||
// Email = "hank@booklovers.com",
|
||||
// Phone = "555 1245 8577",
|
||||
// Website = "https://www.booklovers.com"
|
||||
//};
|
||||
|
||||
var request = new CreateCustomer
|
||||
{
|
||||
//Company = "Book Lovers",
|
||||
Company = "Book Lovers",
|
||||
Email = "hank@booklovers.com",
|
||||
//Phone = "555 1245 8577",
|
||||
//Website = "https://www.booklovers.com"
|
||||
Phone = "555 1245 8577",
|
||||
Website = "https://www.booklovers.com"
|
||||
};
|
||||
|
||||
var result = await customerService.CreateCustomerAsync(request, fixture.CancellationToken);
|
||||
|
||||
@@ -152,11 +152,16 @@ public sealed partial class PayfastService(IDbContextFactory<MidrandBooksDbConte
|
||||
if (string.IsNullOrEmpty(kvp.Value))
|
||||
continue;
|
||||
|
||||
if (kvp.Key.Equals("signature", StringComparison.OrdinalIgnoreCase))
|
||||
continue;
|
||||
|
||||
string key = kvp.Key;
|
||||
|
||||
// 1. Payfast requires spaces to be '+' signs. HttpUtility does this perfectly.
|
||||
string encodedVal = HttpUtility.UrlEncode(kvp.Value.Trim());
|
||||
|
||||
string val = PercentEncodingRegex.Replace(encodedVal, m => 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}&");
|
||||
}
|
||||
@@ -167,13 +172,13 @@ public sealed partial class PayfastService(IDbContextFactory<MidrandBooksDbConte
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(passPhrase))
|
||||
{
|
||||
// Apply the exact same encoding rule to your passphrase
|
||||
string encodedPassphrase = HttpUtility.UrlEncode(passPhrase.Trim());
|
||||
|
||||
string safePassphrase = PercentEncodingRegex.Replace(encodedPassphrase, m => m.Value.ToLowerInvariant());
|
||||
string safePassphrase = Regex.Replace(encodedPassphrase, "%[0-9A-Fa-f]{2}", m => m.Value.ToUpperInvariant());
|
||||
|
||||
getString += $"&passphrase={safePassphrase}";
|
||||
}
|
||||
|
||||
return HashService.ToMd5Hash(getString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user