public UnifiedorderResult Unifiedorder(UnifiedorderRequest model) { var url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; UnifiedorderResult result = null; model.AppId = WeChatConfig.AppId; model.MchId = PayConfig.MchId; model.NonceStr = PayUtil.GetNoncestr(); if (model.NotifyUrl == null) { model.NotifyUrl = PayConfig.Notify; } var dictionary = PayUtil.GetAuthors(model); model.Sign = PayUtil.CreateMd5Sign(dictionary, PayConfig.TenPayKey); //生成Sign result = PostXML <UnifiedorderResult>(url, model); return(result); }
/// <summary> /// 统一下单接口 /// https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1 /// </summary> /// <param name="model"></param> /// <param name="sceneInfo"></param> /// <param name="tenPayKey"></param> /// <returns></returns> public UnifiedorderResult Unifiedorder(UnifiedorderRequest model, SceneInfo sceneInfo = null, string tenPayKey = null) { var url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; UnifiedorderResult result = null; model.AppId = model.AppId ?? WeChatConfig.AppId; model.MchId = model.MchId ?? PayConfig.MchId; model.NonceStr = PayUtil.GetNoncestr(); model.NotifyUrl = model.NotifyUrl ?? PayConfig.Notify; if (sceneInfo != null) { model.SceneInfo = JsonConvert.SerializeObject(sceneInfo); } var dictionary = PayUtil.GetAuthors(model); model.Sign = PayUtil.CreateMd5Sign(dictionary, tenPayKey ?? PayConfig.TenPayKey); //生成Sign result = PostXML <UnifiedorderResult>(url, model); return(result); }