回调请求说明
概述
当订单状态发生变化时,我们的系统将向您的服务器发送一个回调请求,以通知您最新的订单状态。本文档描述了您将收到的回调请求的格式和内容。
请求头
请求将包括以下请求头:
- Content-Type: application/json,指示发送的数据类型为JSON格式。
- Oc-Signature: 一个字符串,提供对请求内容的签名验证。这是为了确保请求的真实性和完整性。
请求体
请求体是一个JSON格式的字符串,包含以下字段:
- transaction_type (string): 交易类型。
- merchant_uid (string): 商户的唯一标识符。
- amount (string): 交易金额。
- currency (string): 交易使用的货币代码。
- notify_url (string): 用于接收回调的URL地址。
- merchant_order_id (string): 商户的订单ID。
- payment_status (string): 支付状态。
- order_uid (string): 订单的唯一标识符。
- signature_key (string): 用于生成签名的密钥。
- tenant (string): 租户标识符。
示例请求体
{
"transaction_type": "income",
"merchant_uid": "123456789",
"amount": "100.00",
"currency": "USD",
"notify_url": "https://yourserver.com/notify",
"merchant_order_id": "ORD1234567",
"payment_status": "completed",
"order_uid": "UID123456789",
"signature_key": "YourSignatureKey",
"tenant": "YourTenantID"
}
签名验证
请使用提供的Oc-Signature请求头和您的密钥来验证请求的签名。这是为了确保请求是从我们的系统发出的,并且请求内容在传输过程中未被篡改。
响应要求
请确保您的服务器能够正确处理此回调请求,并返回状态码200以及简单的文本响应"success"。如果我们的系统收到的响应不是200或返回内容不是"success",我们将视为回调失败,并可能采取进一步的重试机制。
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.ResponseEntity;
@RestController
public class CallbackController {
@PostMapping("/callback")
public ResponseEntity<String> handleCallback(@RequestBody String body) {
// 这里可以添加对body的处理逻辑
return ResponseEntity.ok("success");
}
}
账本查询
请求地址
http POST https://DOMAIN/octopus/api/ledger/get_merchant_ledger
基本参数
参数名称 | 类型 | 是否必须 | 描述 | 格式/示例 |
---|---|---|---|---|
merchant_uid | string | 是 | 商户UID | 联系管理员获得 |