private void btnQueryOrder_Click(object sender, EventArgs e) { //创建支付通道 UnionPayChannel channel = new UnionPayChannel() { CertificateFilePassword = ConfigurationManager.AppSettings["WAPEncryptCertificateFilePassword"] , CertificateFilePath = ConfigurationManager.AppSettings["WAPEncryptCertificateFilePath"] , MerchantID = ConfigurationManager.AppSettings["WAPMerchantID"] , PacketEncryptKey = "654321" }; //查询订单 QueryOrderRequest req = new QueryOrderRequest(); req.SendTime = DateTime.Now; req.SendSeqID = Guid.NewGuid().ToString("N"); req.TransType = WapTransTypes.PreAuthorization; req.MerchantID = channel.MerchantID; req.MerchantOrderID = this.Session["MerchantOrderID"] as string; req.MerchantOrderTime = this.Session["MerchantOrderTime"] as DateTime?; // try { var rsp = WapGateway.QueryOrder(channel, req); this.txtOrderInfo.Text = rsp.ToString(); } catch (Exception ex) { this.txtOrderInfo.Text = "执行失败:" + Environment.NewLine + ex.Message; } }
public void TestQueryOrder() { //先发预订单请求 UnionPayChannel channel = new UnionPayChannel() { CertificateFilePassword = "******", CertificateFilePath = "D:/cer/630056832596.pfx", MerchantID = "630056832596", PacketEncryptKey = "654321" }; PreOrderRequest req = new PreOrderRequest(); req.SendTime = DateTime.Now; req.SendSeqID = Guid.NewGuid().ToString("N"); req.FrontUrl = "http://www.jitmarketing.cn:8090/TranNotification.ashx"; req.MerchantOrderDesc = "呵呵"; req.Misc = string.Empty; //req.GatewayType = GatewayTypes.WAP; req.TransTimeout = DateTime.Now.AddHours(1); req.BackUrl = "http://www.jitmarketing.cn:8090/TranNotification.ashx"; req.MerchantOrderCurrency = Currencys.RMB; req.MerchantOrderAmt = 1; req.MerchantID = "630056832596"; req.MerchantOrderTime = DateTime.Now.AddMinutes(-5); req.MerchantOrderID = Guid.NewGuid().ToString("N"); req.MerchantUserID = string.Empty; req.MobileNum = "15388157741"; req.CarNum = string.Empty; var rsp = WapGateway.PreOrder(channel, req); Assert.IsTrue(rsp.IsSuccess); //跳转到支付平台页面 WebClient wc = new WebClient(); string strResponse = wc.UploadString(rsp.RedirectURL, string.Empty); //在查询 QueryOrderRequest req2 = new QueryOrderRequest(); req2.SendTime = DateTime.Now; req2.SendSeqID = Guid.NewGuid().ToString("N"); req2.TransType = WapTransTypes.PreAuthorization; req2.MerchantID = "630056832596"; req2.MerchantOrderID = req.MerchantOrderID; req2.MerchantOrderTime = req.MerchantOrderTime; var rsp2 = WapGateway.QueryOrder(channel, req2); Assert.IsTrue(rsp2.IsSuccess); }