/// <summary> /// Tries to perform withdraw operation, if fails throws Fault Exception /// </summary> /// <param name="paymentData">data needed to perform withdraw</param> /// <returns>response status</returns> public PaymentResponse Withdraw(WithdrawData paymentData) { try { var account = GetAccount(paymentData.AccessToken, paymentData.AccountNumber); _executor.ExecuteAndSave(new Withdraw(account, DecimalParser.Parse(paymentData.Amount), paymentData.OperationTitle), account); return(new PaymentResponse(ResponseStatus.Success)); } catch (BankException exception) { throw new FaultException(exception.ResponseStatus.Message()); } }
/// <summary> /// Transfer called by Soap service. /// Performs inner bank transfer when both account are from this bank or /// inter bank transfer when receiver is from other (listed) bank. /// When transfer fails - throws FaultException /// </summary> /// <param name="transferData">data needed to perform transfer</param> /// <returns>response status</returns> public PaymentResponse SoapTransfer(SoapTransferData transferData) { var amount = DecimalParser.Parse(transferData.Amount); AccountNumber receiverAccountNumber; IAccount sender; IPublicAccount receiver; try { sender = GetAccount(transferData.AccessToken, transferData.SenderAccountNumber); receiverAccountNumber = _accountNumberFactory.GetAccountNumber(transferData.ReceiverAccountNumber); } catch (BankException exception) { //not my account, access denied, or wrong receiver account number throw new FaultException(exception.ResponseStatus.Message()); } try { receiver = GetAccount(transferData.ReceiverAccountNumber); } catch (BankException exception) { if (exception.ResponseStatus != ResponseStatus.OtherBankAccount) { throw new FaultException(exception.ResponseStatus.Message()); } //receiver ot from this bank - INTER BANK TRANSFER var interTransfer = new InterBankTransfer(sender, receiverAccountNumber, amount, transferData.Title); _executor.ExecuteAndSave(interTransfer, sender); return(PrepareResponse(interTransfer.ResponseStatus)); } //sender and receiver from this bank - INNER TRANSFER var innerTransfer = new InnerBankTransfer(sender, receiver, amount, transferData.Title); _executor.ExecuteAndSave(innerTransfer, sender, receiver); return(PrepareResponse(innerTransfer.ResponseStatus)); }