TenPayV3UnifiedorderRequestData_SceneInfo GetSceneInfo(WeChatUnifiedorderParamter paramter) { return(paramter.SceneInfo == null ? null : new TenPayV3UnifiedorderRequestData_SceneInfo(paramter.SceneInfo.IsH5Pay, paramter.SceneInfo.H5_Info) { store_info = new Store_Info { id = paramter.SceneInfo.id, name = paramter.SceneInfo.name, area_code = paramter.SceneInfo.area_code, address = paramter.SceneInfo.address } }); }
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 public WeChatUnifiedorderResult Pay(WeChatUnifiedorderParamter paramter) #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 { string nonceStr = GetNonceStr(paramter); string timeStamp = TenPayV3Util.GetTimestamp(); TenPayV3UnifiedorderRequestData tenPayV3UnifiedorderRequestData = new TenPayV3UnifiedorderRequestData( Options.WeChatBaseOptions.AppId, Options.WeChatBaseOptions.MchId, paramter.Body, paramter.OutTradeNo, paramter.TotalFee, Options.WeChatBaseOptions.UserHostAddress, GetNotifyUrl(Options.WeChatBaseOptions.PayNotifyUrl, WeChatNotifyType.Pay), paramter.TradeType, paramter.OpenId, Options.WeChatBaseOptions.Key, nonceStr, paramter.DeviceInfo, paramter.TimeStart, paramter.TimeExpire, GetDetail(paramter), paramter.Attach, paramter.FeeType, paramter.GoodsTag, paramter.ProductId, paramter.LimitPay, GetSceneInfo(paramter), paramter.ProfitSharing); UnifiedorderResult unfortifiedResult = TenPayV3.Unifiedorder(tenPayV3UnifiedorderRequestData); if (unfortifiedResult.return_code != Model.ReturnCode.SUCCESS) { throw new WeChatServiceException($"微信统一下单失败, return_code: {unfortifiedResult.return_code}, return_msg: {unfortifiedResult.return_msg}.", unfortifiedResult, typeof(UnifiedorderResult)); } string package = $"prepay_id={unfortifiedResult.prepay_id}"; return(new WeChatUnifiedorderResult { ResultXml = unfortifiedResult.ResultXml, DeviceInfo = unfortifiedResult.device_info, TradeType = unfortifiedResult.trade_type, MWebUrl = unfortifiedResult.mweb_url, PrepayId = unfortifiedResult.prepay_id, TimeStamp = timeStamp, NonceStr = nonceStr, Package = package, CodeUrl = unfortifiedResult.code_url, JsPaySign = TenPayV3.GetJsPaySign(Options.WeChatBaseOptions.AppId, timeStamp, nonceStr, package, Options.WeChatBaseOptions.Key) }); }
string GetDetail(WeChatUnifiedorderParamter paramter) { return(paramter.Detail == null ? null : $"<![CDATA[{JsonConvert.SerializeObject(paramter.Detail)}]]>"); }
string GetNonceStr(WeChatUnifiedorderParamter paramter) { return(string.IsNullOrWhiteSpace(paramter.NonceStr) ? TenPayV3Util.GetNoncestr() : paramter.NonceStr); }
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 public WeChatUnifiedorderResult QRPay(WeChatUnifiedorderParamter paramter) #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 { return(Pay(paramter)); }