{"record":{"id":"1060e1877ecdccd1","repo":"JeffreySu/WeiXinMPSDK","slug":"apply4subjectapis-current","errorCode":null,"errorMessage":"业务申请编号和微信支付申请单编号至少填写一个。","messagePattern":"业务申请编号和微信支付申请单编号至少填写一个。","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/Apis/Apply4Subject/Apply4SubjectApis.Current.cs","lineNumber":68,"sourceCode":"                timeOut);\n        }\n\n        /// <summary>\n        /// 撤销商户开户意愿确认申请单。\n        /// </summary>\n        /// <param name=\"businessCode\">业务申请编号，与 applymentId 至少填写一个。</param>\n        /// <param name=\"applymentId\">微信支付申请单编号，与 businessCode 至少填写一个。</param>\n        /// <param name=\"timeOut\">代理请求超时时间（毫秒）。</param>\n        /// <returns>微信支付接口结果；成功时官方返回 HTTP 204。</returns>\n        public Task<ReturnJsonBase> CancelApplymentAsync(string businessCode = null,\n            long? applymentId = null, int timeOut = Config.TIME_OUT)\n        {\n            var identifier = !string.IsNullOrWhiteSpace(businessCode)\n                ? businessCode\n                : applymentId?.ToString();\n            if (string.IsNullOrWhiteSpace(identifier))\n            {\n                throw new ArgumentException(\"业务申请编号和微信支付申请单编号至少填写一个。\");\n            }\n\n            var path = $\"v3/apply4subject/applyment/{Escape(identifier)}/cancel\";\n            if (!string.IsNullOrWhiteSpace(businessCode) && applymentId.HasValue)\n            {\n                path += $\"?applyment_id={applymentId.Value}\";\n            }\n\n            var request = new TenPayApiRequest(_tenpayV3Setting);\n            return request.RequestWithoutBodyAsync<ReturnJsonBase>(GetUrl(path), timeOut);\n        }\n\n        /// <summary>\n        /// 查询商户开户意愿确认申请单审核结果。\n        /// </summary>\n        /// <param name=\"applymentId\">微信支付申请单编号，与 businessCode 至少填写一个。</param>\n        /// <param name=\"businessCode\">业务申请编号，与 applymentId 至少填写一个。</param>\n        /// <param name=\"timeOut\">代理请求超时时间（毫秒）。</param>","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/Apis/Apply4Subject/Apply4SubjectApis.Current.cs#L50-L86","documentation":"CancelApplymentAsync (v3/apply4subject applyment cancel API) needs an identifier for the applyment to cancel: either businessCode (业务申请编号) or applymentId (微信支付申请单编号). If neither yields a non-empty identifier, an ArgumentException is thrown before building the request path.","triggerScenarios":"Calling CancelApplymentAsync with businessCode null/whitespace AND applymentId null (or a nullable that HasValue == false).","commonSituations":"The applyment flow stored neither code because the apply request failed earlier, or businessCode was trimmed to empty and applymentId was never persisted, so cancellation cannot target any application.","solutions":["Pass the businessCode you supplied when creating the applyment.","Or pass the applymentId returned by WeChat Pay in the applyment response.","If both are missing, re-query the applyment status first (e.g. via the query API) to recover the id, or skip cancellation since there is nothing to cancel."],"exampleFix":"// before\nawait apis.CancelApplymentAsync(null, null);\n// after\nawait apis.CancelApplymentAsync(businessCode: \"APPLY_20240101_001\", applymentId: null);\n// or\nawait apis.CancelApplymentAsync(null, applymentId: 2000002123456789);","handlingStrategy":"validation","validationCode":"// C#\nif (string.IsNullOrWhiteSpace(businessCode) && (applymentId is null || applymentId <= 0))\n    throw new InvalidOperationException(\"CancelApplyment requires businessCode or applymentId\");","typeGuard":"bool HasApplymentIdentifier(string businessCode, long? applymentId) => !string.IsNullOrWhiteSpace(businessCode) || applymentId.HasValue;","tryCatchPattern":"try { await apis.CancelApplymentAsync(businessCode, applymentId); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"至少填写一个\")) { log.LogWarning(\"No applyment identifier available; nothing to cancel\"); }","preventionTips":["Persist the applymentId from the applyment creation response immediately","Always store businessCode alongside order records","Only invoke cancel when at least one identifier was recorded"],"tags":["argument-validation","applyment","weixin-tenpay"],"backgroundTag":"missing-required-argument","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}