/// <summary> /// 写日志 /// </summary> private void WriteLog(AlipayResult result) { var log = GetLog(); if (log.IsTraceEnabled == false) { return; } log.Class(GetType().FullName) .Caption("请求支付宝支付") .Content("支付方式 : {0}", GetPayWay().Description()) .Content("支付网关 : {0}", GetGatewayUrl()) .Content() .Content("请求参数:") .Content(_builder.GetDictionary()) .Content() .Content("返回结果:") .Content(result.GetDictionary()) .Content() .Content("原始请求:") .Content(_builder.ToString()) .Content() .Content("原始响应: ") .Content(result.Raw) .Trace(); }
/// <summary> /// 写日志 /// </summary> /// <param name="config">支付宝配置</param> /// <param name="builder">支付宝参数生成器</param> /// <param name="result">支付宝结果</param> protected void WriteLog(AlipayConfig config, AlipayParameterBuilder builder, AlipayResult result) { var log = GetLog(); if (log.IsTraceEnabled == false) { return; } log.Class(GetType().FullName) .Caption("支付宝支付") .Content($"支付宝方式 : {GetPayWay().Description()}") .Content($"支付网关 : {config.GetGatewayUrl()}") .Content("请求参数:") .Content(builder.GetDictionary()) .Content() .Content("返回结果:") .Content(result.GetDictionary()) .Content() .Content("原始请求:") .Content(builder.ToString()) .Content() .Content("原始响应:") .Content(result.Raw) .Trace(); }
/// <summary> /// 创建结果 /// </summary> /// <param name="builder">支付宝参数生成器</param> /// <param name="result">支付宝结果</param> /// <returns></returns> protected virtual PayResult CreateResult(AlipayParameterBuilder builder, AlipayResult result) { return(new PayResult(result.Success, result.GetTradeNo(), result.Raw) { Parameter = builder.ToString(), Message = result.GetMessage() }); }
public void TestConfig() { _builder = new AlipayParameterBuilder(new AlipayConfig { AppId = "a" }); _output.WriteLine(_builder.ToString()); Assert.Equal("app_id=a&charset=utf-8&format=json&sign_type=RSA2×tamp=2000-10-10 10:10:10&version=1.0", _builder.ToString()); }
/// <summary> /// 创建结果 /// </summary> protected override PayResult CreateResult(AlipayParameterBuilder builder, AlipayResult result) { return(new PayResult(result.Success, result.GetTradeNo(), result.Raw) { Parameter = builder.ToString(), Message = result.GetMessage(), Result = result.GetValue(AlipayConst.QrCode) }); }
/// <summary> /// 请求结果 /// </summary> protected override Task <PayResult> RequstResult(AlipayConfig config, AlipayParameterBuilder builder) { var result = builder.ToString(); WriteLog(config, builder, result); return(Task.FromResult(new PayResult { Result = result })); }
/// <summary> /// 写日志 /// </summary> protected void WriteLog(AlipayConfig config, AlipayParameterBuilder builder, string content) { Logger.Error(GetType().FullName + " 支付宝支付:" + $"支付方式 : {EnumUtil.GetEnumDescription(GetPayWay())}" + $"支付网关 : {config.GetGatewayUrl()}" + "请求参数:" + builder.GetDictionary() + "原始请求:" + builder.ToString() + "内容: " + content ); }
/// <summary> /// 获取调试参数 /// </summary> /// <param name="param">支付参数</param> public virtual async Task <string> Debug(PayParam param) { var config = await ConfigProvider.GetConfigAsync(); Validate(config, param); var builder = new AlipayParameterBuilder(config, param); Config(builder, param); return(builder.ToString()); }
/// <summary> /// 写日志 /// </summary> protected void WriteLog(AlipayConfig config, AlipayParameterBuilder builder, string content) { var log = GetLog(); if (log.IsTraceEnabled == false) { return; } log.Class(GetType().FullName) .Caption("支付宝支付") .Content($"支付方式 : {GetType()}") .Content($"支付网关 : {config.GetGatewayUrl()}") .Content("请求参数:") .Content(builder.GetDictionary()) .Content() .Content("原始请求:") .Content(builder.ToString()) .Content() .Content("内容: ") .Content(content) .Trace(); }
public void TestAppId() { _builder.AppId("a"); Assert.Equal("app_id=a&charset=utf-8&format=json&sign_type=RSA2×tamp=2000-10-10 10:10:10&version=1.0", _builder.ToString()); }
public void TestAppId() { _builder.AppId("a"); Assert.Equal("app_id=a", _builder.ToString()); }