Skip to navigation

Contract Transfers & Reconciliation

Contract Transfers & Reconciliation: Agent Java SDK v0.3.0 integration, examples, parameters and response semantics.

View as Markdown

This guide targets Agent Java SDK v0.3.0, Java 8+, and the tagged public contract. Examples run in a partner backend after initializing client in Quick Start.

Example prerequisites

The Java snippets share these imports. Initialize client using Quick Start and obtain platformUserId from the saved binding. Example user/order IDs must be replaced with your own persisted values.

import com.sixmm.agent.*;
import com.sixmm.agent.model.*;
import java.util.*;

Fixed Amount Transfer

Use transfer for fixed amount transfers. Direction.IN means transferring from the partner platform into 6MM. Direction.OUT means transferring from 6MM back to the partner platform.

Use strings or BigDecimal for amounts. Do not use double or float.

Transfer By agentUserId

import com.sixmm.agent.model.Direction;
import com.sixmm.agent.model.TransferRequest;
import com.sixmm.agent.model.TransferResponse;
TransferResponse resp = client.transfer(TransferRequest.fixed(
"AGT-ORDER-1001",
"agent-user-001",
Direction.IN,
"USDT",
"10.00"));
System.out.println(resp.orderNo);
System.out.println(resp.orderStatus);
System.out.println(resp.agentUserId);
System.out.println(resp.platformUserId);

Transfer By platformUserId

TransferResponse resp = client.transfer(TransferRequest.fixedByPlatformUserId(
"AGT-ORDER-1002",
"1188041528",
Direction.OUT,
"USDT",
"5.00"));

Provide Both IDs

If both IDs are provided, the service validates that they point to the same bound user.

TransferRequest req = TransferRequest
.fixed("AGT-ORDER-1003", "agent-user-001", Direction.IN, "USDT", "20.00")
.withPlatformUserId("1188041528");
TransferResponse resp = client.transfer(req);

Request fields:

FieldTypeRequiredDescription
agentOrderNostringYesGlobally unique partner order number
agentUserIdstringConditionallyRequired when platformUserId is absent
platformUserIdstringConditionallyRequired when agentUserId is absent
directionenumYesIN or OUT
currencystringNoFilled from defaultCurrency when absent
amountstringYesDecimal amount string

Response fields:

FieldTypeDescription
orderNostringPlatform order number
orderStatusstringSUCCESS, FAILED, PROCESSING, etc.
agentUserIdstringPartner-side user ID
platformUserIdstring6MM external user ID

Order Confirmation And Idempotency

After transfer is called, the Agent service synchronously calls the trading core on the main path. In most cases, the API response already contains the synchronous trading-core result.

ResultMeaningPartner action
SUCCESSTransfer succeededMark local order as successful
FAILEDTransfer was rejected or failedSave the failure reason and show it when appropriate
PROCESSINGTrading core timeout or network uncertaintyDo not retry with a new order number. Wait for webhook or call queryOrder

Idempotency requirements:

  • Use one agentOrderNo for one business transaction.
  • If HTTP times out or the network fails, query the same agentOrderNo first.
  • Webhooks may be retried. Deduplicate them by idempotency key.

Transfer All Out

transferAllOut moves the user’s withdrawable 6MM-side balance back to the partner platform.

import com.sixmm.agent.model.TransferAllOutRequest;
import com.sixmm.agent.model.TransferAllOutResponse;
TransferAllOutResponse resp = client.transferAllOut(
TransferAllOutRequest.of("AGT-ORDER-2001", "agent-user-001", "USDT"));
System.out.println(resp.orderStatus);
System.out.println(resp.amount);

By platformUserId:

TransferAllOutResponse resp = client.transferAllOut(
TransferAllOutRequest.byPlatformUserId("AGT-ORDER-2002", "1188041528", "USDT"));

amount in the response is the actual transferred amount.

Reverse Order

Reverse is used to compensate a successful transfer order when the backend supports the reverse flow. Typical cases include partner local order exceptions or manual reconciliation rollback.

import com.sixmm.agent.model.ReverseOrderRequest;
import com.sixmm.agent.model.ReverseOrderResponse;
ReverseOrderResponse resp = client.reverse(ReverseOrderRequest.of(
"AGT-ORDER-1001",
"REV-ORDER-1001",
"partner order rollback"));
System.out.println(resp.orderStatus);

Fields:

FieldTypeRequiredDescription
origOrderNostringYesOriginal transfer order number
reverseOrderNostringYesGlobally unique reverse order number
reverseReasonstringYesReverse reason

Notes:

  • Reverse is not a normal cancel operation.
  • Reverse orders must also be idempotent by order number.
  • After an original order is reversed, webhook may push the original order’s REVERSED final state.

Query Order

import com.sixmm.agent.model.OrderQueryType;
import com.sixmm.agent.model.QueryOrderRequest;
import com.sixmm.agent.model.QueryOrderResponse;
QueryOrderResponse resp = client.queryOrder(
QueryOrderRequest.of("AGT-ORDER-1001", OrderQueryType.TRANSFER_IN));
System.out.println(resp.status);
System.out.println(resp.failReason);

Supported orderType values:

  • TRANSFER_IN
  • TRANSFER_OUT

Common response fields:

FieldTypeDescription
orderTypestringOrder type
orderNostringPartner order number
statusstringOrder status
directionstringIN or OUT
transferModestringFIXED_AMOUNT or ALL_OUT
currencystringCurrency
amountstringAmount
agentUserIdstringPartner-side user ID
platformUserIdstring6MM external user ID
failReasonstringFailure reason
createdAtstringCreation time
completedAtstringCompletion time

List Orders

import com.sixmm.agent.model.ListOrdersRequest;
import com.sixmm.agent.model.ListOrdersResponse;
ListOrdersRequest req = ListOrdersRequest.page(1, 20);
req.orderType = "TRANSFER_IN";
req.status = "SUCCESS";
req.startTime = "2026-06-01T00:00:00Z";
req.endTime = "2026-06-16T00:00:00Z";
ListOrdersResponse resp = client.listOrders(req);
System.out.println(resp.total);
resp.orders.forEach(order -> System.out.println(order.orderNo));

Pagination recommendations:

  • page starts from 1.
  • Keep pageSize at or below 100.
  • For reconciliation jobs, page by time window and deduplicate by orderNo.

Funds event callbacks

transfer.completed may carry SUCCESS, FAILED, or an original order update of REVERSED; reverse.completed is a reversal order terminal event. transfer.dead means the final state remains unconfirmed after retries and needs manual reconciliation, not a confirmed failure. The event name alone does not prove funds were credited.

Successful acknowledgement is distinct from successful funds movement: after recording a valid targetStatus=FAILED notification, return HTTP 2xx as well. Persist funds-event deduplication by orderType:orderId:targetStatus within the merchant and environment scope.

Event fields and JSON examples · Signature verification, responses, and retries