WxPayAPI/business/NativeNotify.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WxPayAPI
{
/// <summary>
/// 扫码支付模式一回调处理类
/// 接收微信支付后台发送的扫码结果,调用统一下单接口并将下单结果返回给微信支付后台
/// </summary>
public class NativeNotify:Notify
{
public NativeNotify(Page page):base(page)
{
}
public override void ProcessNotify()
{
WxPayData notifyData = GetNotifyData();
//检查openid和product_id是否返回
if (!notifyData.IsSet("openid") || !notifyData.IsSet("product_id"))
{
WxPayData res = new WxPayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", "回调数据异常");
Log.Info(this.GetType().ToString(), "The data WeChat post is error : " + res.ToXml());
page.Response.Write(res.ToXml());
page.Response.End();
}
//调统一下单接口,获得下单结果
string openid = notifyData.GetValue("openid").ToString();
string product_id = notifyData.GetValue("product_id").ToString();
WxPayData unifiedOrderResult = new WxPayData();
try
{
unifiedOrderResult = UnifiedOrder(openid, product_id);
}
catch(Exception ex)//若在调统一下单接口时抛异常,立即返回结果给微信支付后台
{
WxPayData res = new WxPayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", "统一下单失败");
Log.Error(this.GetType().ToString(), "UnifiedOrder failure : " + res.ToXml());
page.Response.Write(res.ToXml());
page.Response.End();
}
//若下单失败,则立即返回结果给微信支付后台
if (!unifiedOrderResult.IsSet("appid") || !unifiedOrderResult.IsSet("mch_id") || !unifiedOrderResult.IsSet("prepay_id"))
{
WxPayData res = new WxPayData();
res.SetValue("return_code", "FAIL");
res.SetValue("return_msg", "统一下单失败");
Log.Error(this.GetType().ToString(), "UnifiedOrder failure : " + res.ToXml());
page.Response.Write(res.ToXml());
后面还有 39 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。