public TransactionResponse RunApiTransaction(double amount, CardTransactionType transactionType, string prevTxnId)
        {
            TransactionResponse response = new TransactionResponse();

            string txnType = VelocityTransactionType.GetTranType(transactionType, prevTxnId);

            if (!string.IsNullOrEmpty(txnSessionToken))
            {
                if (string.Equals(txnType, VelocityTransactionType.Void))
                {
                    UndoTxn undoTran     = new UndoTxn(applnProfileId, prevTxnId);
                    string  postDataJson = undoTran.toJson();
                    response = ExecRestTransaction(txnEndPoint, postDataJson, txnSessionToken, "PUT", txnType);
                }
                else if (string.Equals(txnType, VelocityTransactionType.Refund))
                {
                    ReturnByIdTxn refundTxn    = new ReturnByIdTxn(applnProfileId, merchantProfileId, prevTxnId, amount);
                    string        postDataJson = refundTxn.toJson();
                    response = ExecRestTransaction(txnEndPoint, postDataJson, txnSessionToken, "POST", txnType);
                }
            }
            else
            {
                response.ErrorMessage = string.Format("Error processing {0} on endPoint {1} : Result: {2}", txnType, txnEndPoint, "Empty or Invalid session token");
                response.IsError      = true;
            }
            return(response);
        }
        public TransactionResponse RunTerminalTransaction(string uri, double amount, CardTransactionType transactionType)
        {
            TransactionResponse response = new TransactionResponse();
            string txnType = VelocityTransactionType.GetTranType(transactionType);

            string        postDataXml     = string.Format("<DETAIL><TRAN_TYPE>{0}</TRAN_TYPE><AMOUNT>{1}</AMOUNT></DETAIL>", txnType, amount.ToString());
            HttpClientApi httpClientApi   = new HttpClientApi();
            string        responseMessage = httpClientApi.ProcessTransaction(uri, postDataXml);

            if (httpClientApi.httpStatus == System.Net.HttpStatusCode.OK && httpClientApi.exceptionStatus == "NONE")
            {
                response = TerminalTxnResponse.GetTransactionResponseFromXml(responseMessage);
            }
            else
            {
                response.ErrorMessage = string.Format("Error processing {0} on device {1} : Result: {2} : Detail: {3}", txnType, uri, httpClientApi.statusCode, httpClientApi.exceptionData);
                response.IsError      = true;
            }

            return(response);
        }