namespace com.hitrust.trustpay.client { using System; public class TrxResponse { protected internal string iErrorMessage; protected internal XMLDocument iResponseMessage; protected internal string iReturnCode; public const string RC_SUCCESS = "0000"; protected internal TrxResponse() { this.iReturnCode = ""; this.iErrorMessage = ""; this.InitBlock(); } public TrxResponse(XMLDocument aXMLDocument) { this.iReturnCode = ""; this.iErrorMessage = ""; this.InitBlock(); this.init(aXMLDocument); } public TrxResponse(string aReturnCode, string aErrorMessage) { this.iReturnCode = ""; this.iErrorMessage = ""; this.InitBlock(); this.setReturnCode(aReturnCode); this.setErrorMessage(aErrorMessage); } public virtual XMLDocument getOriginalResponseMessage() { return this.iResponseMessage; } public virtual string getValue(string aTag) { return this.iResponseMessage.getValueNoNull(aTag); } protected internal virtual void init(XMLDocument aXMLDocument) { XMLDocument document = aXMLDocument.getValue("ReturnCode"); if (document == null) { throw new TrxException("1303", "无法辨识网上支付平台的交易结果", "无法取得[ReturnCode]!"); } this.setReturnCode(document.ToString()); XMLDocument document2 = aXMLDocument.getValue("ErrorMessage"); if (document2 != null) { this.setErrorMessage(document2.ToString()); } if (this.ReturnCode.Equals("0000")) { this.iResponseMessage = aXMLDocument; } } private void InitBlock() { this.iResponseMessage = new XMLDocument(""); } public virtual bool isSuccess() { return this.iReturnCode.Equals("0000"); } public virtual TrxResponse setErrorMessage(string aErrorMessage) { this.iErrorMessage = aErrorMessage.Trim(); return this; } public virtual TrxResponse setReturnCode(string aReturnCode) { this.iReturnCode = aReturnCode.Trim(); return this; } public virtual string ErrorMessage { get { return this.iErrorMessage; } } public virtual string ReturnCode { get { return this.iReturnCode; } } } }