Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions BuckarooSdk/Base/PushHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ public PushHandler(string apiKey)
this.SignatureCalculationService = new SignatureCalculationService();
}

public Push DeserializePush(byte[] body, string requestUri, string authorizationHeader)
/// <summary>
/// Deserializes a Buckaroo <see cref="Push"/> message.
/// </summary>
/// <param name="body">The body of the message as <see cref="Array"/> of <see cref="byte"/>.</param>
/// <param name="requestUri">The <see cref="Uri"/> of the receiving endpoint of the Buckaroo <see cref="Push"/> message.</param>
/// <param name="authorizationHeader">The Authorization header received with the <see cref="Push"/> message.</param>
/// <returns>A <see cref="Push"/> message.</returns>
/// <exception cref="AuthenticationException">If the HMAC Authorization header cannot be verified.</exception>
public Push DeserializePush(byte[] body, Uri requestUri, string authorizationHeader)
{
var requestUriEncoded = WebUtility.UrlEncode(requestUri)?.ToLower();
var requestUriEncoded = WebUtility.UrlEncode($"{requestUri.Authority}{requestUri.PathAndQuery}").ToLower();

var requestMethod = HttpMethod.Post.ToString();


//calculate signature
if (!this.SignatureCalculationService.VerifySignature(body, requestMethod, requestUriEncoded, this._apiKey, authorizationHeader))
{
Expand Down