• 微信开发 :WeixinPayInfoCollection尚未注册Mch 问题解决


    在使用开源项目 SENPARC.WEIXIN SDK 调用微信支付接口的时候出现了WeixinPayInfoCollection尚未注册Mch,这个问题。

    最后地解决方案是:

    我这个傻逼忘了在全局Global初始化TenPayV3InfoCollection

    只要在Global 添加以下代码

    //提供微信支付信息
    var tenPayV3_MchId = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_MchId"];
    var tenPayV3_Key = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_Key"];
    var tenPayV3_AppId = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_AppId"];
    var tenPayV3_AppSecret = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_AppSecret"];
    var tenPayV3_TenpayNotify = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_TenpayNotify"];

    var tenPayV3Info = new TenPayV3Info(tenPayV3_AppId, tenPayV3_AppSecret, tenPayV3_MchId, tenPayV3_Key,
    tenPayV3_TenpayNotify);
    TenPayV3InfoCollection.Register(tenPayV3Info);

    代码示例:

            private static TenPayV3Info _tenPayV3Info;
            /// <summary>
            /// v3 微信 支付模式属性
            /// </summary>
            public static TenPayV3Info TenPayV3Info
            {
                get
                {
                    if (_tenPayV3Info == null)
                    {
                        _tenPayV3Info =TenPayV3InfoCollection.Data[System.Configuration.ConfigurationManager.AppSettings["TenPayV3_MchId"]];
                    }
                    return _tenPayV3Info;
                }
            } 
    
            protected void Application_Start(object sender, EventArgs e)
            {
                RegisterWeixinPay();
            }
    
            //提供微信支付信息
            var tenPayV3_MchId = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_MchId"];
            var tenPayV3_Key = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_Key"];
            var tenPayV3_AppId = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_AppId"];
            var tenPayV3_AppSecret = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_AppSecret"];
            var tenPayV3_TenpayNotify = System.Configuration.ConfigurationManager.AppSettings["TenPayV3_TenpayNotify"];
    
            var tenPayV3Info = new TenPayV3Info(tenPayV3_AppId, tenPayV3_AppSecret, tenPayV3_MchId, tenPayV3_Key,tenPayV3_TenpayNotify);
            TenPayV3InfoCollection.Register(tenPayV3Info);

    webconfig 配置

        <!-- 微信支付V3 -->
        <add key="TenPayV3_MchId" value="TenPayV3_MchId"/>
        <add key="TenPayV3_Key" value="TenPayV3_Key"/>
        <add key="TenPayV3_AppId" value="TenPayV3_AppId"/>
        <add key="TenPayV3_AppSecret" value="TenPayV3_AppSecret"/>
        <add key="TenPayV3_TenpayNotify" value="TenPayV3_TenpayNotify"/>
  • 相关阅读:
    UVA
    UVA
    模板——扩展欧几里得算法(求ax+by=gcd的解)
    UVA
    模板——2.2 素数筛选和合数分解
    模板——素数筛选
    Educational Codeforces Round 46 (Rated for Div. 2)
    Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses
    Educational Codeforces Round 46 (Rated for Div. 2) D. Yet Another Problem On a Subsequence
    Educational Codeforces Round 46 (Rated for Div. 2) C. Covered Points Count
  • 原文地址:https://www.cnblogs.com/huangenai/p/6233807.html
Copyright © 2020-2023  润新知