Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3deae15f5a | |||
| 8e1df7938b | |||
| d9f2d32c76 | |||
| 9296f0331e | |||
| 1ace61baa5 | |||
| e3e49b8db2 | |||
| 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);
|
||||
|
||||
@@ -147,18 +147,56 @@ public sealed partial class PayfastService(IDbContextFactory<MidrandBooksDbConte
|
||||
{
|
||||
var pfOutput = new StringBuilder();
|
||||
|
||||
foreach (var kvp in data)
|
||||
// Define the exact structural sequence mandated by Payfast's documentation
|
||||
string[] mandatorySequence =
|
||||
[
|
||||
"merchant_id",
|
||||
"merchant_key",
|
||||
"return_url",
|
||||
"cancel_url",
|
||||
"notify_url",
|
||||
"name_first",
|
||||
"name_last",
|
||||
"email_address",
|
||||
"cell_number",
|
||||
"m_payment_id",
|
||||
"amount",
|
||||
"item_name",
|
||||
"item_description",
|
||||
"custom_int1",
|
||||
"custom_int2",
|
||||
"custom_int3",
|
||||
"custom_int4",
|
||||
"custom_int5",
|
||||
"custom_str1",
|
||||
"custom_str2",
|
||||
"custom_str3",
|
||||
"custom_str4",
|
||||
"custom_str5",
|
||||
"email_confirmation",
|
||||
"confirmation_address",
|
||||
"payment_method",
|
||||
"subscription_type",
|
||||
"billing_date",
|
||||
"recurring_amount",
|
||||
"frequency",
|
||||
"cycles"
|
||||
];
|
||||
|
||||
// 1. Iterate explicitly by the mandatory positional array sequence instead of the dictionary's internal order
|
||||
foreach (string key in mandatorySequence)
|
||||
{
|
||||
if (string.IsNullOrEmpty(kvp.Value))
|
||||
continue;
|
||||
// Only append if the key exists in your source dictionary and contains data
|
||||
if (data.TryGetValue(key, out string? rawValue) && !string.IsNullOrEmpty(rawValue))
|
||||
{
|
||||
// Payfast requires spaces to be '+' signs. HttpUtility does this natively.
|
||||
string encodedVal = HttpUtility.UrlEncode(rawValue.Trim());
|
||||
|
||||
string key = kvp.Key;
|
||||
// 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());
|
||||
|
||||
string encodedVal = HttpUtility.UrlEncode(kvp.Value.Trim());
|
||||
|
||||
string val = PercentEncodingRegex.Replace(encodedVal, m => m.Value.ToLowerInvariant());
|
||||
|
||||
pfOutput.Append($"{key}={val}&");
|
||||
pfOutput.Append($"{key}={val}&");
|
||||
}
|
||||
}
|
||||
|
||||
string getString = pfOutput.Length > 0
|
||||
@@ -168,12 +206,11 @@ public sealed partial class PayfastService(IDbContextFactory<MidrandBooksDbConte
|
||||
if (!string.IsNullOrWhiteSpace(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using LiteCharms.Features.Abstractions;
|
||||
namespace LiteCharms.Features.Browser;
|
||||
|
||||
namespace LiteCharms.Features.Browser;
|
||||
|
||||
public sealed class LocalStorageService(ProtectedLocalStorage storage) : IService
|
||||
public sealed class LocalStorageService(ProtectedLocalStorage storage)
|
||||
{
|
||||
public async ValueTask<Result> DeleteAsync(string key)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user