Z Zise Developers 简体中文

Change maturity handling: enum principal_interest, not both

PATCH /v1/earn/orders/{id}/rollover scope: earn:write
On behalf of a member · x-on-behalf-of required

Editable only before maturity: orders already settling or settled are rejected with state_invalid. If the product-level renewal switch is off, only none is allowed.

⚠ Only three enums exist: none / principal / principal_interest. both is rejected; it never existed and was once sent incorrectly by the member client. This endpoint never silently falls back: invalid values produce errors.

⚠ No idempotency key is required; this is a fund-neutral, idempotent UPDATE.

⚠ Changes appear in the member’s Earn timeline with a “initiated by merchant API” marker, visible to the end user.

Prerequisites

  • Order belongs to this member and your merchant; otherwise 404
  • Order has not entered settlement: one of pending_start / starting / accruing / pending_settle
  • Setting principal or principal_interest requires a renewable product

Path Parameters

FieldTypeRequiredDescription
id string Required Fixed-term order ID, with or without ero_.
FieldTypeRequiredDescription
x-on-behalf-of string Required Member who owns the order.

Request Body

FieldTypeRequiredDescription
mode "none" | "principal" | "principal_interest" Required Maturity handling, required and exactly one of the three values. none returns principal and interest to available balance; principal renews principal only and returns interest; principal_interest renews both.

Response

200Updated. Response contains only the order ID and new handling mode.
{
  "id": "ero_c41d7f92-8a03-4bb6-9e10-5f2c8d3a7061",
  "rollover_mode": "principal_interest"
}
400invalid_request: mode is outside the three values, including both. · state_invalid: product not renewable or order outside the editable window. · member_context_required · member_not_found
403insufficient_scope: this key lacks earn:write
404not_found: order nonexistent, not associated with this member, or not owned by you. All three share one response.
Request
curl -X PATCH 'https://api.zinfra.vip/v1/earn/orders/{id}/rollover' \
  -H 'x-auth-token: Bearer $TOKEN' \
  -H 'x-on-behalf-of: $MEMBER_ID' \
  -H 'content-type: application/json' \
  -d '{
    "mode": "principal_interest"
  }'
const res = await fetch("https://api.zinfra.vip/v1/earn/orders/{id}/rollover", {
  method: "PATCH",
  headers: {
    "x-auth-token": "Bearer $TOKEN",
    "x-on-behalf-of": "$MEMBER_ID",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "mode": "principal_interest"
  }),
});
// Keep monetary amounts as strings, never numbers.
const data = await res.json();
import requests

res = requests.patch(
    "https://api.zinfra.vip/v1/earn/orders/{id}/rollover",
    headers={
        "x-auth-token": "Bearer $TOKEN",
        "x-on-behalf-of": "$MEMBER_ID",
        "content-type": "application/json",
    },
    json={
      "mode": "principal_interest"
    },
)
# Use Decimal(str(...)) for amounts, not float.
data = res.json()
req, _ := http.NewRequest("PATCH", "https://api.zinfra.vip/v1/earn/orders/{id}/rollover",
    strings.NewReader(`{
  "mode": "principal_interest"
}`))
req.Header.Set("x-auth-token", "Bearer $TOKEN")
req.Header.Set("x-on-behalf-of", "$MEMBER_ID")
req.Header.Set("content-type", "application/json")
res, err := http.DefaultClient.Do(req)
// Decode amount fields as string, not float64.
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.zinfra.vip/v1/earn/orders/{id}/rollover"))
    .header("x-auth-token", "Bearer $TOKEN")
    .header("x-on-behalf-of", "$MEMBER_ID")
    .header("content-type", "application/json")
    .method("PATCH", HttpRequest.BodyPublishers.ofString("""
{
  "mode": "principal_interest"
}
"""))
    .build();
// Use String / BigDecimal for amounts, not double.
$ch = curl_init('https://api.zinfra.vip/v1/earn/orders/{id}/rollover');
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'PATCH',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'x-auth-token: Bearer $TOKEN',
    'x-on-behalf-of: $MEMBER_ID',
    'content-type: application/json',
  ],
  CURLOPT_POSTFIELDS => <<<'JSON'
{
  "mode": "principal_interest"
}
JSON,
]);
$res = curl_exec($ch);
// Use bcmath / strings for amounts, not floatval.
200
{
  "id": "ero_c41d7f92-8a03-4bb6-9e10-5f2c8d3a7061",
  "rollover_mode": "principal_interest"
}