namespace com.hitrust.trustpay.client.b2c { using com.hitrust.trustpay.client; using System; public class PaymentRequest : TrxRequest { private string iMerchantRemarks; private string iNotifyType; private com.hitrust.trustpay.client.b2c.Order iOrder; private string iPayLinkType; private string iPaymentType; private string iProductType; private string iResultNotifyURL; public const int MERCHANT_REMARKS_LEN = 200; public const string NOTIFY_TYPE_SERVER = "1"; public const string NOTIFY_TYPE_URL = "0"; public const string PAY_LINK_TYPE_MOBILE = "2"; public const string PAY_LINK_TYPE_NET = "1"; public const string PAY_LINK_TYPE_TV = "3"; public const string PAY_TYPE_ABC = "1"; public const string PAY_TYPE_INT = "2"; public const string PRD_TYPE_ONE = "1"; public const string PRD_TYPE_TWO = "2"; public const int RESULT_NOTIFY_URL_LEN = 200; public PaymentRequest() : base("B2C") { this.iOrder = null; this.iProductType = "1"; this.iNotifyType = "0"; this.iPaymentType = "1"; this.iResultNotifyURL = ""; this.iMerchantRemarks = ""; this.iPayLinkType = "1"; } public PaymentRequest(XMLDocument aXMLDocument) : base("B2C") { this.iOrder = null; this.iProductType = "1"; this.iNotifyType = "0"; this.iPaymentType = "1"; this.iResultNotifyURL = ""; this.iMerchantRemarks = ""; this.iPayLinkType = "1"; this.Order = new com.hitrust.trustpay.client.b2c.Order(aXMLDocument); this.ProductType = aXMLDocument.getValueNoNull("ProductType"); this.PaymentType = aXMLDocument.getValueNoNull("PaymentType"); this.NotifyType = aXMLDocument.getValueNoNull("NotifyType"); this.ResultNotifyURL = aXMLDocument.getValueNoNull("ResultNotifyURL"); this.MerchantRemarks = aXMLDocument.getValueNoNull("MerchantRemarks"); this.PayLinkType = aXMLDocument.getValueNoNull("PaymentLinkType"); } protected internal override void checkRequest() { if (this.iOrder == null) { throw new TrxException("1100", "商户提交的交易资料不完整", "未设定订单信息!"); } if (this.iProductType == null) { throw new TrxException("1100", "商户提交的交易资料不完整", "未设定商品种类!"); } if (this.iResultNotifyURL == null) { throw new TrxException("1100", "商户提交的交易资料不完整", "未设定支付结果回传网址!"); } string str = this.iOrder.isValid(); if (str.Length != 0) { throw new TrxException("1101", "商户提交的交易资料不合法", "订单信息不合法![" + str + "]"); } if (!this.iProductType.Equals("1") && !this.iProductType.Equals("2")) { throw new TrxException("1101", "商户提交的交易资料不合法", "商品种类不合法!"); } if (!this.iPaymentType.Equals("1") && !this.iPaymentType.Equals("2")) { throw new TrxException("1101", "商户提交的交易资料不合法", "支付类型不合法!"); } if (!this.iNotifyType.Equals("0") && !this.iNotifyType.Equals("1")) { throw new TrxException("1101", "商户提交的交易资料不合法", "支付通知类型不合法!"); } if (!DataVerifier.isValidURL(this.iResultNotifyURL)) { throw new TrxException("1101", "商户提交的交易资料不合法", "支付结果回传网址不合法!"); } if (this.iResultNotifyURL.Length == 0) { throw new TrxException("1101", "商户提交的交易资料不合法", "支付结果回传网址不合法!"); } if (SupportClass.ToSByteArray(SupportClass.ToByteArray(this.iResultNotifyURL)).Length > 200) { throw new TrxException("1101", "商户提交的交易资料不合法", "支付结果回传网址不合法!"); } if (SupportClass.ToSByteArray(SupportClass.ToByteArray(this.iMerchantRemarks)).Length > 200) { throw new TrxException("1101", "商户提交的交易资料不合法", "商户备注信息不合法!"); } if ((!this.iPayLinkType.Equals("1") && !this.iPayLinkType.Equals("2")) && !this.iPayLinkType.Equals("3")) { throw new TrxException("1101", "商户提交的交易资料不合法", "支付接入类型不合法!"); } } protected internal override TrxResponse constructResponse(XMLDocument aResponseMessage) { return new TrxResponse(aResponseMessage); } public virtual string MerchantRemarks { get { return this.iMerchantRemarks; } set { this.iMerchantRemarks = value.Trim(); } } public virtual string NotifyType { get { return this.iNotifyType; } set { this.iNotifyType = value.Trim(); } } public virtual com.hitrust.trustpay.client.b2c.Order Order { get { return this.iOrder; } set { this.iOrder = value; } } public virtual string PayLinkType { get { return this.iPayLinkType; } set { this.iPayLinkType = value.Trim(); } } public virtual string PaymentType { get { return this.iPaymentType; } set { this.iPaymentType = value.Trim(); } } public virtual string ProductType { get { return this.iProductType; } set { this.iProductType = value.Trim(); } } protected internal override XMLDocument RequestMessage { get { return new XMLDocument("PayReq" + this.iOrder.getXMLDocument(1).ToString() + "" + this.iProductType + "" + this.iPaymentType + "" + this.iNotifyType + "" + this.iResultNotifyURL + "" + this.iMerchantRemarks + "" + this.iPayLinkType + ""); } } public virtual string ResultNotifyURL { get { return this.iResultNotifyURL; } set { this.iResultNotifyURL = value.Trim(); } } } }