示例#1
0
        public async Task <IActionResult> InitiatePayment(
            [FromBody] Card cardDetails, [FromQuery] Guid sessionId, [FromQuery] string callback
            )
        {
            await _repository.SessionIsActiveAsync(sessionId);

            _validator.ValidateCard(cardDetails);
            if (!String.IsNullOrWhiteSpace(callback) &&
                Uri.IsWellFormedUriString(callback, UriKind.Absolute))
            {
                await _notifier.SendAsyncNotification(new Uri(callback), sessionId.ToString());
            }
            await _repository.MakePaymentAsync(sessionId, cardDetails);

            return(Ok());
        }
        public IActionResult Post([FromBody] SubmittedCardModel card)
        {
            if (card == null || card.CardNumber == null || String.IsNullOrEmpty(card.CardNumber))
            {
                return(StatusCode(422));
            }

            if (!_numberService.IsDigitsOnly(card.CardNumber))
            {
                return(StatusCode(422));
            }

            var validationResult = _cardValidator.ValidateCard(new Card(card.CardNumber));

            return(new JsonResult(new ValidationResultModel(validationResult.CardType, validationResult.ValidationResult), jsonSerializerSettings));
        }