protected void Page_Load(object sender, EventArgs e) { try { if (!string.Equals(Request.HttpMethod, "POST", StringComparison.CurrentCultureIgnoreCase)) { throw new Exception("Error HttpMethod"); } var outMessage = string.Empty; var s = Request.InputStream; var count = 0; var buffer = new byte[1024]; var builder = new StringBuilder(); while ((count = s.Read(buffer, 0, 1024)) > 0) { builder.Append(Encoding.UTF8.GetString(buffer, 0, count)); } s.Flush(); s.Close(); s.Dispose(); WriteLog(builder.ToString()); var paymentNotify = new PaymentNotify(builder.ToString()); bool isSucceed = false; //检测订单有效性 var response = paymentNotify.Report(out isSucceed); if (isSucceed) { WriteLog("report Success"); //后台反馈微信信息 var payModuleId = 0; if (int.TryParse(paymentNotify.attach, out payModuleId)) { var message = string.Empty; if (PayNotifyManager.PayNotify((PayModuleEnum)payModuleId, paymentNotify, out message)) { outMessage = PaymentNotify.ReportSuccess(); } else { outMessage = PaymentNotify.ReportError(message); } } else { outMessage = PaymentNotify.ReportError("异常业务支付ID"); } } ReturnResponse(outMessage); } catch (Exception exception) { var errorResponse = PaymentNotify.ReportError(exception.Message); ReturnResponse(errorResponse); } }
public static bool PayNotify(PayModuleEnum payModule, PaymentNotify paymentNotify, out string message) { message = string.Empty; IPayNotify payNotify = null; //记录通知信息 SavePayNotifyInfo(payModule, paymentNotify); switch (payModule) { case PayModuleEnum.Restaurant: payNotify = new RestaurantPayNotify(); break; case PayModuleEnum.Hotel: payNotify = new HotelPayNotify(); break; default: message = "异常参数支付模块ID"; return(false); } return(payNotify.PayNotify(paymentNotify, out message)); }
private static void SavePayNotifyInfo(PayModuleEnum payModule, PaymentNotify paymentNotify) { var payNotifyInfo = new PayNotifyInfo(); payNotifyInfo.ModuleName = payModule.ToString(); payNotifyInfo.NotifyID = Guid.NewGuid(); payNotifyInfo.appid = paymentNotify.appid; payNotifyInfo.attach = paymentNotify.attach; payNotifyInfo.bank_type = paymentNotify.bank_type; payNotifyInfo.cash_fee = paymentNotify.cash_fee; payNotifyInfo.cash_fee_type = paymentNotify.cash_fee_type; payNotifyInfo.coupon_count = paymentNotify.coupon_count; payNotifyInfo.coupon_fee = paymentNotify.coupon_fee; payNotifyInfo.CreateTime = DateTime.Now; payNotifyInfo.device_info = paymentNotify.device_info; payNotifyInfo.err_code = paymentNotify.err_code; payNotifyInfo.err_code_des = paymentNotify.err_code_des; payNotifyInfo.fee_type = paymentNotify.fee_type; payNotifyInfo.is_subscribe = paymentNotify.is_subscribe; payNotifyInfo.mch_id = paymentNotify.mch_id; payNotifyInfo.nonce_str = paymentNotify.nonce_str; payNotifyInfo.openid = paymentNotify.openid; payNotifyInfo.out_trade_no = paymentNotify.out_trade_no; payNotifyInfo.result_code = paymentNotify.result_code; payNotifyInfo.return_code = paymentNotify.return_code; payNotifyInfo.return_msg = paymentNotify.return_msg; payNotifyInfo.sign = paymentNotify.sign; payNotifyInfo.time_end = paymentNotify.time_end; payNotifyInfo.total_fee = paymentNotify.total_fee; payNotifyInfo.trade_type = paymentNotify.trade_type; payNotifyInfo.transaction_id = paymentNotify.transaction_id; payNotifyInfo.Add(); }
public NotifyController(PaymentNotify paymentNotify) { this.paymentNotify = paymentNotify; paymentNotify.PaymentSucceed += new PaymentSucceedEventHandler(notify_PaymentSucceed); paymentNotify.PaymentFailed += new PaymentFailedEventHandler(notify_PaymentFailed); paymentNotify.UnknownGateway += new UnknownGatewayEventHandler(notify_UnknownGateway); }
public NotifyController() { merchantList = new List <Merchant>(); Merchant alipayMerchant = new Merchant(); alipayMerchant.GatewayType = GatewayType.Alipay; alipayMerchant.Partner = "000000000000000"; alipayMerchant.Key = "000000000000000000000000000000000000000000"; Merchant unionPayMerchant = new Merchant(); unionPayMerchant.GatewayType = GatewayType.UnionPay; unionPayMerchant.Partner = "000000000000000"; unionPayMerchant.Key = "000000000000000000000000000000000000000000"; Merchant weChatPaymentMerchant = new Merchant(); weChatPaymentMerchant.GatewayType = GatewayType.WeChatPayment; weChatPaymentMerchant.AppId = "wx000000000000000"; weChatPaymentMerchant.Partner = "000000000000000"; weChatPaymentMerchant.Key = "000000000000000000000000000000000000000000"; merchantList.Add(alipayMerchant); merchantList.Add(unionPayMerchant); merchantList.Add(weChatPaymentMerchant); // 添加到商户数据集合 notify = new PaymentNotify(merchantList); notify.PaymentSucceed += new PaymentSucceedEventHandler(notify_PaymentSucceed); notify.PaymentFailed += new PaymentFailedEventHandler(notify_PaymentFailed); notify.UnknownGateway += new UnknownGatewayEventHandler(notify_UnknownGateway); }
private void DoValidate() { NameValueCollection values2 = new NameValueCollection(); values2.Add(this.Page.Request.Form); values2.Add(this.Page.Request.QueryString); NameValueCollection parameters = values2; if (!this.isBackRequest) { parameters.Add("IsReturn", "true"); } this.Gateway = "hishop.plugins.payment.ws_wappay.wswappayrequest"; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); if (this.isBackRequest) { this.Notify.ReturnUrl = Globals.FullPath("/pay/PaymentReturn_url.aspx") + "?" + this.Page.Request.Url.Query; } this.OrderId = this.Notify.GetOrderId(); string gatewayOrderId = this.Notify.GetGatewayOrderId(); if (string.IsNullOrEmpty(this.OrderId)) { Globals.Debuglog(" OrderId:没获取到,GetewayOrderId:" + gatewayOrderId, "_DebuglogPaymentTest.txt"); this.ResponseStatus(true, "noorderId"); } else { this.orderlist = ShoppingProcessor.GetOrderMarkingOrderInfo(this.OrderId, false); if (this.orderlist.Count == 0) { Globals.Debuglog("更新订单失败,也许是订单已后台付款,OrderId:" + this.OrderId, "_DebugAlipayPayNotify.txt"); this.ResponseStatus(true, "nodata"); } else { int modeId = 0; foreach (OrderInfo info in this.orderlist) { this.Amount += info.GetTotal(); info.GatewayOrderId = gatewayOrderId; modeId = info.PaymentTypeId; } PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode(modeId); if (paymentMode == null) { Globals.Debuglog("gatewaynotfound" + this.OrderId, "_DebugAlipayPayNotify.txt"); this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += new EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new EventHandler(this.Notify_Payment); string configXml = HiCryptographer.Decrypt(paymentMode.Settings); this.Notify.VerifyNotify(0x7530, configXml); } } } }
private static void SavePayNotifyInfo(string payModuleName, PaymentNotify paymentNotify) { var payNotifyInfo = new WeiXinPayNotifyInfo { ModuleName = payModuleName, NotifyId = Guid.NewGuid(), Appid = paymentNotify.appid, Attach = paymentNotify.attach, BankType = paymentNotify.bank_type, CashFee = paymentNotify.cash_fee, CashFeeType = paymentNotify.cash_fee_type, CouponCount = paymentNotify.coupon_count, CouponFee = paymentNotify.coupon_fee, CreateTime = DateTime.Now, DeviceInfo = paymentNotify.device_info, ErrCode = paymentNotify.err_code, ErrCodeDes = paymentNotify.err_code_des, FeeType = paymentNotify.fee_type, IsSubscribe = paymentNotify.is_subscribe, MchId = paymentNotify.mch_id, NonceStr = paymentNotify.nonce_str, Openid = paymentNotify.openid, OutTradeNo = paymentNotify.out_trade_no, ResultCode = paymentNotify.result_code, ReturnCode = paymentNotify.return_code, ReturnMsg = paymentNotify.return_msg, Sign = paymentNotify.sign, TimeEnd = paymentNotify.time_end, TotalFee = paymentNotify.total_fee, TradeType = paymentNotify.trade_type, TransactionId = paymentNotify.transaction_id }; payNotifyInfo.Add(); }
protected void Page_Load(object sender, System.EventArgs e) { System.Collections.Specialized.NameValueCollection parameters = new System.Collections.Specialized.NameValueCollection { this.Page.Request.Form, this.Page.Request.QueryString }; this.Gateway = "Ecdev.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest"; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); this.OrderId = this.Notify.GetOrderId(); this.Order = ShoppingProcessor.GetOrderInfo(this.OrderId); if (this.Order == null) { base.Response.Write("<p style=\"font-size:16px;\">找不到对应的订单,你付款的订单可能已经被删除</p>"); return; } this.Amount = this.Notify.GetOrderAmount(); if (this.Amount <= 0m) { this.Amount = this.Order.GetTotal(); } this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId(); PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("Ecdev.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest"); if (paymentMode == null) { base.Response.Write("<p style=\"font-size:16px;\">找不到对应的支付方式,该支付方式可能已经被删除</p>"); return; } this.Notify.Finished += new System.EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new System.EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new System.EventHandler(this.Notify_Payment); this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(paymentMode.Settings)); }
private void DoValidate() { NameValueCollection nameValueCollection = new NameValueCollection { this.Page.Request.Form, this.Page.Request.QueryString }; this.Gateway = base.GetParameter("HIGW", false); this.Gateway = this.Gateway.Replace("_", "."); if (this.Gateway == "hishop.plugins.payment.wxqrcode.wxqrcoderequest") { string wXQRCodePayResult = this.GetWXQRCodePayResult(); nameValueCollection.Add("notify_data", wXQRCodePayResult); } this.Notify = PaymentNotify.CreateInstance(this.Gateway, nameValueCollection); if (this.Notify == null) { Globals.AppendLog(nameValueCollection, "通知对象获取失败" + this.Amount, this.Page.Request.Url.ToString(), "", "WapInpourPage"); this.ResponseStatus(true, "verifyfaild"); } else { if (this.isBackRequest) { string hIGW = this.Gateway.Replace(".", "_"); this.Notify.ReturnUrl = Globals.FullPath(base.GetRouteUrl("InpourReturn_url", new { HIGW = hIGW })) + "?" + this.Page.Request.Url.Query; } this.InpourId = this.Notify.GetOrderId(); this.Amount = this.Notify.GetOrderAmount(); this.InpourRequest = MemberProcessor.GetInpourBlance(this.InpourId); if (this.InpourRequest == null) { Globals.AppendLog(nameValueCollection, "未找到相应的充值记录---Amount:" + this.Amount, this.Page.Request.Url.ToString(), "", "WapInpourPage"); this.ResponseStatus(true, "success"); } else { this.Amount = this.InpourRequest.InpourBlance; this.paymode = TradeHelper.GetPaymentMode(this.InpourRequest.PaymentId); if (this.paymode == null) { Globals.AppendLog(nameValueCollection, "未获取到支付方式信息", this.Page.Request.Url.ToString(), "", "WapInpourPage"); this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += this.Notify_Finished; this.Notify.NotifyVerifyFaild += this.Notify_NotifyVerifyFaild; this.Notify.Payment += this.Notify_Payment; this.Notify.VerifyNotify(600000, HiCryptographer.Decrypt(this.paymode.Settings)); } } } }
public bool PayNotify(string moudleName, PaymentNotify paymentNotify, out string message) { var payNotifyRepository = DependencyManager.ResolveByName<IPayNotifyRepository>(moudleName); if (payNotifyRepository != null) return payNotifyRepository.PayNotify(paymentNotify, out message); message = string.Format("此模块{0}尚未配置支付后通知业务逻辑", moudleName); return false; }
public NotifyController(IGateways gateways) { this.gateways = gateways; notify = new PaymentNotify(gateways.Merchants); notify.PaymentSucceed += new PaymentSucceedEventHandler(notify_PaymentSucceed); notify.PaymentFailed += new PaymentFailedEventHandler(notify_PaymentFailed); notify.UnknownGateway += new UnknownGatewayEventHandler(notify_UnknownGateway); }
protected void Page_Load(object sender, EventArgs e) { NameValueCollection nameValueCollection = new NameValueCollection { this.Page.Request.Form }; this.Gateway = "hishop.plugins.payment.ws_wappay.wswappayrequest"; this.Notify = PaymentNotify.CreateInstance(this.Gateway, nameValueCollection); this.OrderId = this.Notify.GetOrderId(); this.Order = ShoppingProcessor.GetOrderInfo(this.OrderId); if (this.Order == null) { Globals.WriteLog(nameValueCollection, "订单信息不存在", "", "", "alipay"); base.Response.Write("success"); } else { this.Amount = this.Notify.GetOrderAmount(); if (this.Amount <= decimal.Zero) { this.Amount = this.Order.GetTotal(false); } this.hasNotify = !string.IsNullOrEmpty(this.Order.GatewayOrderId); if (this.Order.PreSaleId > 0 && this.Order.DepositGatewayOrderId.ToNullString() == this.Notify.GetGatewayOrderId()) { base.Response.Write("success"); } else { if (this.Order.PreSaleId > 0 && !this.Order.DepositDate.HasValue) { this.Order.DepositGatewayOrderId = this.Notify.GetGatewayOrderId(); } else { this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId(); } PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest"); if (paymentMode == null) { paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.alipaywx.alipaywxrequest"); if (paymentMode == null) { Globals.WriteLog(nameValueCollection, "支付方式获取失败hishop.plugins.payment.ws_wappay.wswappayrequest", "", "", "alipay"); base.Response.Write("success"); return; } } this.Notify.Finished += this.Notify_Finished; this.Notify.NotifyVerifyFaild += this.Notify_NotifyVerifyFaild; this.Notify.Payment += this.Notify_Payment; this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(paymentMode.Settings)); } } }
async Task Receive() { PaymentNotify notify = new PaymentNotify(_gateways); notify.PaymentSucceed += Notify_PaymentSucceed; notify.PaymentFailed += Notify_PaymentFailed; notify.UnknownGateway += Notify_UnknownGateway; await notify.ReceivedAsync(); }
protected void Page_Load(object sender, EventArgs e) { base.Response.Write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>"); NameValueCollection nameValueCollection = new NameValueCollection { this.Page.Request.QueryString }; nameValueCollection.Add("IsReturn", "true"); this.Gateway = "hishop.plugins.payment.ws_wappay.wswappayrequest"; this.Notify = PaymentNotify.CreateInstance(this.Gateway, nameValueCollection); this.OrderId = this.Notify.GetOrderId(); this.Order = ShoppingProcessor.GetOrderInfo(this.OrderId); if (this.Order == null) { base.Response.Write("<p style=\"font-size:16px;\">找不到对应的订单,你付款的订单可能已经被删除</p>"); } else { this.Amount = this.Notify.GetOrderAmount(); if (this.Amount <= decimal.Zero) { this.Amount = this.Order.GetTotal(false); } if (this.Order.PreSaleId > 0 && this.Order.DepositGatewayOrderId.ToNullString() == this.Notify.GetGatewayOrderId()) { base.Response.Write("<p style=\"font-size:16px;\">预售订单,订金已支付成功</p>"); } else { if (this.Order.PreSaleId > 0 && !this.Order.DepositDate.HasValue) { this.Order.DepositGatewayOrderId = this.Notify.GetGatewayOrderId(); } else { this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId(); } PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest"); if (paymentMode == null) { paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.alipaywx.alipaywxrequest"); if (paymentMode == null) { base.Response.Write("<p style=\"font-size:16px;\">找不到对应的支付方式,该支付方式可能已经被删除</p>"); return; } } this.Notify.Finished += this.Notify_Finished; this.Notify.NotifyVerifyFaild += this.Notify_NotifyVerifyFaild; this.Notify.Payment += this.Notify_Payment; this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(paymentMode.Settings)); } } }
public async Task Notify() { // 订阅支付通知事件 var notify = new PaymentNotify(_gateways); notify.PaymentSucceed += Notify_PaymentSucceed; notify.PaymentFailed += Notify_PaymentFailed; notify.UnknownGateway += Notify_UnknownGateway; // 接收并处理支付通知 await notify.ReceivedAsync(); }
private void DoValidate() { NameValueCollection values2 = new NameValueCollection(); values2.Add(this.Page.Request.Form); values2.Add(this.Page.Request.QueryString); NameValueCollection parameters = values2; if (!this.isBackRequest) { parameters.Add("IsReturn", "true"); } this.Gateway = "hishop.plugins.payment.ws_wappay.wswappayrequest"; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); Globals.Debuglog("充值支付:0-" + JsonConvert.SerializeObject(this.Notify), "_DebugAlipayPayNotify.txt"); try { StringBuilder builder = new StringBuilder(); foreach (string str in parameters) { builder.Append(str + ":" + parameters[str] + ";"); } Globals.Debuglog(builder.ToString(), "_DebugAlipayPayNotify.txt"); } catch (Exception) { } if (this.isBackRequest) { this.Notify.ReturnUrl = Globals.FullPath("/pay/RePaymentReturn_url.aspx") + "?" + this.Page.Request.Url.Query; } Globals.Debuglog("充值支付:1-" + JsonConvert.SerializeObject(this.Notify), "_DebugAlipayPayNotify.txt"); this.PayId = this.Notify.GetOrderId(); this.Model = MemberAmountProcessor.GetAmountDetailByPayId(this.PayId); if (this.Model != null) { this.Amount = this.Model.TradeAmount; this.Model.GatewayPayId = this.Notify.GetGatewayOrderId(); PaymentModeInfo paymentMode = MemberAmountProcessor.GetPaymentMode(this.Model.TradeWays); if (paymentMode == null) { this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += new EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new EventHandler(this.Notify_Payment); string configXml = HiCryptographer.Decrypt(paymentMode.Settings); this.Notify.VerifyNotify(0x7530, configXml); } } }
public async Task Index() { // 订阅支付通知事件 PaymentNotify notify = new PaymentNotify(gatewayList); notify.PaymentSucceed += Notify_PaymentSucceed; notify.PaymentFailed += Notify_PaymentFailed; notify.UnknownGateway += Notify_UnknownGateway; // 接收并处理支付通知 await notify.ReceivedAsync(); }
public ActionResult Index() { // 订阅支付通知事件 PaymentNotify notify = new PaymentNotify(_merchantList); notify.PaymentSucceed += notify_PaymentSucceed; notify.PaymentFailed += notify_PaymentFailed; notify.UnknownGateway += notify_UnknownGateway; // 接收并处理支付通知 notify.Received(); return(View()); }
public bool PayNotify(PaymentNotify paymentNotify,out string message) { message = string.Empty; //支付完成后修改订单状态为已支付 try { var hotelOrderService = new HotelOrderService(); hotelOrderService.PaySuccess(paymentNotify.out_trade_no); return true; } catch (Exception exception) { message = exception.Message; return false; } }
public bool PayNotify(PaymentNotify paymentNotify, out string message) { message = string.Empty; //支付完成后修改订单状态为已支付 try { var hotelOrderService = new HotelOrderService(); hotelOrderService.PaySuccess(paymentNotify.out_trade_no); return(true); } catch (Exception exception) { message = exception.Message; return(false); } }
public bool PayNotify(string moudleName, PaymentNotify paymentNotify, out string message) { //支付成功,更新支付记录状态 new PaymentInfoService().PaySuccess(paymentNotify.transaction_id); //调用业务模块的支付后操作 var payNotifyRepository = DependencyManager.ResolveByName <IPayNotifyRepository>(moudleName); if (payNotifyRepository != null) { return(payNotifyRepository.PayNotify(paymentNotify, out message)); } message = string.Format("此模块{0}尚未配置支付后通知业务逻辑", moudleName); return(false); }
protected void Page_Load(object sender, EventArgs e) { // 设置商户数据 Merchant alipayMerchant = new Merchant(); alipayMerchant.GatewayType = GatewayType.Alipay; alipayMerchant.UserName = "******"; alipayMerchant.Key = "000000000000000000000000000000000000000000"; Merchant yeepayMerchant = new Merchant(); yeepayMerchant.GatewayType = GatewayType.Yeepay; yeepayMerchant.UserName = "******"; yeepayMerchant.Key = "000000000000000000000000000000000000000000"; Merchant tenpayMerchant = new Merchant(); tenpayMerchant.GatewayType = GatewayType.Tenpay; tenpayMerchant.UserName = "******"; tenpayMerchant.Key = "000000000000000000000000000000000000000000"; Merchant weChatPaymentMerchant = new Merchant(); weChatPaymentMerchant.GatewayType = GatewayType.WeChatPay; weChatPaymentMerchant.UserName = "******"; weChatPaymentMerchant.Key = "000000000000000000000000000000000000000000"; // 添加到商户数据集合 List <Merchant> merchantList = new List <Merchant>(); merchantList.Add(alipayMerchant); merchantList.Add(yeepayMerchant); merchantList.Add(tenpayMerchant); merchantList.Add(weChatPaymentMerchant); // 订阅支付通知事件 PaymentNotify notify = new PaymentNotify(merchantList); notify.PaymentSucceed += new PaymentSucceedEventHandler(notify_PaymentSucceed); notify.PaymentFailed += new PaymentFailedEventHandler(notify_PaymentFailed); notify.UnknownGateway += new UnknownGatewayEventHandler(notify_UnknownGateway); // 接收并处理支付通知 notify.Received(); }
protected void Page_Load(object sender, EventArgs e) { // 设置商户数据 Merchant alipayMerchant = new Merchant(); alipayMerchant.GatewayType = GatewayType.Alipay; alipayMerchant.UserName = "******"; // 合作伙伴身份(PID) alipayMerchant.Key = "000000000000000000000000000000000000000000"; // MD5密钥 Merchant yeepayMerchant = new Merchant(); yeepayMerchant.GatewayType = GatewayType.Yeepay; yeepayMerchant.UserName = "******"; // 商户编号 yeepayMerchant.Key = "000000000000000000000000000000000000000000"; // 商户密钥 Merchant tenpayMerchant = new Merchant(); tenpayMerchant.GatewayType = GatewayType.Tenpay; tenpayMerchant.UserName = "******"; // 商户号 tenpayMerchant.Key = "000000000000000000000000000000000000000000"; // 密钥 Merchant weChatPaymentMerchant = new Merchant(); weChatPaymentMerchant.GatewayType = GatewayType.WeChatPay; weChatPaymentMerchant.UserName = "******"; // 微信支付商户号 weChatPaymentMerchant.Key = "000000000000000000000000000000000000000000"; // API密钥 // 添加到商户数据集合 List <Merchant> merchantList = new List <Merchant>(); merchantList.Add(alipayMerchant); merchantList.Add(yeepayMerchant); merchantList.Add(tenpayMerchant); merchantList.Add(weChatPaymentMerchant); // 订阅支付通知事件 PaymentNotify notify = new PaymentNotify(merchantList); notify.PaymentSucceed += notify_PaymentSucceed; notify.PaymentFailed += notify_PaymentFailed; notify.UnknownGateway += notify_UnknownGateway; // 接收并处理支付通知 notify.Received(); }
private void DoValidate() { System.Collections.Specialized.NameValueCollection parameters = new System.Collections.Specialized.NameValueCollection { this.Page.Request.Form, this.Page.Request.QueryString }; this.Gateway = this.Page.Request.QueryString["HIGW"]; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); if (this.isBackRequest) { this.Notify.ReturnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { this.Gateway })) + "?" + this.Page.Request.Url.Query; } this.OrderId = this.Notify.GetOrderId(); this.Order = TradeHelper.GetOrderInfo(this.OrderId); if (this.Order == null) { this.ResponseStatus(true, "ordernotfound"); } else { this.Amount = this.Notify.GetOrderAmount(); if (this.Amount <= 0m) { this.Amount = this.Order.GetTotal(); } this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId(); PaymentModeInfo paymentMode = TradeHelper.GetPaymentMode(this.Order.PaymentTypeId); if (paymentMode == null) { this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += new System.EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new System.EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new System.EventHandler(this.Notify_Payment); this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(paymentMode.Settings)); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (!string.Equals(Request.HttpMethod, "POST", StringComparison.CurrentCultureIgnoreCase)) { throw new Exception("Error HttpMethod"); } var s = Request.InputStream; var count = 0; var buffer = new byte[1024]; var builder = new StringBuilder(); while ((count = s.Read(buffer, 0, 1024)) > 0) { builder.Append(Encoding.UTF8.GetString(buffer, 0, count)); } s.Flush(); s.Close(); s.Dispose(); WriteLog(builder.ToString()); var paymentNotify = new PaymentNotify(builder.ToString()); bool isSucceed = false; var response = paymentNotify.Report(out isSucceed); if (isSucceed) { WriteLog("report Success"); //后台反馈微信信息 var wxPay = new WXPaymentOperate(); wxPay.GetPaymentCompleteInfomation(paymentNotify); } ReturnResponse(response); } catch (Exception exception) { var errorResponse = PaymentNotify.ReportError(exception.Message); ReturnResponse(errorResponse); } }
private void DoValidate() { System.Collections.Specialized.NameValueCollection parameters = new System.Collections.Specialized.NameValueCollection { this.Page.Request.Form, this.Page.Request.QueryString }; this.Gateway = this.Page.Request.QueryString["HIGW"]; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); if (this.isBackRequest) { this.Notify.ReturnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("DistributorInpourReturn_url", new object[] { this.Gateway })); PaymentNotify expr_AC = this.Notify; expr_AC.ReturnUrl = expr_AC.ReturnUrl + "?" + this.Page.Request.Url.Query; } this.InpourId = this.Notify.GetOrderId(); this.Amount = this.Notify.GetOrderAmount(); this.InpourRequest = SubsiteStoreHelper.GetInpouRequest(this.InpourId); if (this.InpourRequest == null) { this.ResponseStatus(true, "success"); } else { this.Amount = this.InpourRequest.InpourBlance; this.paymode = SubsiteStoreHelper.GetPaymentMode(this.InpourRequest.PaymentId); if (this.paymode == null) { this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += new System.EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new System.EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new System.EventHandler(this.Notify_Payment); this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(this.paymode.Settings)); } } }
private void DoValidate() { NameValueCollection values2 = new NameValueCollection(); values2.Add(this.Page.Request.Form); values2.Add(this.Page.Request.QueryString); NameValueCollection parameters = values2; this.Gateway = "hishop.plugins.payment.ws_wappay.wswappayrequest"; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); Globals.Debuglog("订单支付:0-" + JsonConvert.SerializeObject(this.Notify), "_Debuglog.txt"); if (this.isBackRequest) { this.Notify.ReturnUrl = Globals.FullPath("/pay/PaymentReturn_url.aspx") + "?" + this.Page.Request.Url.Query; } Globals.Debuglog("订单支付:1-" + JsonConvert.SerializeObject(this.Notify), "_Debuglog.txt"); this.OrderId = this.Notify.GetOrderId(); this.orderlist = ShoppingProcessor.GetOrderMarkingOrderInfo(this.OrderId); if (this.orderlist.Count != 0) { int modeId = 0; foreach (OrderInfo info in this.orderlist) { this.Amount += info.GetAmount(); info.GatewayOrderId = this.Notify.GetGatewayOrderId(); modeId = info.PaymentTypeId; } PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode(modeId); if (paymentMode == null) { this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += new EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new EventHandler(this.Notify_Payment); string configXml = HiCryptographer.Decrypt(paymentMode.Settings); this.Notify.VerifyNotify(0x7530, configXml); } } }
private void DoValidate() { NameValueCollection values2 = new NameValueCollection(); values2.Add(this.Page.Request.Form); values2.Add(this.Page.Request.QueryString); NameValueCollection parameters = values2; this.Gateway = "hishop.plugins.payment.ws_wappay.wswappayrequest"; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); if (this.isBackRequest) { this.Notify.ReturnUrl = Globals.FullPath("/pay/PaymentReturn_url.aspx") + "?" + this.Page.Request.Url.Query; } this.OrderId = this.Notify.GetOrderId(); this.Order = ShoppingProcessor.GetOrderInfo(this.OrderId); if (this.Order == null) { this.ResponseStatus(true, "ordernotfound"); } else { this.Amount = this.Notify.GetOrderAmount(); if (this.Amount <= 0M) { this.Amount = this.Order.GetTotal(); } this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId(); PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode(this.Order.PaymentTypeId); if (paymentMode == null) { this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += new EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new EventHandler(this.Notify_Payment); this.Notify.VerifyNotify(0x7530, HiCryptographer.Decrypt(paymentMode.Settings)); } } }
protected void Page_Load(object sender, EventArgs e) { NameValueCollection values2 = new NameValueCollection(); values2.Add(this.Page.Request.Form); values2.Add(this.Page.Request.QueryString); NameValueCollection parameters = values2; this.Gateway = this.Page.Request.QueryString["HIGW"]; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); if (this.isBackRequest) { this.Notify.ReturnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("DistributorPaymentReturn_url", new object[] { this.Gateway })) + "?" + this.Page.Request.Url.Query; } this.PurchaseOrderId = this.Notify.GetOrderId(); this.PurchaseOrder = SubsiteSalesHelper.GetPurchaseOrder(this.PurchaseOrderId); if (this.PurchaseOrder == null) { this.ResponseStatus(true, "purchaseordernotfound"); } else { this.Amount = this.Notify.GetOrderAmount(); if (this.Amount <= 0M) { this.Amount = this.PurchaseOrder.GetPurchaseTotal(); } PaymentModeInfo paymentMode = SubsiteStoreHelper.GetPaymentMode(this.PurchaseOrder.PaymentTypeId); if (paymentMode == null) { this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += new EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new EventHandler(this.Notify_Payment); this.Notify.VerifyNotify(0x7530, HiCryptographer.Decrypt(paymentMode.Settings)); } } }
void DoValidate() { NameValueCollection values2 = new NameValueCollection(); values2.Add(Page.Request.Form); values2.Add(Page.Request.QueryString); NameValueCollection parameters = values2; Gateway = Page.Request.QueryString["HIGW"]; Notify = PaymentNotify.CreateInstance(Gateway, parameters); if (isBackRequest) { Notify.ReturnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("DistributorInpourReturn_url", new object[] { Gateway })); Notify.ReturnUrl = Notify.ReturnUrl + "?" + Page.Request.Url.Query; } InpourId = Notify.GetOrderId(); Amount = Notify.GetOrderAmount(); InpourRequest = SubsiteStoreHelper.GetInpouRequest(InpourId); if (InpourRequest == null) { ResponseStatus(true, "success"); } else { Amount = InpourRequest.InpourBlance; paymode = SubsiteStoreHelper.GetPaymentMode(InpourRequest.PaymentId); if (paymode == null) { ResponseStatus(true, "gatewaynotfound"); } else { Notify.Finished += new EventHandler <FinishedEventArgs>(Notify_Finished); Notify.NotifyVerifyFaild += new EventHandler(Notify_NotifyVerifyFaild); Notify.Payment += new EventHandler(Notify_Payment); Notify.VerifyNotify(0x7530, Cryptographer.Decrypt(paymode.Settings)); } } }
private void DoValidate() { NameValueCollection values2 = new NameValueCollection(); values2.Add(this.Page.Request.Form); values2.Add(this.Page.Request.QueryString); NameValueCollection parameters = values2; this.Gateway = this.Page.Request.QueryString["HIGW"]; this.Notify = PaymentNotify.CreateInstance(this.Gateway, parameters); if (this.isBackRequest) { this.Notify.ReturnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("InpourReturn_url", new object[] { this.Gateway })) + "?" + this.Page.Request.Url.Query; } this.InpourId = this.Notify.GetOrderId(); this.Amount = this.Notify.GetOrderAmount(); this.InpourRequest = PersonalHelper.GetInpourBlance(this.InpourId); if (this.InpourRequest == null) { this.ResponseStatus(true, "success"); } else { this.Amount = this.InpourRequest.InpourBlance; this.paymode = TradeHelper.GetPaymentMode(this.InpourRequest.PaymentId); if (this.paymode == null) { this.ResponseStatus(true, "gatewaynotfound"); } else { this.Notify.Finished += new EventHandler <FinishedEventArgs>(this.Notify_Finished); this.Notify.NotifyVerifyFaild += new EventHandler(this.Notify_NotifyVerifyFaild); this.Notify.Payment += new EventHandler(this.Notify_Payment); this.Notify.VerifyNotify(0x7530, HiCryptographer.Decrypt(this.paymode.Settings)); } } }
public NotifyController(PaymentNotify paymentNotify) { this.paymentNotify = paymentNotify; paymentNotify.PaymentSucceed += @event => { //支付成功时时的处理代码 if (@event.PaymentNotifyMethod == PaymentNotifyMethod.AutoReturn) { //当前是用户的浏览器自动返回时显示充值成功页面 } else { //支付结果的发送方式,以服务端接收为准 } }; paymentNotify.PaymentFailed += @event => { //支付失败时的处理代码 }; paymentNotify.UnknownGateway += @event => { //无法识别支付网关时的处理代码 }; }
public static bool PayNotify(string payModuleName, PaymentNotify paymentNotify, out string message) { message = string.Empty; IPayNotifyRepository payNotify = null; //记录通知信息 SavePayNotifyInfo(payModuleName, paymentNotify); //此处应该用到IOC //switch (payModule) //{ // case PayModuleEnum.Restaurant: // payNotify = new RestaurantPayNotify(); // break; // case PayModuleEnum.Hotel: // payNotify = new HotelPayNotify(); // break; // default: // message = "异常参数支付模块ID"; // return false; //} return payNotify.PayNotify(paymentNotify, out message); }