public IActionResult GenerateSignature([FromQuery] GenerateSignatureRequest request)
        {
            var hmacValidator = new HmacValidator();

            var stringToSign = hmacValidator.BuildSigningString(GetDictonaryFromRequest(request));
            var signature    = hmacValidator.CalculateSignature(stringToSign, request.SigningKey);

            return(Ok(signature));
        }
Ejemplo n.º 2
0
        private string CalculateSignature(ProcessPaymentRequest request)
        {
            var parametrs = new Dictionary <string, string>
            {
                { nameof(request.MerchantTransactionId), request.MerchantTransactionId },
                { nameof(request.Amount), request.Amount.ToString("F", CultureInfo.InvariantCulture) },
                { nameof(request.CardNumber), request.CardNumber },
                { nameof(request.ExpiryMonth), request.ExpiryMonth.ToString() },
                { nameof(request.ExpiryYear), request.ExpiryYear.ToString() },
                { nameof(request.Cvv), request.Cvv },
                { nameof(request.Currency), request.Currency }
            };

            var hmacGenerator = new HmacValidator();

            return(hmacGenerator.CalculateSignature(hmacGenerator.BuildSigningString(parametrs), _testMerchant.SigningKey));
        }