diff --git a/LiteCharms.Features/Extensions/Hash.cs b/LiteCharms.Features/Extensions/Hash.cs index 0c17d85..78f2c6c 100644 --- a/LiteCharms.Features/Extensions/Hash.cs +++ b/LiteCharms.Features/Extensions/Hash.cs @@ -82,4 +82,21 @@ public static class Hash return (payload, passphrase); } + + public static (PayfastWebhookPayload Payload, string Passphrase) FromRawPayfastPayload(this IFormCollection form) + { + string passphrase = string.Empty; + var payload = new PayfastWebhookPayload(); + + if (form.IsNullOrEmpty()) return (payload, passphrase); + + payload = new PayfastWebhookPayload + { + Amount = form.TryGetValue("amount", out var amountValues) ? amountValues.ToString() : null, + ItemName = form.TryGetValue("item_name", out var itemValues) ? itemValues.ToString() : null, + MPaymentId = form.TryGetValue("m_payment_id", out var paymentIdValues) ? paymentIdValues.ToString() : null, + }; + + return (payload, passphrase); + } } \ No newline at end of file diff --git a/LiteCharms.Features/LiteCharms.Features.csproj b/LiteCharms.Features/LiteCharms.Features.csproj index df4841b..087c9e4 100644 --- a/LiteCharms.Features/LiteCharms.Features.csproj +++ b/LiteCharms.Features/LiteCharms.Features.csproj @@ -147,6 +147,8 @@ + +