update-webhook-endpoint
POST /api/{team}/gateway/update-webhook-endpoint/{token}
Adresin URL'ini, olaylarını ya da açık/kapalı durumunu değiştirir; yalnızca gönderilen alanlar değişir. Kapalı adrese bildirim gönderilmez; kapatılmadan önce sıraya girmiş bildirimler de gitmez.
Yalnızca iş ortağının açtığı çalışma alanlarında çalışır; diğerleri 403 alır. Bkz. İş Ortakları.
Kimlik doğrulama
Çalışma alanının anahtarıyla: X-Api-Key, X-Timestamp, X-Signature, Content-Type: application/json. Ayrıntılar: Kimlik Doğrulama ve İmza.
İstek
{
"token": "3e7a1c9b-5d2f-4a8e-9c6b-0f1e2d3c4b5a",
"webhook_endpoint": {
"events": ["order.paid", "order.payment_refunded", "order.payment_cancelled"],
"is_active": false
}
}
| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
token | string | evet | Adresin token'ı. Adresteki token'la aynı olmalıdır. |
webhook_endpoint | object | evet | Değişecek alanlar. |
webhook_endpoint.url | string | hayır | Yeni adres; kurallar create-webhook-endpoint ile aynı. |
webhook_endpoint.events | array | hayır | Olayların yeni listesi; gönderilirse öncekinin yerini alır, en az biri. |
webhook_endpoint.is_active | boolean | hayır | false adresi kapatır, true açar. |
SDK örnekleri
not
Örneklerdeki $client / client nesnesinin kurulumu: İstemciyi Kurmak.
- PHP
- Node.js
- Python
- Java
- cURL
use Gurmehub\Odemehub\Request\UpdateWebhookEndpoint;
$webhookEndpoint = $client->updateWebhookEndpoint(new UpdateWebhookEndpoint(
token: $webhookEndpointToken,
isActive: false,
))->webhookEndpoint;
$webhookEndpoint->isActive; // false
const { webhookEndpoint } = await client.updateWebhookEndpoint({
token: webhookEndpointToken,
isActive: false,
});
webhookEndpoint.isActive; // false
from odemehub.request import UpdateWebhookEndpoint
webhook_endpoint = client.update_webhook_endpoint(UpdateWebhookEndpoint(
token=webhook_endpoint_token,
is_active=False,
)).webhook_endpoint
webhook_endpoint.is_active # False
import com.odemehub.request.UpdateWebhookEndpoint;
var webhookEndpoint = client.updateWebhookEndpoint(UpdateWebhookEndpoint.builder(webhookEndpointToken)
.isActive(false)
.build()).getWebhookEndpoint();
webhookEndpoint.isActive(); // false
URI_PATH="/api/$ODEMEHUB_TEAM/gateway/update-webhook-endpoint/3e7a1c9b-5d2f-4a8e-9c6b-0f1e2d3c4b5a"
BODY='{"token":"3e7a1c9b-5d2f-4a8e-9c6b-0f1e2d3c4b5a","webhook_endpoint":{"is_active":false}}'
TIMESTAMP=$(date +%s)
SIGNATURE=$(printf '%s\n%s\n%s\n%s' "$TIMESTAMP" "POST" "$URI_PATH" "$BODY" | openssl dgst -sha256 -hmac "$ODEMEHUB_API_SECRET" | sed 's/^.* //')
curl -X POST "https://sandbox.odemehub.com$URI_PATH" \
-H "Content-Type: application/json" \
-H "X-Api-Key: $ODEMEHUB_API_KEY" \
-H "X-Timestamp: $TIMESTAMP" \
-H "X-Signature: $SIGNATURE" \
--data-raw "$BODY"
Yanıt
result ve adresin güncel hâli (webhook_endpoint): Webhook adresi nesnesi.
HTTP durum kodları
| Kod | Durum |
|---|---|
200 | Adres güncellendi. |
401 | API anahtarı ya da imza geçersiz. |
403 | Çalışma alanı işlem yapamıyor ya da bir iş ortağının açtığı çalışma alanı değil: Bu uç yalnızca iş ortağı çalışma alanlarına açıktır. |
404 | Bu webhook adresi bulunamadı. |
422 | Doğrulama hatası. |
429 | İstek sınırı aşıldı. |
Hatalar
| Alan | Mesaj |
|---|---|
token | Gövdedeki token adresteki token ile aynı olmalı. |
webhook_endpoint.events | En az bir olay seçin. |
webhook_endpoint.events.* | Bu olay çalışma alanınızda kullanılamıyor. |
webhook_endpoint.url | Bu adres zaten ekli; olayları onun üzerinden seçin. |