Exemple #1
0
        public void CheckIncorrectMerchant()
        {
            var result = _securityHelper.CheckRequest(new BaseRequest
            {
                MerchantId  = "100",
                RequestDate = DateTime.Now.ToUniversalTime(),
                Sign        = String.Empty
            });

            Assert.Equal(SecurityErrorType.MerchantUnknown, result);
        }
        public async Task <SecurityErrorType> Post([FromBody] MerchantAuthRequest request)
        {
            if (request == null)
            {
                return(SecurityErrorType.MerchantUnknown);
            }

            var merchant = await _merchantRepository.GetAsync(request.MerchantId);

            if (merchant == null)
            {
                return(SecurityErrorType.MerchantUnknown);
            }

            return(_securityHelper.CheckRequest(request.StringToSign, merchant.MerchantId, request.Sign,
                                                merchant.PublicKey, merchant.ApiKey));
        }
Exemple #3
0
        public async Task <IActionResult> VerifySignature([FromBody] VerifySignatureModel request)
        {
            try
            {
                IPayAuth payAuth = await _payAuthService.GetAsync(request.ClientId, request.SystemId);

                var validationResult = _securityHelper.CheckRequest(request.Text, request.ClientId, request.Signature,
                                                                    payAuth.Certificate, payAuth.ApiKey);

                return(Ok(new SignatureValidationResponse {
                    Description = validationResult.ToString(), ErrorType = validationResult
                }));
            }
            catch (ClientNotFoundException e)
            {
                _log.Error(e, $"{e.Message}, request: {request.ToJson()}");

                return(NotFound(ErrorResponse.Create(e.Message)));
            }
        }