سواپولت هر بار که وبهوک invoice-paid را میفرستد، درخواست و پاسخ سرور شما را ثبت میکند. با خواندن این سابقه برای هر فاکتور، endpoint خود را عیبیابی کنید و پس از رفع مشکل، وبهوک را دوباره بفرستید.
سواپولت ارسالهای ناموفق را خودش حدود سه روز تکرار میکند (رویدادهای وبهوک را ببینید)؛ پس بعد از یک قطعی کوتاه لازم نیست کاری بکنید.
وضعیت وبهوک یک فاکتور و همهی تلاشها برای ارسال آن، همراه با آنچه فرستاده شده و پاسخ سرور شما.
statusenumوضعیت کلی وبهوک.
مقدارهای ممکن
DISABLEDنه فاکتور آدرس وبهوک دارد، نه کسبوکار.PENDINGهنوز چیزی فرستاده نشده.SUCCEEDدستکم یکی از تلاشها موفق بوده.FAILEDهمهی تلاشها تا این لحظه ناموفق بودهاند. ممکن است سواپولت هنوز در حال تلاش دوباره باشد.callsarray of objectsهمهی تلاشهای ارسال، از قدیمیترین.
requestIdUUIDrequestId بدنهی همین تلاش. هر تلاش شناسهی خودش را دارد.
urlstringآدرسی که درخواست به آن فرستاده شده.
requestBodystringبدنهی JSONی که دقیقاً فرستاده شده، بهصورت رشته.
responseBodystringممکن است null باشدبدنهی پاسخ سرور شما. اگر پاسخی نیامده باشد خالی است.
statusintegerکد وضعیت HTTP که سرور شما برگردانده؛ یا -1 اگر سرور در دسترس نبوده یا در ۱۰ ثانیه پاسخ نداده است.
succeedbooleanآیا این تلاش تحویلشده حساب میشود: هر پاسخی بهجز وضعیت 4xx یا 5xx.
createdAtISO 8601 timestampزمان پایان تلاش.
{
"status": "SUCCEED",
"calls": [
{
"requestId": "560fc0fe-773f-46e4-8446-259ed7a9f6d0",
"url": "https://pixelshop.example/webhooks/swapwallet",
"requestBody": "{\"requestId\":\"560fc0fe-773f-46e4-8446-259ed7a9f6d0\",\"hmac\":\"f68377fb0576dbd1a37670acddf2ee1ce964ff312db26567af514f0a828708f9\",\"event\":{\"time\":\"2026-11-23T09:19:42.612394118Z\",\"type\":\"INVOICE\",\"invoice\":{\"id\":\"bcbb332e-0bf8-4da2-a42f-a75a0be6c36f\",\"supportCode\":\"AI-8LEYRQH-G8HM\",\"status\":\"PAID\",\"description\":\"Spotify Premium, 1 month\",\"customData\":\"{\\\"cartId\\\":\\\"c-88412\\\"}\",\"wallet\":null,\"ownerId\":905513,\"telegramInlineMessageId\":null,\"userLanguage\":\"FA\",\"returnUrl\":\"https://pixelshop.example/orders/1042\",\"webhookUrl\":\"https://pixelshop.example/webhooks/swapwallet\",\"orderId\":\"ORD-1042\",\"amount\":{\"number\":\"9.18\",\"unit\":\"USDT\"},\"value\":{\"number\":\"9.18\",\"unit\":\"USD\"},\"feePayer\":\"APPLICATION\",\"feeAmount\":{\"number\":\"0.0918\",\"unit\":\"USDT\"},\"paymentLinks\":[],\"paidAmount\":{\"number\":\"9.18\",\"unit\":\"USDT\"},\"paidAt\":\"2026-11-23T09:19:41.552904Z\",\"blockchainStatus\":\"CONFIRMED\",\"userId\":\"u-58213\",\"userEmail\":\"parsa@example.com\",\"userPhoneNumber\":\"+989123334455\",\"userTelegramId\":974181500,\"userDisplayName\":\"Parsa\",\"lockHours\":0,\"expiredAt\":\"2026-11-23T10:12:04.318227Z\",\"createdAt\":\"2026-11-23T09:12:04.318512Z\"}}}",
"responseBody": "Service Unavailable",
"status": 503,
"succeed": false,
"createdAt": "2026-11-23T09:19:42.731205Z"
},
{
"requestId": "a7d0cb53-b035-44b4-b48e-4b04a59d5f97",
"url": "https://pixelshop.example/webhooks/swapwallet",
"requestBody": "{\"requestId\":\"a7d0cb53-b035-44b4-b48e-4b04a59d5f97\",\"hmac\":\"e14c8f2ae561e80d64faffc2274c823c2b0aedc4bb9e32918fafe991f6d43bf6\",\"event\":{\"time\":\"2026-11-23T09:20:43.004871392Z\",\"type\":\"INVOICE\",\"invoice\":{\"id\":\"bcbb332e-0bf8-4da2-a42f-a75a0be6c36f\",\"supportCode\":\"AI-8LEYRQH-G8HM\",\"status\":\"PAID\",\"description\":\"Spotify Premium, 1 month\",\"customData\":\"{\\\"cartId\\\":\\\"c-88412\\\"}\",\"wallet\":null,\"ownerId\":905513,\"telegramInlineMessageId\":null,\"userLanguage\":\"FA\",\"returnUrl\":\"https://pixelshop.example/orders/1042\",\"webhookUrl\":\"https://pixelshop.example/webhooks/swapwallet\",\"orderId\":\"ORD-1042\",\"amount\":{\"number\":\"9.18\",\"unit\":\"USDT\"},\"value\":{\"number\":\"9.18\",\"unit\":\"USD\"},\"feePayer\":\"APPLICATION\",\"feeAmount\":{\"number\":\"0.0918\",\"unit\":\"USDT\"},\"paymentLinks\":[],\"paidAmount\":{\"number\":\"9.18\",\"unit\":\"USDT\"},\"paidAt\":\"2026-11-23T09:19:41.552904Z\",\"blockchainStatus\":\"CONFIRMED\",\"userId\":\"u-58213\",\"userEmail\":\"parsa@example.com\",\"userPhoneNumber\":\"+989123334455\",\"userTelegramId\":974181500,\"userDisplayName\":\"Parsa\",\"lockHours\":0,\"expiredAt\":\"2026-11-23T10:12:04.318227Z\",\"createdAt\":\"2026-11-23T09:12:04.318512Z\"}}}",
"responseBody": "{\"received\":true}",
"status": 200,
"succeed": true,
"createdAt": "2026-11-23T09:20:43.118940Z"
}
]
}/v1/merchants/invoices/{invoiceId}/webhookوضعیت وبهوک یک فاکتور و همهی تلاشهای ارسال آن را، از قدیمیترین، همراه با بدنهی فرستادهشده و پاسخ سرور شما برمیگرداند.
invoiceIdUUIDالزامیشناسهی فاکتور.
یک آبجکت تاریخچهی وبهوک برمیگرداند.
INVOICE_NOT_FOUNDکسبوکار شما فاکتوری با این شناسه ندارد.
curl https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook \
-H "Authorization: Bearer $SWAPWALLET_BUSINESS_KEY"const response = await fetch('https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.SWAPWALLET_BUSINESS_KEY}`,
},
});
const data = await response.json();
console.log(data.result);import os
import requests
response = requests.get(
"https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook",
headers={"Authorization": f"Bearer {os.environ['SWAPWALLET_BUSINESS_KEY']}"},
)
print(response.json()["result"])<?php
$ch = curl_init('https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWAPWALLET_BUSINESS_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
print_r($data['result']);package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("SWAPWALLET_BUSINESS_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(string(data))
}{
"status": "OK",
"result": {
"status": "SUCCEED",
"calls": [
{
"requestId": "560fc0fe-773f-46e4-8446-259ed7a9f6d0",
"url": "https://pixelshop.example/webhooks/swapwallet",
"requestBody": "{\"requestId\":\"560fc0fe-773f-46e4-8446-259ed7a9f6d0\",\"hmac\":\"f68377fb0576dbd1a37670acddf2ee1ce964ff312db26567af514f0a828708f9\",\"event\":{\"time\":\"2026-11-23T09:19:42.612394118Z\",\"type\":\"INVOICE\",\"invoice\":{\"id\":\"bcbb332e-0bf8-4da2-a42f-a75a0be6c36f\",\"supportCode\":\"AI-8LEYRQH-G8HM\",\"status\":\"PAID\",\"description\":\"Spotify Premium, 1 month\",\"customData\":\"{\\\"cartId\\\":\\\"c-88412\\\"}\",\"wallet\":null,\"ownerId\":905513,\"telegramInlineMessageId\":null,\"userLanguage\":\"FA\",\"returnUrl\":\"https://pixelshop.example/orders/1042\",\"webhookUrl\":\"https://pixelshop.example/webhooks/swapwallet\",\"orderId\":\"ORD-1042\",\"amount\":{\"number\":\"9.18\",\"unit\":\"USDT\"},\"value\":{\"number\":\"9.18\",\"unit\":\"USD\"},\"feePayer\":\"APPLICATION\",\"feeAmount\":{\"number\":\"0.0918\",\"unit\":\"USDT\"},\"paymentLinks\":[],\"paidAmount\":{\"number\":\"9.18\",\"unit\":\"USDT\"},\"paidAt\":\"2026-11-23T09:19:41.552904Z\",\"blockchainStatus\":\"CONFIRMED\",\"userId\":\"u-58213\",\"userEmail\":\"parsa@example.com\",\"userPhoneNumber\":\"+989123334455\",\"userTelegramId\":974181500,\"userDisplayName\":\"Parsa\",\"lockHours\":0,\"expiredAt\":\"2026-11-23T10:12:04.318227Z\",\"createdAt\":\"2026-11-23T09:12:04.318512Z\"}}}",
"responseBody": "Service Unavailable",
"status": 503,
"succeed": false,
"createdAt": "2026-11-23T09:19:42.731205Z"
},
{
"requestId": "a7d0cb53-b035-44b4-b48e-4b04a59d5f97",
"url": "https://pixelshop.example/webhooks/swapwallet",
"requestBody": "{\"requestId\":\"a7d0cb53-b035-44b4-b48e-4b04a59d5f97\",\"hmac\":\"e14c8f2ae561e80d64faffc2274c823c2b0aedc4bb9e32918fafe991f6d43bf6\",\"event\":{\"time\":\"2026-11-23T09:20:43.004871392Z\",\"type\":\"INVOICE\",\"invoice\":{\"id\":\"bcbb332e-0bf8-4da2-a42f-a75a0be6c36f\",\"supportCode\":\"AI-8LEYRQH-G8HM\",\"status\":\"PAID\",\"description\":\"Spotify Premium, 1 month\",\"customData\":\"{\\\"cartId\\\":\\\"c-88412\\\"}\",\"wallet\":null,\"ownerId\":905513,\"telegramInlineMessageId\":null,\"userLanguage\":\"FA\",\"returnUrl\":\"https://pixelshop.example/orders/1042\",\"webhookUrl\":\"https://pixelshop.example/webhooks/swapwallet\",\"orderId\":\"ORD-1042\",\"amount\":{\"number\":\"9.18\",\"unit\":\"USDT\"},\"value\":{\"number\":\"9.18\",\"unit\":\"USD\"},\"feePayer\":\"APPLICATION\",\"feeAmount\":{\"number\":\"0.0918\",\"unit\":\"USDT\"},\"paymentLinks\":[],\"paidAmount\":{\"number\":\"9.18\",\"unit\":\"USDT\"},\"paidAt\":\"2026-11-23T09:19:41.552904Z\",\"blockchainStatus\":\"CONFIRMED\",\"userId\":\"u-58213\",\"userEmail\":\"parsa@example.com\",\"userPhoneNumber\":\"+989123334455\",\"userTelegramId\":974181500,\"userDisplayName\":\"Parsa\",\"lockHours\":0,\"expiredAt\":\"2026-11-23T10:12:04.318227Z\",\"createdAt\":\"2026-11-23T09:12:04.318512Z\"}}}",
"responseBody": "{\"received\":true}",
"status": 200,
"succeed": true,
"createdAt": "2026-11-23T09:20:43.118940Z"
}
]
}
}/v1/merchants/invoices/{invoiceId}/webhook/retryارسال تازهای از وبهوک invoice-paid فاکتور را در صف میگذارد که وضعیت فعلی فاکتور را میبرد. برای هر فاکتور پرداختشده، از جمله تسویهشدهها، کار میکند؛ چه ارسال قبلی موفق بوده باشد چه نه.
اگر این ارسال هم ناموفق باشد، طبق همان برنامهی همیشگی تکرار میشود. نتیجه را با دریافت تاریخچهی وبهوک ببینید.
invoiceIdUUIDالزامیشناسهی فاکتور.
پس از قرار گرفتن ارسال در صف، {"status": "OK"} برمیگرداند.
APPLICATION_INVOICE_WEBHOOK_RETRY_NOT_ALLOWEDفاکتور پرداخت نشده است.
INVOICE_NOT_FOUNDکسبوکار شما فاکتوری با این شناسه ندارد.
curl -X POST https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook/retry \
-H "Authorization: Bearer $SWAPWALLET_BUSINESS_KEY"const response = await fetch('https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook/retry', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SWAPWALLET_BUSINESS_KEY}`,
},
});
const data = await response.json();
console.log(data.result);import os
import requests
response = requests.post(
"https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook/retry",
headers={"Authorization": f"Bearer {os.environ['SWAPWALLET_BUSINESS_KEY']}"},
)
print(response.json()["result"])<?php
$ch = curl_init('https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook/retry');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWAPWALLET_BUSINESS_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
print_r($data['result']);package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("POST", "https://swapwallet.app/api/v1/merchants/invoices/bcbb332e-0bf8-4da2-a42f-a75a0be6c36f/webhook/retry", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("SWAPWALLET_BUSINESS_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(string(data))
}{
"status": "OK"
}