public PaymentInfo MakeRefund(Card cardInfo, double amount) { if (VerifyCard(cardInfo)) { ServiceExceptionInfo info = new ServiceExceptionInfo(); if (amount <= 0) { info.ErrorCode = 101; info.Description = "Invalid amount"; info.When = DateTime.Now; //throw new FaultException<ServiceExceptionInfo>(info, new FaultReason("Error in MakePayment, invalid amount")); throw new FaultException("Error in MakePayment, invalid amount"); } for (int i = 0; i < cards.Count; i++) { if (cards[i].CardNo == cardInfo.CardNo) { cards[i].Balance += amount; break; } } return(new PaymentInfo() { ReferenceNo = Guid.NewGuid().ToString(), Status = PaymentStatus.Success }); } return(null); }
public PaymentInfo MakePayment(double amount) { //Logic //Use the cardinfo for payment. ServiceExceptionInfo info = new ServiceExceptionInfo(); if (amount <= 0) { info.ErrorCode = 101; info.Description = "Invalid amount"; info.When = DateTime.Now; throw new FaultException <ServiceExceptionInfo>(info, new FaultReason("Error in MakePayment")); } return(new PaymentInfo() { ReferenceNo = Guid.NewGuid().ToString(), Status = PaymentStatus.Success }); }
public PaymentInfo MakePayment(Card cardInfo, double amount) { //Logic //Use the cardinfo for payment. if (VerifyCard(cardInfo)) { ServiceExceptionInfo info = new ServiceExceptionInfo(); if (amount <= 0) { info.ErrorCode = 101; info.Description = "Invalid amount"; info.When = DateTime.Now; //throw new FaultException<ServiceExceptionInfo>(info, new FaultReason("Error in MakePayment, invalid amount")); throw new FaultException("Error in MakePayment, invalid amount"); } //Original Code Commented To Induce Bug - Not Checking for Balance if (cardBal < amount) { info.ErrorCode = 102; info.Description = "Insufficient balance in the card"; info.When = DateTime.Now; //throw new FaultException<ServiceExceptionInfo>(info, new FaultReason("Error in MakePayment, insufficient balance in the card")); throw new FaultException("Error in MakePayment, insufficient balance in the card"); } cardBal -= amount; s_card.Balance = cardBal; s_card = null; return(new PaymentInfo() { ReferenceNo = Guid.NewGuid().ToString(), Status = PaymentStatus.Success }); } return(null); }