# Transaktionen & Status

Finden Sie eine Bestellung und prüfen Sie ihren Status serverseitig.

## Bestellung suchen

GET`/transactions.php?order_id=ORDER-DEMO-001`

Terminal
```
curl "https://circus-pay.com/api/transactions.php?order_id=ORDER-DEMO-001" \
  -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY"
```

JavaScript
```
const response = await fetch("https://circus-pay.com/api/transactions.php?order_id=ORDER-DEMO-001", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.CIRCUSPAY_SECRET_KEY}`
  }
});
const result = await response.json();
if (!response.ok || !result.success) {
  throw new Error(result.error || "API request failed");
}
console.log(result);
```

PHP
```
<?php
$ch = curl_init("https://circus-pay.com/api/transactions.php?order_id=ORDER-DEMO-001");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 20,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("CIRCUSPAY_SECRET_KEY"),
    "Content-Type: application/json",
  ],
]);
$raw = curl_exec($ch);
if ($raw === false) { throw new RuntimeException(curl_error($ch)); }
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400 || empty($result["success"])) {
  throw new RuntimeException($result["error"] ?? "API request failed");
}
```

Python
```
import os, requests

response = requests.get(
    "https://circus-pay.com/api/transactions.php?order_id=ORDER-DEMO-001",
    headers={"Authorization": "Bearer " + os.environ["CIRCUSPAY_SECRET_KEY"]},
    timeout=20,
)
response.raise_for_status()
result = response.json()
if not result.get("success"):
    raise RuntimeError(result.get("error", "API request failed"))
print(result)
```

Beispiel · keine abgeschlossene Transaktion
```
{
  "success": true,
  "orderId": "ORDER-DEMO-001",
  "status": "pending",
  "paid": false,
  "url": null
}
```

## Ergebnis auswerten

Existiert eine Transaktion, enthält die Antwort `transaction` mit unter anderem `id`, `order_id`, `amount`, `currency` und `status`. Bei dieser Suche ist `paid` wahr, wenn der Status `success` lautet.

| Parameter | Beschreibung | 
| --- | --- |

| `success` | Zahlung erfolgreich. Prüfen Sie auch Referenz, Betrag und Währung. | 
| `pending` | Zahlung nicht abgeschlossen. Keine Auslieferung auslösen. | 
| `failed` | Versuch fehlgeschlagen. | 
| `refunded` | Zahlung erstattet. | 

## Weitere Abfragen

Endpunkte
```
GET /transactions.php?id=123
GET /transactions.php
```

Die Suche per ID liefert `transaction`. Die Liste liefert `transactions`, begrenzt auf die neuesten 200 Einträge. Das Format hängt von der Abfrage ab.
