public JsonResultDTO MakePayment(CardDetailDTO cardDetail)
        {
            var isExpiryDateValid = CardValidation.ValidateExpiryDate(cardDetail.ExpiryDate);
            var isCvvValid        = CardValidation.ValidateCvvNumber(cardDetail.Cvv);

            if (isExpiryDateValid && isCvvValid)
            {
                var bankResponse = IBankRepo.MakePayment(cardDetail);
                if (bankResponse.Status == "Success")
                {
                    jsonResult.IsSuccess     = true;
                    jsonResult.TransactionId = bankResponse.Identifier;
                }
                else
                {
                    jsonResult.IsSuccess = false;
                    jsonResult.Errors.Add("Bank responded payment unsuccessful");
                }
            }
            else
            {
                jsonResult.IsSuccess = false;
                jsonResult.Errors.Add("The credit card is expired");
            }
            return(jsonResult);
        }
        private void Salvar(object sender, RoutedEventArgs e)
        {
            try
            {
                Client       selectedClient    = (Client)ClientName.SelectedValue;
                ComboBoxItem selectedType      = (ComboBoxItem)Type.SelectedValue;
                ComboBoxItem selectedCardBrand = (ComboBoxItem)CardBrand.SelectedValue;

                string type      = (string)selectedType.Content;
                string cardBrand = (string)selectedCardBrand.Content;

                CardValidation.Validation(CardholderName.Text, Number.Text, ExpirationDate.Text, cardBrand, type, selectedClient.IdClient);

                Card card = new Card()
                {
                    CardholderName = CardholderName.Text,
                    CardNumber     = Number.Text,
                    ExpirationDate = (DateTime)ExpirationDate.SelectedDate,
                    CardBrand      = cardBrand,
                    Password       = Password.Password,
                    Type           = type,
                    IdClient       = selectedClient.IdClient,
                    Status         = 1
                };

                string status = OldButGoldService.PostRequestCard(card);
                MessageBox.Show(status);
                this.NavigationService.Navigate(new Uri("Pages/Index.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void Cadastrar(Card c)
 {
     try
     {
         CardValidation.CardValidationRules(c);
         repositorio.Insert(c);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public void Cadastrar(Transaction t, Card c, decimal limit)
 {
     try
     {
         CardValidation.CardValidationRules(c);
         TransactionValidation.TransactionValidationRules(t, limit, c.Status);
         repositorio.Insert(t);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        //POST: /api/Payments/Post
        public async Task <ActionResult <BankResponseDto> > Post([FromBody] PaymentRequestDto paymentRequestDto)
        {
            CardValidation cardValidation = new CardValidation(paymentRequestDto.Card);

            if (!cardValidation.IsValid)
            {
                return(BadRequest(new { message = "Card data is incorrect." }));
            }

            ClaimsPrincipal currentUser     = this.User;
            var             currentUserName = currentUser.FindFirst("login").Value;
            var             user            = await _userManager.FindByNameAsync(currentUserName);

            BankResponseDto bankResponseDto = await paymentService.PostPayment(paymentRequestDto, user, _options.Value.BankUrl);

            if (bankResponseDto != null)
            {
                return(Ok(bankResponseDto));
            }
            else
            {
                return(NotFound(new { message = "Bank could not process the request" }));
            }
        }
示例#6
0
 /// <summary>
 /// Determines the franchise code for this specific card.
 /// </summary>
 /// <param name="forceDebit">Whether the card should be detected as a debit card or not.</param>
 /// <returns></returns>
 public string FranchiseCode(bool forceDebit) => CardValidation.DetectCardFranchise(Number, forceDebit);
 public bool CanMakePaymentWithCard(string cardNumber, int expiryMonth, int expiryYear)
 {
     return(CardValidation.IsValidCard(cardNumber, expiryMonth, expiryYear));
 }
 public bool IsCardNumberValid(string cardNumber)
 {
     return(CardValidation.IsValidCardNumber(cardNumber));
 }
示例#9
0
 public void SetUp()
 {
     _cardRepository = Substitute.For <CardRepository>();
     _cardValidation = new CardValidator(_cardRepository);
 }
示例#10
0
 public CardController(CardCreation cardCreation, CardValidation cardValidation)
 {
     _cardCreation   = cardCreation;
     _cardValidation = cardValidation;
 }
示例#11
0
 public void WhenIValidatedTheCard()
 {
     Result = CardValidation.IsValidCard(EnteredCardNumber, ExpiryDate.Month, ExpiryDate.Year);
 }
示例#12
0
 public void WhenIValidatedTheCardNumber()
 {
     Result = CardValidation.IsValidCardNumber(EnteredCardNumber);
 }