Пример #1
0
        public async Task <IActionResult> GenerateRsaKeys([FromBody] GenerateRsaKeysModel request)
        {
            try
            {
                // check that pay auth for merchant exists
                var payAuth = await _payAuthService.GetAsync(request.ClientId, LykkePayConstants.DefaultSystemId);

                var rsaKeys = _securityHelper.GenerateRsaKeys(request.ClientDisplayName);

                await _payAuthService.UpdateAsync(new Core.Domain.PayAuth
                {
                    SystemId    = LykkePayConstants.DefaultSystemId,
                    ClientId    = request.ClientId,
                    Certificate = rsaKeys.PublicKey
                });

                return(Ok(new GenerateRsaKeysResponse
                {
                    PublicKey = rsaKeys.PublicKey,
                    PrivateKey = rsaKeys.PrivateKey
                }));
            }
            catch (Exception e)
            {
                _log.Error(e, $"{e.Message}, request: {request.ToJson()}");

                return(BadRequest(ErrorResponse.Create(e.Message)));
            }
        }
        public async Task <IActionResult> GetPayAuthInformation([Required][RowKey] string merchantId)
        {
            try
            {
                var payAuth = await _payAuthService.GetAsync(merchantId, LykkePayConstants.DefaultSystemId);

                return(Ok(Mapper.Map <PayAuthInformationResponse>(payAuth)));
            }
            catch (ClientNotFoundException e)
            {
                _log.Error(e, $"{e.Message}, request: {merchantId}");

                return(NotFound(ErrorResponse.Create(e.Message)));
            }
        }
Пример #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)));
            }
        }