Refactored shasher payfast confirmation response handling
continuous-integration/drone/pr Build is passing

This commit is contained in:
Khwezi Mngoma
2026-06-01 16:36:33 +02:00
parent afc984f3bc
commit 5eb6dbc8b2
4 changed files with 95 additions and 15 deletions
@@ -1,4 +1,6 @@
using LiteCharms.Features.Hasher;
using LiteCharms.Features.Models;
using static LiteCharms.Features.Extensions.Hash;
namespace LiteCharms.Features.Tests;
@@ -65,17 +67,18 @@ public class HashServiceFeatureTests(Fixture fixture) : IClassFixture<Fixture>
{
var paymentId = hashService.HashEncodeLongId(1001).Value;
var incomingForm = new Dictionary<string, string>
var payload = new PayfastWebhookPayload
{
{ "m_payment_id", paymentId },
{ "amount", "350.00" },
{ "item_name", "System Architecture Book" }
Amount = "350.00",
ItemName = "System Architecture Book",
MPaymentId = paymentId,
};
var rawPayload = $"amount=350.00&item_name=System+Architecture+Book&m_payment_id={paymentId}&passphrase={payfastPassphrase}";
var rawPayload = payload.ToRawPayfastPayload(payfastPassphrase);
var generatedSignature = HashService.ToMd5Hash(rawPayload).Value;
var result = hashService.VerifyPayfastWebhookSignature(incomingForm, generatedSignature);
var result = hashService.VerifyPayfastWebhookSignature(payload, generatedSignature);
Assert.True(result.IsSuccess);
Assert.True(result.Value);