重新发送交易 webhook
POST /api/resend-webhook/{transactionIdentifier}
POST https://api.fypay.me/api/resend-webhook/{transactionIdentifier}需要在 Authorization 头中提供 Bearer token。请参阅 生成令牌 获取。
将特定交易的 webhook 重新发送到已配置的 URL 或临时 URL(覆盖)。
交易标识符可以是:
- 数字交易 ID:FyPay 返回的 ID(webhooks 中的
transactionId字段) - 您的引用 ID:创建交易时提供的标识符(
externalId) - PIX End-to-End ID:webhooks 中返回的
e2eId(格式:E/D + 32 个字符)
认证
需要在 Authorization 头中提供 Bearer 令牌。
路径参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
transactionIdentifier | string | 是 | 交易标识符:数字 id、externalId 或 endToEndId |
请求体(可选)
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
url | string | 否 | 此次重新发送的临时 URL。如果未提供,重发将发送到为该事件配置的所有活跃 URL。如果提供了 URL,则使用该事件第一个活跃 URL 的 headers 和 payload 版本。该 URL 不会被持久化 |
{
"url": "https://meu-servidor.com/webhooks/fypay"
}URL 行为
- 如果未提供
url,重发会发送到为该事件配置的所有活跃 URL,每个 URL 使用各自的自定义 headers 和 payload 版本 - 如果请求体中提供了
url,则临时使用该 URL(不会持久化),使用为该事件配置的第一个活跃 URL 的自定义 headers 和 payload 版本 - 如果没有可用的 URL,返回错误 400
重发与原始发送走相同的流程:payload 会根据交易的当前状态重新构建,并使用账户当前的 HMAC secret 在 X-Avista-Signature header 中签名(在控制台生成签名密钥之前,重发请求不带该 header)。
代码示例
curl -X POST "https://api.fypay.me/api/resend-webhook/PAG-2024-0001" \
-H "Authorization: Bearer $FYPAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://meu-servidor.com/webhooks/fypay"
}'const axios = require('axios');
const response = await axios.post('https://api.fypay.me/api/resend-webhook/PAG-2024-0001',
{
"url": "https://meu-servidor.com/webhooks/fypay"
},
{
headers: {
'Authorization': `Bearer ${process.env.FYPAY_TOKEN}`,
'Content-Type': 'application/json',
},
}
);
console.log(response.data);import os, requests
response = requests.post(
'https://api.fypay.me/api/resend-webhook/PAG-2024-0001',
headers={
'Authorization': f'Bearer {os.environ["FYPAY_TOKEN"]}',
'Content-Type': 'application/json',
},
json={
"url": "https://meu-servidor.com/webhooks/fypay"
},
)
print(response.json())$ch = curl_init('https://api.fypay.me/api/resend-webhook/PAG-2024-0001');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('FYPAY_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{
"url": "https://meu-servidor.com/webhooks/fypay"
}',
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;String body = """
{
"url": "https://meu-servidor.com/webhooks/fypay"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.fypay.me/api/resend-webhook/PAG-2024-0001"))
.header("Authorization", "Bearer " + System.getenv("FYPAY_TOKEN"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());响应 (200)
| 字段 | 类型 | 描述 |
|---|---|---|
message | string | 结果描述信息 |
webhookLogId | number | 为审计生成的 webhook 日志 ID |
sentAt | string | Webhook 发送日期/时间(ISO 8601) |
statusCode | number | 目标 URL 返回的 HTTP 状态码 |
{
"message": "Webhook resent successfully",
"webhookLogId": 12345,
"sentAt": "2024-01-15T10:30:00.000Z",
"statusCode": 200
}错误
| 状态码 | 描述 |
|---|---|
| 400 | 没有可用的 webhook URL。请为此交易的操作类型配置 webhook,或在 url 字段中提供临时 URL |
| 401 | 令牌无效、已过期或缺失 |
| 404 | 交易未找到或不属于已认证的账户 |
| 429 | 超过每个账户每分钟 60 次请求的限制。请等待时间窗口重置(Retry-After 响应头) |
| 502 | 目标 URL 返回了非 2xx 状态码。响应体包含 message、webhookLogId 和 sentAt |
| 504 | 目标 URL 未在 10 秒内响应。响应体包含 message、webhookLogId 和 sentAt |