JeffreySu/WeiXinMPSDK · error · TenpayApiRequestException

为'Order_Paid'与

Error message

{nameof(data.type)}为'Order_Paid'与{nameof(data.detail)}

What it means

SyncPayServiceOrderAsync (PayScoreApis.cs:302) syncs payment state to a Pay Score service order. When data.type is "Order_Paid" (order paid), WeChat requires data.detail (payment details) to accompany the request. The library throws TenpayApiRequestException when type is Order_Paid but detail is null; the message is a truncated/awkward phrasing meaning "when type is 'Order_Paid', detail is required".

Solutions

  1. Populate data.detail with the payment details (detail.payment_information etc.) whenever type is Order_Paid
  2. If no payment detail is available, use the appropriate non-paid sync type instead of Order_Paid
  3. Validate type/detail pairing before calling SyncPayServiceOrderAsync

Example fix

// before
var data = new SyncPayServiceOrderRequestData {
    out_order_no = orderNo,
    type = "Order_Paid"          // detail missing
};

// after
data.detail = new Detail {
    payment_information = new PaymentInformation { ... }
};
Defensive patterns

Strategy: validation

Validate before calling

if (data.type == "Order_Paid" && data.detail == null)
    throw new InvalidOperationException("detail is required when type is Order_Paid");

Type guard

bool SyncRequestValid(SyncPayServiceOrderRequestData d) =>
    d.type != "Order_Paid" || d.detail != null;

Try / catch

try { await api.SyncPayServiceOrderAsync(data); }
catch (TenpayApiRequestException ex) when (ex.Message.Contains("Order_Paid"))
{ logger.LogError(ex, "Order_Paid sync sent without detail"); throw; }

Prevention

When it happens

Trigger: Calling SyncPayServiceOrderAsync with SyncPayServiceOrderRequestData.type == "Order_Paid" while leaving data.detail null.

Common situations: Reusing a request builder for other sync types (e.g. REVOKED) where detail isn't needed and then switching to Order_Paid; forgetting to attach the payment detail (paid time, paid channel etc.) after handling the payment callback.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12). Data as JSON: /api/errors/6c8609df995350f9. Report an issue: GitHub.

Appendix: source

Thrown at src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/Apis/PayScore/PayScoreApis.cs:302

            var url = ReurnPayApiUrl($"{Senparc.Weixin.Config.TenPayV3Host}/{{0}}v3/payscore/serviceorder/{data.out_order_no}/pay");
            TenPayApiRequest tenPayApiRequest = new(_tenpayV3Setting);
            return await tenPayApiRequest.RequestAsync<PayServiceOrderReturnJson>(url, data, timeOut);
        }

        /// <summary>
        /// 同步服务订单信息接口
        /// <para>由于收款商户进行的某些“线下操作”会导致微信支付侧的订单状态与实际情况不符。例如,用户通过线下付款的方式已经完成支付,而微信支付侧并未支付成功,此时可能导致用户重复支付。因此商户需要通过订单同步接口将订单状态同步给微信支付,修改订单在微信支付系统中的状态。</para>
        /// <para>特别说明:待支付(USER_PAYING)状态下,当用户正在尝试通过收银台主动支付订单金额时,同步服务订单信息API无法调用成功,可等待3min后重试</para>
        /// <para>更多详细请参考 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_20.shtml </para>
        /// </summary>
        /// <param name="data">微信支付需要POST的Data数据</param>
        /// <param name="timeOut">超时时间,单位为ms</param>
        /// <returns></returns>
        public async Task<SyncPayServiceOrderReturnJson> SyncPayServiceOrderAsync(SyncPayServiceOrderRequestData data, int timeOut = Config.TIME_OUT)
        {
            if (data.type == "Order_Paid" && data.detail is null)
            {
                throw new TenpayApiRequestException($"{nameof(data.type)}为'Order_Paid'与{nameof(data.detail)}");
            }

            var url = ReurnPayApiUrl($"{Senparc.Weixin.Config.TenPayV3Host}/{{0}}v3/payscore/serviceorder/{data.out_order_no}/sync");
            TenPayApiRequest tenPayApiRequest = new(_tenpayV3Setting);
            return await tenPayApiRequest.RequestAsync<SyncPayServiceOrderReturnJson>(url, data, timeOut);
        }


        #endregion

        #region 支付即服务

        /// <summary>
        /// 服务人员注册接口
        /// <para>用于商户开发者为商户注册服务人员使用。</para>
        /// <para>注意:调用接口前商家需完成支付即服务产品的开通和设置。若服务商为特约商户调用接口,需在特约商户开通并完成产品设置后,与特约商户建立产品授权关系。</para>
        /// <para>更多详细请参考 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_4_1.shtml </para>
        /// </summary>

View on GitHub (pinned to be573f6f94)