Create Collection
curl --request POST \
--url https://api.fyatu.com/api/v3/collections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 25,
"currency": "USD",
"orderId": "ORD-0001",
"description": "Premium Subscription",
"callbackUrl": "https://yoursite.com/payment/complete",
"webhookUrl": "https://yoursite.com/webhook/fyatu",
"metadata": {
"userId": "12345",
"plan": "premium"
}
}
'import requests
url = "https://api.fyatu.com/api/v3/collections"
payload = {
"amount": 25,
"currency": "USD",
"orderId": "ORD-0001",
"description": "Premium Subscription",
"callbackUrl": "https://yoursite.com/payment/complete",
"webhookUrl": "https://yoursite.com/webhook/fyatu",
"metadata": {
"userId": "12345",
"plan": "premium"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 25,
currency: 'USD',
orderId: 'ORD-0001',
description: 'Premium Subscription',
callbackUrl: 'https://yoursite.com/payment/complete',
webhookUrl: 'https://yoursite.com/webhook/fyatu',
metadata: {userId: '12345', plan: 'premium'}
})
};
fetch('https://api.fyatu.com/api/v3/collections', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fyatu.com/api/v3/collections",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 25,
'currency' => 'USD',
'orderId' => 'ORD-0001',
'description' => 'Premium Subscription',
'callbackUrl' => 'https://yoursite.com/payment/complete',
'webhookUrl' => 'https://yoursite.com/webhook/fyatu',
'metadata' => [
'userId' => '12345',
'plan' => 'premium'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fyatu.com/api/v3/collections"
payload := strings.NewReader("{\n \"amount\": 25,\n \"currency\": \"USD\",\n \"orderId\": \"ORD-0001\",\n \"description\": \"Premium Subscription\",\n \"callbackUrl\": \"https://yoursite.com/payment/complete\",\n \"webhookUrl\": \"https://yoursite.com/webhook/fyatu\",\n \"metadata\": {\n \"userId\": \"12345\",\n \"plan\": \"premium\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.fyatu.com/api/v3/collections")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 25,\n \"currency\": \"USD\",\n \"orderId\": \"ORD-0001\",\n \"description\": \"Premium Subscription\",\n \"callbackUrl\": \"https://yoursite.com/payment/complete\",\n \"webhookUrl\": \"https://yoursite.com/webhook/fyatu\",\n \"metadata\": {\n \"userId\": \"12345\",\n \"plan\": \"premium\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fyatu.com/api/v3/collections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 25,\n \"currency\": \"USD\",\n \"orderId\": \"ORD-0001\",\n \"description\": \"Premium Subscription\",\n \"callbackUrl\": \"https://yoursite.com/payment/complete\",\n \"webhookUrl\": \"https://yoursite.com/webhook/fyatu\",\n \"metadata\": {\n \"userId\": \"12345\",\n \"plan\": \"premium\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"status": 201,
"message": "Checkout session created successfully",
"data": {
"collectionId": "col_a1b2c3d4e5f6",
"reference": "A2B4C6D8E0F2",
"orderId": "ORD-0001",
"amount": 25,
"fee": 0.75,
"netAmount": 24.25,
"currency": "USD",
"status": "PENDING",
"checkoutUrl": "https://checkout.fyatu.com/sci/checkout?batch=col_a1b2c3d4e5f6",
"expiresAt": "2026-01-08T12:30:00+00:00"
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-08T11:30:00+00:00"
}
}{
"success": false,
"status": 400,
"message": "Validation failed",
"error": {
"code": "VALIDATION_ERROR",
"details": [
{
"field": "currency",
"message": "Currency is required"
}
]
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-05T10:30:00+00:00"
}
}{
"success": false,
"status": 401,
"message": "Unable to identify business",
"error": {
"code": "AUTH_TOKEN_INVALID"
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-05T10:30:00+00:00"
}
}{
"success": false,
"status": 409,
"message": "A collection with this order ID already exists",
"error": {
"code": "DUPLICATE_REFERENCE"
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-08T11:30:00+00:00"
}
}Collections
Create Collection
Create a payment collection session with hosted checkout. Accept payments from customers with callback and webhook support. POST /collections.
POST
/
collections
Create Collection
curl --request POST \
--url https://api.fyatu.com/api/v3/collections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 25,
"currency": "USD",
"orderId": "ORD-0001",
"description": "Premium Subscription",
"callbackUrl": "https://yoursite.com/payment/complete",
"webhookUrl": "https://yoursite.com/webhook/fyatu",
"metadata": {
"userId": "12345",
"plan": "premium"
}
}
'import requests
url = "https://api.fyatu.com/api/v3/collections"
payload = {
"amount": 25,
"currency": "USD",
"orderId": "ORD-0001",
"description": "Premium Subscription",
"callbackUrl": "https://yoursite.com/payment/complete",
"webhookUrl": "https://yoursite.com/webhook/fyatu",
"metadata": {
"userId": "12345",
"plan": "premium"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 25,
currency: 'USD',
orderId: 'ORD-0001',
description: 'Premium Subscription',
callbackUrl: 'https://yoursite.com/payment/complete',
webhookUrl: 'https://yoursite.com/webhook/fyatu',
metadata: {userId: '12345', plan: 'premium'}
})
};
fetch('https://api.fyatu.com/api/v3/collections', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fyatu.com/api/v3/collections",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 25,
'currency' => 'USD',
'orderId' => 'ORD-0001',
'description' => 'Premium Subscription',
'callbackUrl' => 'https://yoursite.com/payment/complete',
'webhookUrl' => 'https://yoursite.com/webhook/fyatu',
'metadata' => [
'userId' => '12345',
'plan' => 'premium'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fyatu.com/api/v3/collections"
payload := strings.NewReader("{\n \"amount\": 25,\n \"currency\": \"USD\",\n \"orderId\": \"ORD-0001\",\n \"description\": \"Premium Subscription\",\n \"callbackUrl\": \"https://yoursite.com/payment/complete\",\n \"webhookUrl\": \"https://yoursite.com/webhook/fyatu\",\n \"metadata\": {\n \"userId\": \"12345\",\n \"plan\": \"premium\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.fyatu.com/api/v3/collections")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 25,\n \"currency\": \"USD\",\n \"orderId\": \"ORD-0001\",\n \"description\": \"Premium Subscription\",\n \"callbackUrl\": \"https://yoursite.com/payment/complete\",\n \"webhookUrl\": \"https://yoursite.com/webhook/fyatu\",\n \"metadata\": {\n \"userId\": \"12345\",\n \"plan\": \"premium\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fyatu.com/api/v3/collections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 25,\n \"currency\": \"USD\",\n \"orderId\": \"ORD-0001\",\n \"description\": \"Premium Subscription\",\n \"callbackUrl\": \"https://yoursite.com/payment/complete\",\n \"webhookUrl\": \"https://yoursite.com/webhook/fyatu\",\n \"metadata\": {\n \"userId\": \"12345\",\n \"plan\": \"premium\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"status": 201,
"message": "Checkout session created successfully",
"data": {
"collectionId": "col_a1b2c3d4e5f6",
"reference": "A2B4C6D8E0F2",
"orderId": "ORD-0001",
"amount": 25,
"fee": 0.75,
"netAmount": 24.25,
"currency": "USD",
"status": "PENDING",
"checkoutUrl": "https://checkout.fyatu.com/sci/checkout?batch=col_a1b2c3d4e5f6",
"expiresAt": "2026-01-08T12:30:00+00:00"
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-08T11:30:00+00:00"
}
}{
"success": false,
"status": 400,
"message": "Validation failed",
"error": {
"code": "VALIDATION_ERROR",
"details": [
{
"field": "currency",
"message": "Currency is required"
}
]
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-05T10:30:00+00:00"
}
}{
"success": false,
"status": 401,
"message": "Unable to identify business",
"error": {
"code": "AUTH_TOKEN_INVALID"
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-05T10:30:00+00:00"
}
}{
"success": false,
"status": 409,
"message": "A collection with this order ID already exists",
"error": {
"code": "DUPLICATE_REFERENCE"
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-08T11:30:00+00:00"
}
}Overview
Create a checkout session to collect payment from a customer. Returns a checkout URL where the customer completes payment.Request Body
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Payment amount in USD |
currency | string | No | Currency code (default: USD). Only USD supported, other values are ignored |
orderId | string | Yes | Your unique order/invoice ID (max 100 chars) |
description | string | Yes | Payment description (max 100 chars) |
callbackUrl | string | No | Return URL after payment (overrides dashboard setting) |
webhookUrl | string | No | IPN URL for server-to-server notifications (overrides dashboard setting) |
metadata | object | No | Custom data to attach to the payment |
callbackUrl and webhookUrl are optional overrides. If not provided, the URLs configured in your app dashboard will be used.Response
| Field | Type | Description |
|---|---|---|
collectionId | string | Unique collection identifier |
reference | string | Human-readable reference (shown to payer) |
orderId | string | Your order ID (if provided) |
amount | number | Payment amount |
fee | number | Processing fee (deducted from amount) |
netAmount | number | Amount you receive (amount - fee) |
currency | string | Currency code |
status | string | PENDING |
checkoutUrl | string | URL to redirect customer for payment |
expiresAt | string | Session expiry time (60 minutes) |
Integration Examples
<?php
// Create checkout session via API
$appId = 'DD123FR45446CECES';
$secretKey = 'YOUR_SECRET_KEY';
// Step 1: Get access token
$tokenResponse = file_get_contents('https://api.fyatu.com/api/v3/auth/token', false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'content' => json_encode([
'appId' => $appId,
'secretKey' => $secretKey,
'grantType' => 'client_credentials'
])
]
]));
$token = json_decode($tokenResponse, true)['data']['accessToken'];
// Step 2: Create checkout session
$response = file_get_contents('https://api.fyatu.com/api/v3/collections', false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => [
'Content-Type: application/json',
'Authorization: Bearer ' . $token
],
'content' => json_encode([
'amount' => 25.00,
'orderId' => 'INV-' . time(),
'description' => 'Premium Subscription',
'callbackUrl' => 'https://yoursite.com/payment/complete', // Optional override
'webhookUrl' => 'https://yoursite.com/webhook/fyatu', // Optional override
'metadata' => [
'userId' => '12345',
'plan' => 'premium'
]
])
]
]));
$result = json_decode($response, true);
if ($result['success']) {
// Redirect customer to checkout
header('Location: ' . $result['data']['checkoutUrl']);
exit;
} else {
echo 'Error: ' . $result['message'];
}
const APP_ID = 'DD123FR45446CECES';
const SECRET_KEY = 'YOUR_SECRET_KEY';
async function createCheckout(orderData) {
// Step 1: Get access token
const tokenResponse = await fetch('https://api.fyatu.com/api/v3/auth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
appId: APP_ID,
secretKey: SECRET_KEY,
grantType: 'client_credentials'
})
});
const { data: tokenData } = await tokenResponse.json();
const accessToken = tokenData.accessToken;
// Step 2: Create checkout session
const response = await fetch('https://api.fyatu.com/api/v3/collections', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify({
amount: orderData.amount,
orderId: orderData.orderId,
description: orderData.description,
callbackUrl: 'https://yoursite.com/payment/complete', // Optional override
webhookUrl: 'https://yoursite.com/webhook/fyatu', // Optional override
metadata: orderData.metadata
})
});
const result = await response.json();
if (result.success) {
return result.data.checkoutUrl;
} else {
throw new Error(result.message);
}
}
// Usage in Express.js
app.post('/create-payment', async (req, res) => {
try {
const checkoutUrl = await createCheckout({
amount: 25.00,
orderId: `INV-${Date.now()}`,
description: 'Premium Subscription',
metadata: { userId: req.user.id }
});
res.json({ checkoutUrl });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
Example Response
{
"success": true,
"status": 201,
"message": "Checkout session created successfully",
"data": {
"collectionId": "col_a1b2c3d4e5f6",
"reference": "A2B4C6D8E0F2",
"orderId": "ORD-0001",
"amount": 25.00,
"fee": 0.75,
"netAmount": 24.25,
"currency": "USD",
"status": "PENDING",
"checkoutUrl": "https://checkout.fyatu.com/sci/checkout?batch=col_a1b2c3d4e5f6",
"expiresAt": "2026-01-08T12:30:00+00:00"
},
"meta": {
"requestId": "req_abc123def456",
"timestamp": "2026-01-08T11:30:00+00:00"
}
}
Checkout Flow
- Create Session: Call this endpoint to create a checkout session
- Redirect Customer: Send customer to the
checkoutUrl - Customer Pays: Customer logs in and completes payment on Fyatu
- Webhook Notification: Receive IPN at your
webhookUrl(server-to-server) - Customer Returns: Customer is redirected to
callbackUrlwith status
Callback URL
After payment (success or failure), the customer is redirected to yourcallbackUrl with query parameters:
https://yoursite.com/payment/complete?batch=col_a1b2c3d4e5f6&status=COMPLETED
| Parameter | Description |
|---|---|
batch | The collection ID |
status | Payment status (COMPLETED, FAILED, CANCELLED) |
Never trust callback parameters alone. Always verify payment status server-side using the webhook or by calling the Get Collection endpoint.
Webhook (IPN)
YourwebhookUrl receives a POST request with the payment details:
{
"event": "collection.completed",
"collectionId": "col_a1b2c3d4e5f6",
"orderId": "ORD-0001",
"reference": "A2B4C6D8E0F2",
"status": "COMPLETED",
"amount": 25.00,
"fee": 0.75,
"netAmount": 24.25,
"currency": "USD",
"payer": {
"clientId": "clt_a1b2c3d4e5f6",
"name": "Alice Example"
},
"metadata": {
"plan": "premium"
},
"completedAt": "2026-01-08T11:35:00+00:00"
}
Session Expiration
- Checkout sessions expire after 60 minutes
- Expired sessions are automatically updated to status
EXPIRED - Create a new session if the customer returns after expiration
Duplicate Prevention
- The
orderIdmust be unique per app - Attempting to create a collection with a duplicate
orderIdreturns409 Conflict - Use
orderIdto link payments to your order/invoice system
Store the
collectionId to later verify the payment status or issue refunds.Authorizations
JWT access token obtained from /auth/token
Body
application/json
Payment amount in USD
Required range:
x >= 1Your unique order/invoice ID (required)
Maximum string length:
100Payment description (max 100 chars)
Maximum string length:
100Currency code (only USD supported, other values ignored)
Return URL after payment (overrides dashboard setting)
IPN URL for server-to-server notifications (overrides dashboard setting)
Custom data to attach
⌘I

