# CircusPay API — English # Documentation Create a checkout, keep your identity and receive server-side confirmation. Everything you need to connect your business to CircusPay. CIRCUSPAY DEVELOPERS # Payments. Simply integrated. Create a checkout, keep your identity and receive server-side confirmation. Everything you need to connect your business to CircusPay. [Start integrating ↗](https://circus-pay.com/docs/en/quickstart/)[API reference →](https://circus-pay.com/docs/en/create-payment/) 01 · Create→02 · Collect→03 · Confirm [↗ ### Your first checkout One server request. A payment URL ready to share. **Getting started guide →**](https://circus-pay.com/docs/en/quickstart/)[⌁ ### Stay in sync Receive events and verify your webhook signatures. **Configure notifications →**](https://circus-pay.com/docs/en/webhooks/)[▤ ### The right methods Cards, local methods and crypto: tailor each checkout. **Explore methods →**](https://circus-pay.com/docs/en/payment-methods/)[◈ ### Your design, through the API Apply your Checkout Studio themes with a simple identifier. **Customize checkout →**](https://circus-pay.com/docs/en/themes/) ## One API, one starting point Base URL ``` https://circus-pay.com/api ``` **Keep in mind** This documentation is public. Only API calls and account management require authentication. --- # Your first payment Create a payment link and connect your order confirmation. ## 1. Prepare a test key Create a test key in your merchant portal. Store it on your server in `CIRCUSPAY_SECRET_KEY`. Never embed your secret key in a web page or mobile application. ## 2. Create the checkout POST`/checkout/create.php` Terminal ``` curl "https://circus-pay.com/api/checkout/create.php" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" \ -H "Content-Type: application/json" \ --data '{ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel", "testMode": true }' ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/checkout/create.php", { method: "POST", headers: { Authorization: `Bearer ${process.env.CIRCUSPAY_SECRET_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel", "testMode": true }) }); const result = await response.json(); if (!response.ok || !result.success) { throw new Error(result.error || "API request failed"); } console.log(result); ``` PHP ``` true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("CIRCUSPAY_SECRET_KEY"), "Content-Type: application/json", ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => '{ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel", "testMode": true }', ]); $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.post( "https://circus-pay.com/api/checkout/create.php", headers={"Authorization": "Bearer " + os.environ["CIRCUSPAY_SECRET_KEY"]}, json={'amount': 2499, 'currency': 'EUR', 'productName': 'Ma commande', 'orderId': 'ORDER-DEMO-001', 'successUrl': 'https://example.com/payment/return', 'cancelUrl': 'https://example.com/payment/cancel', 'testMode': True}, timeout=20, ) response.raise_for_status() result = response.json() if not result.get("success"): raise RuntimeError(result.get("error", "API request failed")) print(result) ``` **Keep in mind** Amounts use minor units: `2499` means **EUR 24.99**. Use a unique `orderId` for each new order. ## 3. Redirect the customer Read `url` from the JSON response and redirect the browser to that exact URL. The domain may vary with your account configuration: do not reconstruct it. Illustrative response excerpt ``` { "success": true, "token": "pay_EXAMPLE", "url": "https://circus-pay.com/sandbox/pay_EXAMPLE", "orderId": "ORDER-DEMO-001", "test": true, "mode": "test" } ``` ## 4. Confirm server-side Configure a [signed webhook](https://circus-pay.com/docs/en/webhooks/) and verify the order, amount, currency and status. A visit to your return URL is not proof of payment. ## 5. Go live After testing, use a production key and remove `testMode: true`. Confirm that the required methods and currencies are enabled for your account. --- # Authentication HTTPS requests, a secret key and JSON responses. ## Authenticate requests Send your secret key in the `Authorization: Bearer` header. Existing `sk_test_oni_…` and `sk_live_oni_…` keys remain compatible. Headers ``` Authorization: Bearer YOUR_SECRET_KEY Content-Type: application/json ``` ## Keep keys server-side Use an environment variable or your secrets manager. These examples read `CIRCUSPAY_SECRET_KEY`; no key is entered or transmitted through this documentation. ## Respect permissions Sensitive operations, including payouts and key management, may require a portal session. A `403` response with `session_required` means an API key is insufficient. ## Compatibility **Keep in mind** The recommended base is `https://circus-pay.com/api`. Existing integration paths remain unchanged. This documentation introduces no mandatory migration. --- # Create a checkout Generate a hosted payment page for an order. POST`/checkout/create.php` Terminal ``` curl "https://circus-pay.com/api/checkout/create.php" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" \ -H "Content-Type: application/json" \ --data '{ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel" }' ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/checkout/create.php", { method: "POST", headers: { Authorization: `Bearer ${process.env.CIRCUSPAY_SECRET_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel" }) }); const result = await response.json(); if (!response.ok || !result.success) { throw new Error(result.error || "API request failed"); } console.log(result); ``` PHP ``` true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("CIRCUSPAY_SECRET_KEY"), "Content-Type: application/json", ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => '{ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel" }', ]); $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.post( "https://circus-pay.com/api/checkout/create.php", headers={"Authorization": "Bearer " + os.environ["CIRCUSPAY_SECRET_KEY"]}, json={'amount': 2499, 'currency': 'EUR', 'productName': 'Ma commande', 'orderId': 'ORDER-DEMO-001', 'successUrl': 'https://example.com/payment/return', 'cancelUrl': 'https://example.com/payment/cancel'}, timeout=20, ) response.raise_for_status() result = response.json() if not result.get("success"): raise RuntimeError(result.get("error", "API request failed")) print(result) ``` ## Parameters | Parameter | Description | | --- | --- | | `amount · integer · required` | Positive amount in minor units. Example: `15000` for PLN 150. | | `currency · string` | Currency, default `EUR`. Availability depends on the account and configured processing. | | `orderId · string` | Your order reference. Reusing it may return the existing link; do not use it for a new order. | | `productName · string` | Label shown to the customer. | | `customerEmail / customerName` | Optional details to prefill the checkout. | | `paymentMethods · string[]` | Restricts offered methods. Does not enable a method unavailable to your account. | | `theme_id · string` | ID of an active theme belonging to your account. See Checkout Studio. | | `successUrl / cancelUrl` | Return addresses for your store. Payment confirmation happens server-side. | | `testMode · boolean` | Enables the test flow. A test key also forces this mode. | ## Response Illustrative excerpt · fictional domain ``` { "success": true, "token": "pay_EXAMPLE", "url": "https://checkout.example.com/checkout/pay_EXAMPLE", "orderId": "ORDER-DEMO-001", "test": false, "mode": "live" } ``` The response may also include `fallbackUrl`, `routing`, `ghostSite` and `theme_id`. Use `url` as the destination and retain your order reference. ## Retry without duplicating For a non-reusable link and an existing reference, the API may return `reused: true` and `alreadyPaid`. Check these fields and the status before restarting payment. This is not a general idempotency guarantee across all endpoints. --- # Payment methods Offer methods compatible with your account, currency and checkout. ## Read account configuration GET`/payment-methods.php` Terminal ``` curl "https://circus-pay.com/api/payment-methods.php" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/payment-methods.php", { 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 ``` 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/payment-methods.php", 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) ``` The response includes `methods`. For each entry, inspect `id`, `enabled`, `available`, `currencies` and `unavailableReason`. Final availability also depends on the selected processing flow. ## Restrict a checkout JSON ``` { "paymentMethods": ["card", "blik"] } ``` **Keep in mind** This list restricts authorized methods; it does not enable them. An empty list or one containing only unknown values does not disable all payments: creation ignores that restriction. ## BLIK-only example POST`/checkout/create.php` Terminal ``` curl "https://circus-pay.com/api/checkout/create.php" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" \ -H "Content-Type: application/json" \ --data '{ "amount": 15000, "currency": "PLN", "productName": "Commande BLIK", "orderId": "BLIK-DEMO-001", "paymentMethods": [ "blik" ] }' ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/checkout/create.php", { method: "POST", headers: { Authorization: `Bearer ${process.env.CIRCUSPAY_SECRET_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "amount": 15000, "currency": "PLN", "productName": "Commande BLIK", "orderId": "BLIK-DEMO-001", "paymentMethods": [ "blik" ] }) }); const result = await response.json(); if (!response.ok || !result.success) { throw new Error(result.error || "API request failed"); } console.log(result); ``` PHP ``` true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("CIRCUSPAY_SECRET_KEY"), "Content-Type: application/json", ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => '{ "amount": 15000, "currency": "PLN", "productName": "Commande BLIK", "orderId": "BLIK-DEMO-001", "paymentMethods": [ "blik" ] }', ]); $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.post( "https://circus-pay.com/api/checkout/create.php", headers={"Authorization": "Bearer " + os.environ["CIRCUSPAY_SECRET_KEY"]}, json={'amount': 15000, 'currency': 'PLN', 'productName': 'Commande BLIK', 'orderId': 'BLIK-DEMO-001', 'paymentMethods': ['blik']}, timeout=20, ) response.raise_for_status() result = response.json() if not result.get("success"): raise RuntimeError(result.get("error", "API request failed")) print(result) ``` The account must allow BLIK and the selected flow must support PLN. To add cards, use `["blik", "card"]`. ## Catalog identifiers | Parameter | Description | | --- | --- | | `card / applepay / googlepay` | Cards and wallets. Compatibility depends on your configuration and the customer's device. | | `blik` | PLN | | `p24` | PLN, EUR | | `ideal / bancontact / eps` | EUR | | `twint` | CHF | | `multibanco / mb_way / satispay` | EUR | | `klarna` | Depends on currencies and account activation. | | `sepa` | EUR · incoming bank transfer; not a SEPA direct debit. | | `ach` | USD · incoming bank transfer. | | `crypto` | Availability, assets and networks depend on your account. | ## Redirect payments Let the checkout handle redirecting to the bank or provider and the return. Your store then receives server confirmation; an URL parameter or browser return must not be treated as proof of success. --- # Checkout Studio & themes Keep your visual identity in every API-created link. ## Use a saved theme Create and activate your theme in Checkout Studio. Copy its identifier and send it as `theme_id` when creating the checkout. POST`/checkout/create.php` Terminal ``` curl "https://circus-pay.com/api/checkout/create.php" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" \ -H "Content-Type: application/json" \ --data '{ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel", "theme_id": "ma-boutique" }' ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/checkout/create.php", { method: "POST", headers: { Authorization: `Bearer ${process.env.CIRCUSPAY_SECRET_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel", "theme_id": "ma-boutique" }) }); const result = await response.json(); if (!response.ok || !result.success) { throw new Error(result.error || "API request failed"); } console.log(result); ``` PHP ``` true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("CIRCUSPAY_SECRET_KEY"), "Content-Type: application/json", ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => '{ "amount": 2499, "currency": "EUR", "productName": "Ma commande", "orderId": "ORDER-DEMO-001", "successUrl": "https://example.com/payment/return", "cancelUrl": "https://example.com/payment/cancel", "theme_id": "ma-boutique" }', ]); $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.post( "https://circus-pay.com/api/checkout/create.php", headers={"Authorization": "Bearer " + os.environ["CIRCUSPAY_SECRET_KEY"]}, json={'amount': 2499, 'currency': 'EUR', 'productName': 'Ma commande', 'orderId': 'ORDER-DEMO-001', 'successUrl': 'https://example.com/payment/return', 'cancelUrl': 'https://example.com/payment/cancel', 'theme_id': 'ma-boutique'}, timeout=20, ) response.raise_for_status() result = response.json() if not result.get("success"): raise RuntimeError(result.get("error", "API request failed")) print(result) ``` ## A design preserved for the link The API checks that the theme is active and belongs to your account. Its configuration is stored with the link. Branding enforced for your account may take precedence. ## Format and errors | Parameter | Description | | --- | --- | | `theme_id` | 1 to 40 characters: lowercase letters, digits and hyphens. | | `invalid_theme_id` | Malformed identifier. | | `theme_not_found` | Theme missing, inactive or inaccessible to this account. | | `conflicting_theme_id` | The supplied theme_id, themeId or template parameters conflict. | | `theme_unavailable` | The theme cannot be loaded or stored for the link. | **Keep in mind** Without `theme_id`, your integration retains its usual behavior. The legacy `template` parameter keeps its compatibility handling; prefer `theme_id` for a saved theme. --- # Transactions & statuses Find an order and check its status server-side. ## Look up an order 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 ``` 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) ``` Example · no finalized transaction ``` { "success": true, "orderId": "ORDER-DEMO-001", "status": "pending", "paid": false, "url": null } ``` ## Interpret the result When a transaction exists, the response contains `transaction`, including `id`, `order_id`, `amount`, `currency` and `status`. For this lookup, `paid` is true when the status is `success`. | Parameter | Description | | --- | --- | | `success` | Payment succeeded. Also verify the reference, amount and currency. | | `pending` | Payment not finalized. Do not trigger fulfilment. | | `failed` | Attempt failed. | | `refunded` | Payment refunded. | ## Other queries Endpoints ``` GET /transactions.php?id=123 GET /transactions.php ``` Lookup by ID returns `transaction`. Listing returns `transactions`, limited to the latest 200 entries. The format varies with the query used. --- # Payment links Find links created by your integration. ## List API links GET`/payment-links.php?source=api` Terminal ``` curl "https://circus-pay.com/api/payment-links.php?source=api" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/payment-links.php?source=api", { 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 ``` 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/payment-links.php?source=api", 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) ``` ## Select a source | Parameter | Description | | --- | --- | | `source=api` | Links created by an integration. | | `source=dashboard` | Links created in the portal. Default value. | | `source=all` | All sources. | **Keep in mind** Missing links in the default list do not mean creation failed. For an integration, explicitly request `source=api` or `source=all`. ## Create a link Use [POST /checkout/create.php](https://circus-pay.com/docs/en/create-payment/). Store `orderId` and `url` in your system to connect the order to the checkout. --- # Webhooks Receive payment events directly on your server. ## Create a destination POST`/webhooks.php` Terminal ``` curl "https://circus-pay.com/api/webhooks.php" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" \ -H "Content-Type: application/json" \ --data '{ "url": "https://example.com/webhooks/circuspay", "events": [ "payment.succeeded", "payment.failed", "payment.refunded" ], "description": "Boutique principale" }' ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/webhooks.php", { method: "POST", headers: { Authorization: `Bearer ${process.env.CIRCUSPAY_SECRET_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "url": "https://example.com/webhooks/circuspay", "events": [ "payment.succeeded", "payment.failed", "payment.refunded" ], "description": "Boutique principale" }) }); const result = await response.json(); if (!response.ok || !result.success) { throw new Error(result.error || "API request failed"); } console.log(result); ``` PHP ``` true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("CIRCUSPAY_SECRET_KEY"), "Content-Type: application/json", ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => '{ "url": "https://example.com/webhooks/circuspay", "events": [ "payment.succeeded", "payment.failed", "payment.refunded" ], "description": "Boutique principale" }', ]); $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.post( "https://circus-pay.com/api/webhooks.php", headers={"Authorization": "Bearer " + os.environ["CIRCUSPAY_SECRET_KEY"]}, json={'url': 'https://example.com/webhooks/circuspay', 'events': ['payment.succeeded', 'payment.failed', 'payment.refunded'], 'description': 'Boutique principale'}, timeout=20, ) response.raise_for_status() result = response.json() if not result.get("success"): raise RuntimeError(result.get("error", "API request failed")) print(result) ``` Store the `webhook.secret` returned at creation in `CIRCUSPAY_WEBHOOK_SECRET`. It verifies signatures and is distinct from your API key. ## Verify the signature `X-ONIPAY-Signature` contains the hexadecimal HMAC-SHA256 of the raw HTTP body, computed with the webhook secret. Verify the exact received body before re-encoding JSON. PHP · signature verification ``` true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("CIRCUSPAY_SECRET_KEY"), "Content-Type: application/json", ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => '{ "id": 123 }', ]); $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.post( "https://circus-pay.com/api/webhooks.php?action=test", headers={"Authorization": "Bearer " + os.environ["CIRCUSPAY_SECRET_KEY"]}, json={'id': 123}, timeout=20, ) response.raise_for_status() result = response.json() if not result.get("success"): raise RuntimeError(result.get("error", "API request failed")) print(result) ``` ## Inspect deliveries GET`/webhooks.php?id=123&logs=1` Terminal ``` curl "https://circus-pay.com/api/webhooks.php?id=123&logs=1" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/webhooks.php?id=123&logs=1", { 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 ``` 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/webhooks.php?id=123&logs=1", 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) ``` Replace 123 with your webhook ID. The `logs` response contains the last 50 deliveries, including HTTP status, duration and any error. --- # Test mode Validate your flow before collecting a real payment. ## Create a test checkout POST`/checkout/create.php` Terminal ``` curl "https://circus-pay.com/api/checkout/create.php" \ -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" \ -H "Content-Type: application/json" \ --data '{ "amount": 1000, "currency": "EUR", "orderId": "TEST-DEMO-001", "testMode": true }' ``` JavaScript ``` const response = await fetch("https://circus-pay.com/api/checkout/create.php", { method: "POST", headers: { Authorization: `Bearer ${process.env.CIRCUSPAY_SECRET_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "amount": 1000, "currency": "EUR", "orderId": "TEST-DEMO-001", "testMode": true }) }); const result = await response.json(); if (!response.ok || !result.success) { throw new Error(result.error || "API request failed"); } console.log(result); ``` PHP ``` true, CURLOPT_TIMEOUT => 20, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("CIRCUSPAY_SECRET_KEY"), "Content-Type: application/json", ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => '{ "amount": 1000, "currency": "EUR", "orderId": "TEST-DEMO-001", "testMode": true }', ]); $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.post( "https://circus-pay.com/api/checkout/create.php", headers={"Authorization": "Bearer " + os.environ["CIRCUSPAY_SECRET_KEY"]}, json={'amount': 1000, 'currency': 'EUR', 'orderId': 'TEST-DEMO-001', 'testMode': True}, timeout=20, ) response.raise_for_status() result = response.json() if not result.get("success"): raise RuntimeError(result.get("error", "API request failed")) print(result) ``` A test key forces this mode. The response contains `test: true`, `mode: "test"` and a sandbox URL. Check these values before continuing. ## Check your integration - Create a new order with a unique reference. - Open the returned sandbox URL and follow its simulation flow. - Check notification reception in your test environment. - Check that multiple notifications do not cause multiple fulfilments. - Test failure and return to the store. **Keep in mind** Test mode does not collect through a real provider. It does not prove that a method or currency is enabled in production. Test webhooks can reach your configured destinations: isolate test processing. --- # Errors & troubleshooting Understand a response and identify your next action. ## Read an error Illustrative example ``` { "success": false, "code": "currency_unsupported", "error": "La devise demandée n’est pas disponible." } ``` Check both the HTTP status and `success`. The `code` field is not present in every error; `error` provides a message. | Parameter | Description | | --- | --- | | `400` | Invalid or missing parameter. Check amount, currency and JSON body. | | `401` | Missing or invalid authentication. Check the Bearer header and your key. | | `403 / session_required` | Action reserved for a portal session. | | `404` | Resource not found for your account. | | `405` | Incorrect HTTP method. | | `currency_unsupported` | Currency unavailable for processing this payment. | | `theme_not_found` | Check your theme ID and activation. | | `cluster_unavailable` | The requested dedicated processing is unavailable. | | `5xx` | Server error. Check order status before retrying creation. | ## The webhook does not confirm the order Inspect delivery logs, the public HTTPS URL and your server response. Verify the signature over the raw body, then reconcile the order through the transactions API. ## Contact support Provide the date and time, API path, order reference and error message. Mask keys and personal data. [Contact CircusPay →](https://circus-pay.com/contact/) --- # Integrations Use the tools and libraries in your environment. ## REST, without mandatory dependencies The API uses HTTPS and JSON. These examples work with cURL, Node.js fetch, PHP's cURL extension and Python requests. They are integration examples, not official SDKs. ## E-commerce connectors Find the available connectors and their status on the [integrations page](https://circus-pay.com/integrations/). Use the module suited to your store and account. ## Documentation for your tools A public text version provides these guides for developer tools and coding assistants. [Download the text reference ↓](https://circus-pay.com/docs/en/reference.txt) ## Existing integration compatibility Publishing this documentation center changes neither endpoints, keys nor the payment engine. Keep your existing integration and adopt additional options as needed. --- # Skills & AI tools Integrate CircusPay with your coding assistant. BUILT FOR DEVELOPERS & AGENTS ## Your assistant. The right documentation. Give your development tool the actual CircusPay parameters, examples and payment-confirmation rules. [Download the skill ↓](https://circus-pay.com/docs/en/circuspay-integration.zip) ## Choose the right format [↗ ### llms.txt Lightweight index: guides, complete reference and skill. **Open index →**](https://circus-pay.com/docs/en/llms.txt)[≡ ### Complete reference A Markdown version preserving all code blocks. **Open reference →**](https://circus-pay.com/docs/en/llms-full.txt)[⌘ ### Integration skill A short entry point and six targeted references for your assistant. **Read SKILL.md →**](https://circus-pay.com/docs/en/skills/circuspay-integration/SKILL.md)[↓ ### Downloadable pack The skill and its references in a folder ready to add to your project. **Download ZIP →**](https://circus-pay.com/docs/en/circuspay-integration.zip) ## Use the skill - Download and extract the ZIP. - Add the `circuspay-integration` folder to the skills location recognized by your tool. You can also attach SKILL.md and its references to your assistant. - Request the integration you need and specify your language, currency and payment methods. - Configure the key in your server environment. Do not paste it into the conversation. **Depending on your tool** Automatic skill discovery depends on your assistant. The pack contains standard Markdown files that can also be read as context in Claude Code, Codex or another developer tool. ## An example request Prompt to adapt ``` Read the circuspay-integration skill and the relevant references. Integrate a CircusPay checkout into my existing Node.js backend. Use test mode, an order of PLN 150 and BLIK only. Read the key from CIRCUSPAY_SECRET_KEY server-side. Add webhook verification and idempotent order confirmation. Preserve existing integrations. Do not create any real payment. ``` ## Targeted references Each guide is available in Markdown: [checkout creation](https://circus-pay.com/docs/en/markdown/create-payment.md), [payment methods](https://circus-pay.com/docs/en/markdown/payment-methods.md), [themes](https://circus-pay.com/docs/en/markdown/themes.md), [webhooks](https://circus-pay.com/docs/en/markdown/webhooks.md), [transactions](https://circus-pay.com/docs/en/markdown/transactions.md) and [test mode](https://circus-pay.com/docs/en/markdown/testing.md).