public bool PerformFullCreditProcess( string cardNumber, decimal amount, out string authToken) { authToken = string.Empty; try { _gateway.ValidateCard(cardNumber); } catch (InvalidOperationException) { return(false); } if (_gateway.CheckIfCreditAvailable(cardNumber, amount)) { var id = _gateway.ReserveCredit(cardNumber, amount); if (id == Guid.Empty) { return(false); } else { _gateway.LogReservation(cardNumber, id, amount); authToken = _gateway.CompleteTransaction(cardNumber, id); return(true); } } else { return(false); } }
public void CreditNotAvailableTest() { var cardNumber = "342844743236943"; string token = string.Empty; _gateway.CompleteTransaction(cardNumber, _gateway.ReserveCredit(cardNumber, 500m)); var sut = new TransactionProcessor(_gateway); sut.PerformFullCreditProcess(cardNumber, 500m, out token); Assert.Equal(string.Empty, token); }