Ejemplo n.º 1
0
        public async Task <IActionResult> SendSessionReplyAsync(
            [FromRoute] string id,
            [FromQuery] SessionReplyMessage.SessionReplyMessageCode code)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(ValidationProblem(
                           new ValidationProblemDetails(
                               new Dictionary <string, string[]>
                {
                    { nameof(id), new [] { $"{nameof(id)} is required" } }
                })));
            }
            try
            {
                await _transactionsManager.SendSessionReplyAsync(id, code);
            }
            catch (NullReferenceException)
            {
                return(NotFound());
            }

            var transaction = await _transactionsManager.GetAsync(id);

            return(Ok(_mapper.Map <TransactionDetailsModel>(transaction)));
        }
Ejemplo n.º 2
0
        public async Task SendSessionReplyAsync(string txId, SessionReplyMessage.SessionReplyMessageCode code)
        {
            var transaction = await _transactionsRepository.GetAsync(txId);

            if (transaction == null)
            {
                throw new NullReferenceException();
            }

            if (transaction.Status != TransactionStatus.SessionRequested)
            {
                return; //todo: handle properly
            }
            if (!_benefeciarySessionsDict.TryGetValue(transaction.SessionId, out var beneficiarySession))
            {
                return; //todo: handle this case.
            }
            await beneficiarySession.SessionReplyAsync(_vaspInformation, code);

            if (code == SessionReplyMessage.SessionReplyMessageCode.SessionAccepted)
            {
                transaction.Status = TransactionStatus.SessionConfirmed;
            }
            else
            {
                transaction.Status             = TransactionStatus.SessionDeclined;
                transaction.SessionDeclineCode = SessionReplyMessage.GetMessageCode(code);
            }

            await _transactionsRepository.UpdateAsync(transaction);
        }