# 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
```
<?php
$ch = curl_init("https://circus-pay.com/api/payment-methods.php");
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/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
```
<?php
$ch = curl_init("https://circus-pay.com/api/checkout/create.php");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => 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.
