Refactored GenerateSignature #103
@@ -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,9 +152,12 @@ 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;
|
||||
|
||||
string encodedVal = HttpUtility.UrlEncode(kvp.Value.Trim());
|
||||
string encodedVal = Uri.EscapeDataString(kvp.Value.Trim());
|
||||
|
||||
string val = PercentEncodingRegex.Replace(encodedVal, m => m.Value.ToLowerInvariant());
|
||||
|
||||
@@ -167,13 +170,12 @@ public sealed partial class PayfastService(IDbContextFactory<MidrandBooksDbConte
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(passPhrase))
|
||||
{
|
||||
string encodedPassphrase = HttpUtility.UrlEncode(passPhrase.Trim());
|
||||
|
||||
string encodedPassphrase = Uri.EscapeDataString(passPhrase.Trim());
|
||||
string safePassphrase = PercentEncodingRegex.Replace(encodedPassphrase, m => m.Value.ToLowerInvariant());
|
||||
|
||||
getString += $"&passphrase={safePassphrase}";
|
||||
}
|
||||
|
||||
return HashService.ToMd5Hash(getString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user