Response to server-side API requests: 400: Bad request

billing_issue_detected_at_date_comparison_error

账单问题发生在订阅续费尝试过程中出现错误时,因此它始终发生在交易日期(purchased_at)之后。

要解决此问题,请确保账单问题日期(billing_issue_detected_at)晚于交易日期(purchased_at)。

请求体

参数类型描述
errorsObject
  • source: (string) 始终为 billing_issue_detected_at
  • errors: 错误描述。
error_codeString错误简称。始终为 billing_issue_detected_at_date_comparison_error
status_codeIntegerHTTP 状态码。始终为 400

响应示例

{
  "errors": [
    {
      "source": "billing_issue_detected_at",
      "errors": [
        "billing_issue_detected_at must be later than purchased_at."
      ]
    }
  ],
  "error_code": "billing_issue_detected_at_date_comparison_error",
  "status_code": 400
}

expires_date_error

用户无法购买已过期的订阅。因此,expires_at 日期(订阅到期时间)应始终晚于 purchased_at 日期(交易发生时间)。

要解决此问题,请检查这两个日期,确保 expires_at 晚于 purchased_at

请求体

参数类型描述
errorsObject
  • source:(字符串)始终为 expires_at
  • errors:错误描述。
error_codeString错误简称。始终为 expires_date_error
status_codeIntegerHTTP 状态码。始终为 400

响应示例

{
  "errors": [
    {
      "source": "expires_at",
      "errors": [
        "expires_at must be later than purchased_at."
      ]
    }
  ],
  "error_code": "expires_date_error",
  "status_code": 400
}

family_share_price_error

请求失败,因为 is_family_shared 参数设置为 true,表示访问等级已免费与家庭成员共享。但是,Price 对象的 value 参数未设置为零。

如果 is_family_shared 应为 true,请确保将 Price 对象的 value 参数设置为 0

Body

参数类型描述
errorsObject
  • source: (string) 固定值为 is_family_shared
  • errors: 错误描述。
error_codeString简短的错误名称。固定值为:family_share_price_error
status_codeIntegerHTTP 状态码。固定值为 400

响应示例

未找到用户画像

{
  "errors": [
    {
      "source": "is_family_shared",
      "errors": [
        "If is_family_shared is true, price.value must be 0."
      ]
    }
  ],
  "error_code": "family_share_price_error",
  "status_code": 400
}

free_trial_price_error

请求失败,原因是 offer_type 参数设置为 free_trial,但 Price 对象的 value 参数未设置为零。

另一个可能的原因是 offer_id 参数已包含但设置为 null,而该参数不能为 null。在这种情况下,请为 offer_id 提供一个值,或者完全移除该参数。

请求体

参数类型描述
errorsObject
  • source:(字符串)始终为 offer.type
  • errors:错误描述。
error_codeString错误简称。始终为:free_trial_price_error
status_codeIntegerHTTP 状态码。始终为 400

响应示例

未找到用户画像

{
  "errors": [
    {
      "source": "offer_type",
      "errors": [
        "If offer_type is 'free_trial', price.value must be 0."
      ]
    }
  ],
  "error_code": "free_trial_price_error",
  "status_code": 400
}

grace_period_expires_date_error

宽限期是您可以给予客户的额外时间,用于在未能按时续订的情况下延长其订阅——例如,信用卡扣款失败时。这有助于在客户解决问题期间保持其设置不变。提供宽限期是可选的。

如果您提供宽限期,其到期日期(grace_period_expires_at)应晚于订阅到期日期(expires_at)。否则,宽限期到期时间将与订阅到期时间相同。无论如何,宽限期到期时间不能早于订阅到期时间。

要解决此问题,请确保宽限期到期日期(grace_period_expires_at)晚于订阅到期日期(expires_at)。

请求体

参数类型描述
errorsObject
  • source:(字符串)始终为 grace_period_expires_at
  • errors:错误描述。
error_codeString错误简称。始终为 grace_period_expires_date_error
status_codeIntegerHTTP 状态码。始终为 400

响应示例

{
  "errors": [
    {
      "source": "grace_period_expires_at",
      "errors": [
        "grace_period_expires_at must be later or equal to expires_at."
      ]
    }
  ],
  "error_code": "grace_period_expires_date_error",
  "status_code": 400
}

grace_period_billing_error

宽限期的开始计为计费问题。因此,如果宽限期已开始(由 grace_period_expires_at 参数已填写来表示),则其开始日期应记录在 billing_issue_detected_at 参数中。

要解决此问题,请在 billing_issue_detected_at 中设置宽限期的开始日期;或者,如果宽限期尚未开始,请移除 grace_period_expires_at 参数。

请求体

参数类型描述
errorsObject
  • source: (string) 固定值为 grace_period_billing_error
  • errors: 错误描述。
error_codeString简短错误名称。固定值为 grace_period_billing_error
status_codeIntegerHTTP 状态码。固定值为 400

响应示例

{
  "errors": [
    {
      "source": "grace_period_billing_error",
      "errors": [
        "If grace_period_expires_at is specified, billing_issue_detected_at must also be specified."
      ]
    }
  ],
  "error_code": "grace_period_billing_error",
  "status_code": 400
}

missing_offer_id

请求失败,原因是 offer_category 参数的值不是 introductoryoffer_type,但请求中未包含 offer_id。在这种情况下,请提供 offer_id,或从请求中移除 offer_categoryoffer_type

另一个可能的原因是 offer_id 参数已添加但值为 null,而该参数不允许为 null。如果是这种情况,请为 offer_id 提供一个值,或完全移除该参数。

Body

参数类型描述
errorsObject
  • source: (string) 固定值为 offer.category
  • errors: 错误描述。
error_codeString简短的错误名称。可能的值:missing_offer_id
status_codeIntegerHTTP 状态码。固定值为 400

响应示例

未找到用户画像

{
  "errors": [
    {
      "source": "offer_category",
      "errors": [
        "offer_id must be specified for all offer types except 'introductory'."
      ]
    }
  ],
  "error_code": "missing_offer_id",
  "status_code": 400
}

one_time_purchase_trial_error

该请求失败,原因是为一次性购买提供了试用期。与订阅不同,一次性购买不能设置试用期。要解决此问题,请检查 One-Time Purchase 对象中 Offer 对象里的 offer_type 字段。offer_type 的值不能为 free_trial。请更改 offer_type 字段的值,或改用 Subscription 对象替代一次性购买。

Body

参数类型描述
errorsObject
  • source:(字符串)固定为 offer.type
  • errors:错误描述。
error_codeString简短错误名称。固定为 one_time_purchase_trial_error
status_codeIntegerHTTP 状态码。固定为 400

响应示例

{
  "errors": [
    {
      "source": "offer.type",
      "errors": [
        "One-time purchase cannot have a trial."
      ]
    }
  ],
  "error_code": "one_time_purchase_trial_error",
  "status_code": 400
}

originally_purchased_date_error

对于持续续订的订阅,会创建一条交易链。原始交易是该链中的第一笔,它将后续所有交易关联在一起。每次续订都只是对原始交易的延续。如果该交易是首次购买,则它本身即为原始交易。

originally_purchased_at 时间戳标记原始购买的时间,而 purchased_at 则标记当前交易的时间。因此,purchased_at 不可能早于 originally_purchased_at;最多在第一笔交易时两者相同。

本次请求失败,原因是 originally_purchased_at 被设置为晚于 purchased_at 的日期。请确保其早于或等于 purchased_at

响应体

参数类型描述
errorsObject
  • source: (string) 固定值为 originally_purchased_at
  • errors: 错误的详细描述。
error_codeString简短错误名称。固定值为 originally_purchased_date_error
status_codeIntegerHTTP 状态码。固定值为 400

响应示例

{
  "errors": [
    {
      "source": "originally_purchased_at",
      "errors": [
        "originally_purchased_at must be earlier than or equal to purchased_at."
      ]
    }
  ],
  "error_code": "originally_purchased_date_error",
  "status_code": 400
}

请求失败,因为在请求中找不到对应的访问等级。请仔细检查 access_level_id 中是否存在拼写错误,并确认它与正确的应用相匹配。

请求体

参数类型描述
errorsObject
  • source:(string)始终为 non_field_errors
  • errors:错误描述。
error_codeString简短的错误名称。可能的值:paid_access_level_does_not_exist
status_codeIntegerHTTP 状态码。始终为 404

响应示例

未找到访问等级。

{
  "errors": [
    {
      "source": "non_field_errors",
      "errors": [
        "Paid access level `premium` does not exist"
      ]
    }
  ],
  "error_code": "paid_access_level_does_not_exist",
  "status_code": 400
}

profile_does_not_exist

请求失败,因为在请求头中未找到对应的用户画像。请仔细检查请求头中输入的 profile_idcustomer_user_id 是否存在拼写错误,并确认其对应的应用是否正确。

Body

参数类型描述
errorsObject
  • source: (string) 始终为 non_field_errors
  • errors: 错误描述。
error_codeString简短的错误名称。可能的值:profile_does_not_exist
status_codeIntegerHTTP 状态码。始终为 400

响应示例

未找到用户画像

{
  "errors": [
    {
      "source": "non_field_errors",
      "errors": [
        "Profile not found"
      ]
    }
  ],
  "error_code": "profile_does_not_exist",
  "status_code": 400
}

profile_paid_access_level_does_not_exist

请求失败,因为请求中的用户画像与指定的访问等级不匹配。请仔细检查请求头中的用户画像 ID 和请求体中的访问等级 ID 是否正确,并确保没有拼写错误。

Body

参数类型描述
errorsObject
  • source: (string) 始终为 non_field_errors
  • errors: 错误描述。
error_codeString简短错误名称。始终为 profile_paid_access_level_does_not_exist
status_codeIntegerHTTP 状态码。始终为 400

响应示例

{
  "errors": [
    {
      "source": "non_field_errors",
      "errors": [
        "Profile `478b2e7f-d557-4b8b-9c5f-cbd46fc2dee2` has no `premium` access level"
      ]
    }
  ],
  "error_code": "profile_paid_access_level_does_not_exist",
  "status_code": 400
}

refund_date_error

请求失败,因为购买日期(purchased_at)早于或等于退款日期(refunded_at)。退款始终发生在购买之后,因为它是对交易的撤销操作。

要修复此问题,请检查 purchased_atrefunded_at 参数,并确保退款日期晚于购买日期。

Body

参数类型描述
errorsObject
  • source:(string)始终为 refunded_at
  • errors:错误描述。
error_codeString简短的错误名称。始终为 refund_date_error
status_codeIntegerHTTP 状态码。始终为 400

响应示例

{
  "errors": [
    {
      "source": "refunded_at",
      "errors": [
        "refunded_at must be later than purchased_at."
      ]
    }
  ],
  "error_code": "refund_date_error",
  "status_code": 400
}

refund_fields_error

该请求失败,原因是包含了 cancellation_reason 但未提供 refunded_at 日期,或者提供了 refunded_at 但未指定 cancellation_reason

设置退款时,退款日期和退款原因必须同时指定。

Body

参数类型描述
errorsObject
  • source:(string)始终为 refunded_at
  • errors:错误描述。
error_codeString简短错误名称。始终为 refund_fields_error
status_codeIntegerHTTP 状态码。始终为 400

响应示例

{
  "errors": [
    {
      "source": "refunded_at",
      "errors": [
        "refunded_at and cancellation_reason=refund must be specified together."
      ]
    }
  ],
  "error_code": "refund_fields_error",
  "status_code": 400
}

renew_status_changed_date_error

续订是订阅的延续。用户可以取消订阅续订,之后再重新续订。这两个操作的时间均存储在 renew_status_changed_at 参数中,且该时间不能早于交易本身的时间。

要解决此问题,请确保 renew_status_changed_at 晚于交易时间(purchased_at)。

请求体

参数类型描述
errorsObject
  • source:(字符串)始终为 originally_purchased_at
  • errors:错误描述。
error_codeString简短错误名称。始终为 originally_purchased_date_error
status_codeIntegerHTTP 状态码。始终为 400

响应示例

{
  "errors": [
    {
      "source": "renew_status_changed_at",
      "errors": [
        "renew_status_changed_at must be later than purchased_at."
      ]
    }
  ],
  "error_code": "renew_status_changed_date_error",
  "status_code": 400
}

revocation_date_more_than_expiration_date

请求失败,因为您在请求中定义的 revoke_at 晚于当前访问等级的 expires_at 参数。如果您想延长访问等级,请使用授予访问等级请求。

请求体

参数类型描述
errorsObject
  • source:(string)始终为 non_field_errors
  • errors:错误描述。
error_codeString错误简称。始终为 revocation_date_more_than_expiration_date
status_codeIntegerHTTP 状态码。始终为 400

响应示例

  {
  "errors": [
    {
      "source": "revoke_at",
      "errors": [
        "Revocation date (2029-08-29 09:33:42+00:00) is more than current expiration date (2028-08-29 09:33:42+00:00)"
      ]
    }
  ],
  "error_code": "revocation_date_more_than_expiration_date",
  "status_code": 400
}

store_transaction_id_error

对于长期订阅,会生成一条订阅链。原始交易是该链中的第一笔交易,整条链通过它关联。链中的其他交易均为续订。如果某笔交易是订阅链中的第一次购买,它可以作为自身的原始交易。

另一种情况是一次性购买。由于无法续订,它不会创建订阅链。对于一次性购买,store_transaction_id 始终与 store_original_transaction_id 相同。

您的请求失败,原因是 一次性购买 对象中的 store_transaction_id 值与其 store_original_transaction_id 不同。要解决此问题,请将两者设为相同值,或更改对象类型——使用 订阅 替代 一次性购买

Body

参数类型描述
errorsObject
  • source:(string)始终为 store_transaction_id
  • errors:错误描述。
error_codeString简短错误名称。始终为 store_transaction_id_error
status_codeIntegerHTTP 状态码。始终为 400

响应示例

{
  "errors": [
    {
      "source": "store_transaction_id",
      "errors": [
        "store_transaction_id must be equal to store_original_transaction_id for purchase."
      ]
    }
  ],
  "error_code": "store_transaction_id_error",
  "status_code": 400
}

value_error

请求失败,因为指定的撤销日期已过期。请将 revoke_at 设置为未来的日期,或设置为 null 以立即撤销访问权限。

Body
参数类型描述
errorsObject
  • source:(string)始终为 revoke_at
  • errors:错误描述。
error_codeString错误简称。始终为 value_error
status_codeIntegerHTTP 状态码。始终为 400
响应示例
{
    "errors": [
        {
            "source": null,
            "errors": [
                "Must be greater than the current time or null"
            ]
        }
    ],
    "error_code": "value_error",
    "status_code": 400
}