Refactored shasher payfast confirmation response handling
continuous-integration/drone/pr Build is passing
continuous-integration/drone/pr Build is passing
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user