namespace com.hitrust.b2b.trustpay.client { using System; public class TrxResponse { protected internal string iErrorMessage; protected internal XMLDocument iResponseMessage; protected internal string iReturnCode; protected internal string iSignature; public const string RC_SUCCESS = "0000"; public const string STATUS_CANCEL = "5"; public const string STATUS_CHECK = "1"; public const string STATUS_FAILURE = "3"; public const string STATUS_NO_RESPONSE = "9"; public const string STATUS_ORIGINAL = "0"; public const string STATUS_REJECT = "4"; public const string STATUS_SUCCESS = "2"; protected internal TrxResponse() { this.iReturnCode = ""; this.iErrorMessage = ""; this.iSignature = ""; this.InitBlock(); } public TrxResponse(XMLDocument aXMLDocument) { this.iReturnCode = ""; this.iErrorMessage = ""; this.iSignature = ""; this.InitBlock(); this.init(aXMLDocument); } public TrxResponse(string aReturnCode, string aErrorMessage) { this.iReturnCode = ""; this.iErrorMessage = ""; this.iSignature = ""; this.InitBlock(); this.setReturnCode(aReturnCode); this.setErrorMessage(aErrorMessage); } public virtual string getValue(string aTag) { return this.iResponseMessage.getValueNoNull(aTag); } protected internal virtual void init(XMLDocument aXMLDocument) { this.iResponseMessage = aXMLDocument.getValue("Message"); this.iSignature = aXMLDocument.getValueNoNull("Signature"); XMLDocument document = this.iResponseMessage.getValue("ReturnCode"); if (document == null) { throw new TrxException("1303", "无法辨识网上支付平台的交易结果", "无法取得[ReturnCode]!"); } this.setReturnCode(document.ToString()); XMLDocument document2 = this.iResponseMessage.getValue("ErrorMessage"); if (document2 != null) { this.setErrorMessage(document2.ToString()); } } 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; } set { this.iErrorMessage = value.Trim(); } } public virtual string ResponseMessage { get { return this.iResponseMessage.ToString(); } } public virtual string ReturnCode { get { return this.iReturnCode; } set { this.iReturnCode = value.Trim(); } } public virtual string Signature { get { return this.iSignature; } set { this.iSignature = value.Trim(); } } } }