public async Task <T> ExecuteAsync <T>(ILcswPayResquest <T> request, LcswPayOption option) where T : LcswPayResponse { //赋值通用参数 if (string.IsNullOrEmpty(request.PayVersion) && !string.IsNullOrEmpty(option.Version)) { request.PayVersion = option.Version; } if (string.IsNullOrEmpty(request.MerchantNo) && !string.IsNullOrEmpty(option.MerchantNo)) { request.MerchantNo = option.MerchantNo; } if (string.IsNullOrEmpty(request.TerminalId) && !string.IsNullOrEmpty(option.TerminalId)) { request.TerminalId = option.TerminalId; } //计算签名 var signParas = request.GetSignInfo(); var requestParas = signParas.GetAllParasAndSign(option); //执行请求 var url = request.GetRequestUrl().ToFullApiUrl(option.ApiBaseUrl); var content = JsonConvert.SerializeObject(requestParas); _logger.Log(option.LogLevel, $"Request content:{content};url:{url}"); using (var client = _clientFactory.CreateClient()) { var body = await client.DoPostAsync(url, content); //处理响应 _logger.Log(option.LogLevel, "Response:{body}", body); var parser = new LcswPayJsonParser <T>(); var response = parser.Parse(body); if (request.IsCheckResponseSign()) { response.CheckSign(); } return(response); } }
public async Task <T> ExecuteAsync <T>(ILcswPayResquest <T> request, string optionsName) where T : LcswPayResponse { var option = _optionsSnapshotAccessor.Get(optionsName); return(await ExecuteAsync(request, option)); }
public async Task <T> ExecuteAsync <T>(ILcswPayResquest <T> request) where T : LcswPayResponse { return(await ExecuteAsync(request, (string)null)); }