Esempio n. 1
0
        /// <summary>
        /// 微信转账
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="config">配置</param>
        /// <returns>结果</returns>
        public static TransfersResult Transfers(TransfersRequest request, Config config)
        {
            TransfersResult       result = new TransfersResult();
            TransfersQueryRequest transfersQueryRequest = new TransfersQueryRequest
            {
                PartnerTradeNo = request.PartnerTradeNo
            };
            TransfersQueryResult transfersQueryResult = TransfersQuery(transfersQueryRequest, config);

            if (transfersQueryResult.Status == TransfersStatus.Success)
            {
                result.IsSuccess = TransfersStatus.Success;
                return(result);
            }
            if (transfersQueryResult.Status == TransfersStatus.Processing)
            {
                result.IsSuccess = TransfersStatus.Processing;
                return(result);
            }

            var requestStr = TenpayUtil.GetTransfersRequestXml(request, config);
            var response   = HttpHelp.PostXmlToUrl(Config.TransfersUrl, requestStr, config.GetTransfersCertPath(), config.GetPid());

            result = TenpayUtil.ConvertToTransfersResult(response);
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 微信零钱转账查询
        /// </summary>
        /// <param name="request">查询信息</param>
        /// <param name="config">配置</param>
        /// <returns>结果</returns>
        public static TransfersQueryResult TransfersQuery(TransfersQueryRequest request, Config config)
        {
            var requestStr = TenpayUtil.GetTransfersQueryRequestXml(request, config);
            var response   = HttpHelp.PostXmlToUrl(Config.TransferinfoUrl, requestStr, config.GetTransfersQueryCertPath(), config.GetPid());
            var result     = TenpayUtil.ConvertToTransfersQueryResult(response);

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 微信转账订单查询接口xml参数整理
        /// </summary>
        /// <param name="request">查询信息</param>
        /// <param name="config">config</param>
        /// <returns>xml</returns>
        public static string GetTransfersQueryRequestXml(TransfersQueryRequest request, Config config)
        {
            SortedDictionary <string, string> sParams = new SortedDictionary <string, string>
            {
                { "appid", config.GetAppId() },
                { "mch_id", config.GetPid() },
                { "nonce_str", Config.GetNoncestr() },
                { "partner_trade_no", request.PartnerTradeNo }
            };
            var sing = Signature.Getsign(sParams, config.GetKey());

            sParams.Add("sign", sing);
            StringBuilder sbPay = new StringBuilder();

            foreach (KeyValuePair <string, string> k in sParams)
            {
                sbPay.Append("<" + k.Key + "><![CDATA[" + k.Value + "]]></" + k.Key + ">");
            }
            var return_string = $"<xml>{sbPay}</xml>";

            return(return_string);
        }