Example #1
0
        /// <summary>
        /// <para>企业付款到银行卡</para>
        /// <para>用于企业向微信用户银行卡付款,目前支持接口API的方式向指定微信用户的银行卡付款。</para>
        /// <para>注意:请求需要双向证书</para>
        /// </summary>
        /// <param name="dataInfo"></param>
        /// <param name="timeOut"></param>
        /// <param name="cert">证书路径</param>
        /// <param name="certPassword">证书密码</param>
        /// <returns></returns>
        public static PayBankResult PayBank(
            IServiceProvider serviceProvider,
            TenPayV3PayBankRequestData dataInfo,
#if NET451
            string cert, string certPassword,
#endif
            int timeOut = Config.TIME_OUT)
        {
            var urlFormat = ReurnPayApiUrl("https://api.mch.weixin.qq.com/{0}mmpaysptrans/pay_bank");

            var data = dataInfo.PackageRequestHandler.ParseXML();//获取XML

            #region 弃用
            //var formDataBytes = data == null ? new byte[0] : Encoding.UTF8.GetBytes(data);
            //MemoryStream ms = new MemoryStream();
            //ms.Write(formDataBytes, 0, formDataBytes.Length);
            //ms.Seek(0, SeekOrigin.Begin);//设置指针读取位置
            //var resultXml = RequestUtility.HttpPost(CommonDI.CommonSP, url, null, ms);
            #endregion
#if NET451
            string responseContent = CertPost(cert, certPassword, data, urlFormat, timeOut);
#else
            string responseContent = CertPost_NetCore(serviceProvider, dataInfo.MchId, dataInfo.SubMchId, data, urlFormat, timeOut);
#endif


            return(new PayBankResult(responseContent));
        }
Example #2
0
        /// <summary>
        /// <para>企业付款到银行卡</para>
        /// <para>用于企业向微信用户银行卡付款,目前支持接口API的方式向指定微信用户的银行卡付款。</para>
        /// <para>注意:请求需要双向证书</para>
        /// </summary>
        /// <param name="dataInfo"></param>
        /// <param name="cert">证书路径</param>
        /// <param name="timeOut"></param>
        /// <param name="certPassword">证书密码</param>
        /// <returns></returns>
        public static async Task <PayBankResult> PayBankAsync(
            IServiceProvider serviceProvider,
            TenPayV3PayBankRequestData dataInfo,
#if NET462
            string cert, string certPassword,
#endif
            int timeOut = Config.TIME_OUT)
        {
            var urlFormat = ReurnPayApiUrl(Senparc.Weixin.Config.TenPayV3Host + "/{0}mmpaysptrans/pay_bank");

            var data = dataInfo.PackageRequestHandler.ParseXML();//获取XML

            #region 弃用
            //var formDataBytes = data == null ? new byte[0] : Encoding.UTF8.GetBytes(data);
            //MemoryStream ms = new MemoryStream();
            //await ms.WriteAsync(formDataBytes, 0, formDataBytes.Length);
            //ms.Seek(0, SeekOrigin.Begin);//设置指针读取位置
            //var resultXml = await RequestUtility.HttpPostAsync(CommonDI.CommonSP, urlFormat, null, ms);
            #endregion
#if NET462
            string responseContent = CertPost(cert, certPassword, data, urlFormat, timeOut);
#else
            string responseContent = await CertPost_NetCoreAsync(serviceProvider, dataInfo.MchId, dataInfo.SubMchId, data, urlFormat, timeOut).ConfigureAwait(false);
#endif
            return(new PayBankResult(responseContent));
        }
Example #3
0
        /// <summary>
        /// <para>企业付款到银行卡</para>
        /// <para>用于企业向微信用户银行卡付款,目前支持接口API的方式向指定微信用户的银行卡付款。</para>
        /// <para>注意:请求需要双向证书</para>
        /// </summary>
        /// <param name="dataInfo"></param>
        /// <param name="cert">证书路径</param>
        /// <param name="certPassword">证书密码</param>
        /// <returns></returns>
        public static PayBankResult PayBank(TenPayV3PayBankRequestData dataInfo, string cert, string certPassword)
        {
            var urlFormat = ReurnPayApiUrl("https://api.mch.weixin.qq.com/{0}mmpaysptrans/pay_bank");

            var data = dataInfo.PackageRequestHandler.ParseXML();//获取XML

            #region 弃用
            //var formDataBytes = data == null ? new byte[0] : Encoding.UTF8.GetBytes(data);
            //MemoryStream ms = new MemoryStream();
            //ms.Write(formDataBytes, 0, formDataBytes.Length);
            //ms.Seek(0, SeekOrigin.Begin);//设置指针读取位置
            //var resultXml = RequestUtility.HttpPost(url, null, ms);
            #endregion
            var resultXml = CertPost(cert, certPassword, data, urlFormat);
            return(new PayBankResult(resultXml));
        }