ArgusDocs
English Türkçe

Webhooks

On this page

Receive events on your server, check that they come from us and handle retries.

Webhooks tell your server when a payment succeeds, a refund finishes or a payout is paid. They reach you even when the customer never comes back from the bank's page, so use them to update your orders.

1. Create an endpoint

Create an endpoint on the Webhooks page in the Developers menu, or with the API. The URL must be a public address on a registered website or callback URL. On live it must use https. The sandbox also accepts http. In both, the host cannot be localhost or an address on a private network, and the URL cannot hold a user name, a password or a # fragment.

Save the request as endpoint.json:

{
  "url": "https://modakitabevi.com.tr/webhooks/odeme",
  "enabled_events": ["payment_intent.succeeded", "payment_intent.payment_failed", "refund.succeeded", "refund.failed"],
  "description": "Sipariş sistemi"
}
curl -X POST https://api.pf.organizer.tr/v1/webhook_endpoints \
  -H "Authorization: Bearer sk_sandbox_YOUR_KEY" \
  -H "Idempotency-Key: webhook-endpoint-orders" \
  -H "Content-Type: application/json" \
  -d @endpoint.json
{
  "id": "we_01J9ZQC8D0F2H4K6M8P1R3T5V7",
  "object": "webhook_endpoint",
  "url": "https://modakitabevi.com.tr/webhooks/odeme",
  "enabled_events": ["payment_intent.succeeded", "payment_intent.payment_failed", "refund.succeeded", "refund.failed"],
  "status": "enabled",
  "description": "Sipariş sistemi",
  "secret": "REPLACE_WITH_THE_SECRET_FROM_THE_RESPONSE",
  "created": 1790000000,
  "metadata": {}
}

Store the secret on your server. You see it only in this response. To receive every event type, send ["*"] in enabled_events.

If a secret leaks or you lose it, replace it with POST /v1/webhook_endpoints/{id}/roll_secret. The old secret stops working at once. To keep both secrets signing while you deploy the new one, send expires_in_seconds (at most 604800, which is 7 days). The new secret is shown only in that response.

2. Receive events

Each delivery is a POST with the event as JSON:

{
  "id": "evt_01J9ZQ4V8K2M3N5P7R9T1W3Y5E",
  "object": "event",
  "type": "payment_intent.succeeded",
  "created": 1795167021,
  "merchant_id": "mer_01J9ZQ4V8K2M3N5P7R9T1W3Y5A",
  "api_version": "2026-10-01",
  "livemode": false,
  "aggregate_type": "payment_intent",
  "aggregate_id": "pi_01J9ZQ4V8K2M3N5P7R9T1W3Y5A",
  "sequence": 3,
  "request_id": "req_01J9ZQ4V8K2M3N5P7R9T1W3Y5F",
  "correlation_id": "req_01J9ZQ4V8K2M3N5P7R9T1W3Y5F",
  "data": {
    "object": {
      "id": "pi_01J9ZQ4V8K2M3N5P7R9T1W3Y5A",
      "object": "payment_intent",
      "amount": 12500,
      "currency": "try",
      "status": "succeeded",
      "capture_method": "automatic",
      "metadata": {"order_id": "SIP-2026-10423"},
      "created": 1795167000,
      "livemode": false
    },
    "previous_attributes": {"status": "requires_action"},
    "captured_at": 1795167020
  }
}

3. Verify the signature

Every delivery has this header:

Argus-Signature: t=1795167022,v1=<hex>

t is the Unix time of the delivery. v1 is the signature, 64 hex characters. It is the HMAC-SHA256 of t + "." + raw body, keyed with your endpoint secret. Use the whole secret as the key, whsec_ included. To verify a delivery:

  1. Take the raw request body exactly as it arrived, before you parse the JSON.
  2. Read t and every v1 from the header. While you roll a secret, the header can hold two v1 values.
  3. Reject the delivery if t is more than 5 minutes away from your clock.
  4. Compute the HMAC and compare it with each v1 in constant time.
<?php
function verifyArgusSignature(string $payload, string $header, string $secret, int $tolerance = 300): bool
{
    $t = null;
    $signatures = [];
    foreach (explode(',', $header) as $part) {
        [$key, $value] = array_pad(explode('=', trim($part), 2), 2, '');
        if ($key === 't') {
            $t = $value;
        } elseif ($key === 'v1') {
            $signatures[] = $value;
        }
    }
    if ($t === null || !ctype_digit($t) || abs(time() - (int) $t) > $tolerance) {
        return false;
    }
    $expected = hash_hmac('sha256', $t . '.' . $payload, $secret);
    foreach ($signatures as $signature) {
        if (hash_equals($expected, $signature)) {
            return true;
        }
    }
    return false;
}

$payload = file_get_contents('php://input');
$header = $_SERVER['HTTP_ARGUS_SIGNATURE'] ?? '';
if (!verifyArgusSignature($payload, $header, getenv('ARGUS_WEBHOOK_SECRET'))) {
    http_response_code(400);
    exit;
}
$event = json_decode($payload, true);
// Store the event, then answer quickly.
http_response_code(200);
import { createHmac, timingSafeEqual } from 'node:crypto';
import express from 'express';

export function verifyArgusSignature(rawBody, header, secret, toleranceSeconds = 300) {
  let t = null;
  const signatures = [];
  for (const part of String(header ?? '').split(',')) {
    const [key, value = ''] = part.trim().split('=');
    if (key === 't') t = value;
    if (key === 'v1') signatures.push(value);
  }
  if (t === null || !/^\d+$/.test(t)) return false;
  if (Math.abs(Date.now() / 1000 - Number(t)) > toleranceSeconds) return false;
  const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest();
  return signatures.some((sig) => {
    const given = Buffer.from(sig, 'hex');
    return given.length === expected.length && timingSafeEqual(given, expected);
  });
}

const app = express();
app.post('/webhooks/odeme', express.raw({ type: 'application/json' }), (req, res) => {
  const raw = req.body.toString('utf8');
  if (!verifyArgusSignature(raw, req.get('Argus-Signature'), process.env.ARGUS_WEBHOOK_SECRET)) return res.sendStatus(400);
  const event = JSON.parse(raw);
  // Store the event, then answer quickly.
  res.sendStatus(200);
});
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;

public static class ArgusWebhook
{
    public static bool Verify(string payload, string header, string secret, int toleranceSeconds = 300)
    {
        string? t = null;
        var signatures = new List<string>();
        foreach (var part in (header ?? "").Split(','))
        {
            var kv = part.Trim().Split('=', 2);
            if (kv.Length != 2) continue;
            if (kv[0] == "t") t = kv[1];
            else if (kv[0] == "v1") signatures.Add(kv[1]);
        }
        if (t == null || !long.TryParse(t, out var ts)) return false;
        if (Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - ts) > toleranceSeconds) return false;

        using var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secret));
        var expected = hmac.ComputeHash(Encoding.UTF8.GetBytes(t + "." + payload));
        foreach (var sig in signatures)
        {
            byte[] given;
            try { given = Convert.FromHexString(sig); } catch (FormatException) { continue; }
            if (CryptographicOperations.FixedTimeEquals(given, expected)) return true;
        }
        return false;
    }
}

// ASP.NET Core minimal API:
// app.MapPost("/webhooks/odeme", async (HttpRequest req) => {
//     using var reader = new StreamReader(req.Body);
//     var payload = await reader.ReadToEndAsync();
//     if (!ArgusWebhook.Verify(payload, req.Headers["Argus-Signature"].ToString(), secret)) return Results.BadRequest();
//     return Results.Ok();
// });
package webhook

import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/hex"
	"math"
	"strconv"
	"strings"
	"time"
)

// Verify checks an Argus-Signature header against the raw request body.
func Verify(payload []byte, header, secret string, tolerance time.Duration, now time.Time) bool {
	var t string
	var signatures []string
	for _, part := range strings.Split(header, ",") {
		key, value, _ := strings.Cut(strings.TrimSpace(part), "=")
		switch key {
		case "t":
			t = value
		case "v1":
			signatures = append(signatures, value)
		}
	}
	ts, err := strconv.ParseInt(t, 10, 64)
	if err != nil || math.Abs(float64(now.Unix()-ts)) > tolerance.Seconds() {
		return false
	}
	mac := hmac.New(sha256.New, []byte(secret))
	mac.Write([]byte(t + "."))
	mac.Write(payload)
	expected := mac.Sum(nil)
	for _, sig := range signatures {
		given, err := hex.DecodeString(sig)
		if err == nil && hmac.Equal(given, expected) {
			return true
		}
	}
	return false
}
import hashlib
import hmac
import time


def verify_argus_signature(payload: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
    t = None
    signatures = []
    for part in (header or "").split(","):
        key, _, value = part.strip().partition("=")
        if key == "t":
            t = value
        elif key == "v1":
            signatures.append(value)
    if t is None or not t.isdigit() or abs(time.time() - int(t)) > tolerance:
        return False
    expected = hmac.new(secret.encode(), t.encode() + b"." + payload, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(expected, sig) for sig in signatures)


# Flask: verify_argus_signature(request.get_data(), request.headers.get("Argus-Signature", ""), SECRET)

4. Respond quickly and handle duplicates

5. Recover from failed deliveries

We retry a delivery that times out or gets an answer other than 2xx. The waits between attempts are 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours, then 24 hours three times. That makes 9 retries. The last one comes 92 hours 36 minutes (about 3.9 days) after the first attempt.

If the last retry fails too, the endpoint is marked failing. Its other deliveries wait until you turn it on again. The delivery that used up its retries is not sent again by itself.

To recover:

  1. Fix your endpoint.
  2. Turn it on again with POST /v1/webhook_endpoints/{id} and {"disabled": false}:
curl -X POST https://api.pf.organizer.tr/v1/webhook_endpoints/we_01J9ZQC8D0F2H4K6M8P1R3T5V7 \
  -H "Authorization: Bearer sk_sandbox_YOUR_KEY" \
  -H "Idempotency-Key: webhook-endpoint-enable-1" \
  -H "Content-Type: application/json" \
  -d '{"disabled": false}'
  1. Resend the events whose delivery failed. Without a body, the event goes to every endpoint that receives its type. To send it to one endpoint only, send {"endpoint_id": "we_…"}.
curl -X POST https://api.pf.organizer.tr/v1/events/evt_01J9ZQ4V8K2M3N5P7R9T1W3Y5E/resend \
  -H "Authorization: Bearer sk_sandbox_YOUR_KEY" \
  -H "Idempotency-Key: resend-evt-01J9ZQ4V8K2M3N5P7R9T1W3Y5E-1"

To find the events you missed, use GET /v1/events. You can filter it by type, object_id or created.

You can see every attempt, with its status code and response time, on the Webhooks page in the Developers menu. The API returns them from GET /v1/webhook_endpoints/{id}/deliveries.

Event types

Event When data.object
payment_intent.created A payment was created. PaymentIntent
payment_intent.requires_action The customer must complete 3D Secure. PaymentIntent
payment_intent.processing The payment waits for the bank's answer. PaymentIntent
payment_intent.amount_capturable_updated An authorization succeeded and can be captured. PaymentIntent
payment_intent.succeeded The payment succeeded. Fulfil the order. PaymentIntent
payment_intent.payment_failed An attempt was declined or failed. PaymentIntent
payment_intent.canceled The payment was canceled or its authorization expired. PaymentIntent
payment_intent.fraud_updated The fraud screening result changed. PaymentIntent
refund.created A refund was created. Refund
refund.updated A refund changed (for example it was sent to the bank). Refund
refund.succeeded A refund succeeded. Refund
refund.failed A refund failed. Refund
dispute.created A chargeback was opened. Dispute
dispute.updated A chargeback changed. Dispute
dispute.closed A chargeback was closed (won or lost). Dispute
payout.created A payout was created. Payout
payout.paid A payout reached your bank account. Payout
payout.failed A payout failed or was rejected; the money is back in your balance. Payout
topup.succeeded A top-up arrived. Topup
balance.available Funds became available. Balance
balance.negative_limit_exceeded Your balance is below its allowed negative limit; payouts pause until you top up. Balance
merchant.updated Your merchant account changed. Merchant
topup.updated A top-up changed. Topup
customer.created A customer was created. Customer
customer.updated A customer was updated. Customer
customer.deleted A customer was deleted. Customer
payment_link.created A payment link was created. PaymentLink
payment_link.updated A payment link changed: you edited it, or a reusable link took a payment. PaymentLink
payment_link.paid A payment link was paid: a single-use link took its payment, or a reusable one its last. PaymentLink
payment_link.expired A payment link passed its expiry without being paid. PaymentLink
payment_link.deactivated A payment link was deactivated. PaymentLink
payment_link.sent A payment link was sent to a customer by SMS or e-mail. PaymentLink
early_settlement.created An early settlement was made: pending balance was brought forward to your available balance for a fee. EarlySettlement
wallet_transfer.completed Settlement money moved from your balance to your business wallet. WalletTransfer
wallet_transfer.failed The transfer failed or was rejected; no money moved to the wallet. WalletTransfer

Test your handler

In the API reference

Next: Handle failures safely with Errors and retries, then work through Going live.