curl https://api.swiftpay.cx/api/checkout/sessions/sess_abc123 \
-H "Authorization: Bearer mp_live_your_api_key"
const sessionId = "sess_abc123";
const response = await fetch(
`https://api.swiftpay.cx/api/checkout/sessions/${sessionId}`,
{
headers: {
Authorization: "Bearer mp_live_your_api_key",
},
}
);
const session = await response.json();
if (session.data.status === "completed") {
console.log("Payment successful!");
}
import requests
session_id = 'sess_abc123'
response = requests.get(
f'https://api.swiftpay.cx/api/checkout/sessions/{session_id}',
headers={'Authorization': 'Bearer mp_live_your_api_key'}
)
session = response.json()
if session['data']['status'] == 'completed':
print('Payment successful!')
{
"success": true,
"data": {
"id": "sess_abc123",
"amountInCents": 2999,
"currency": "USD",
"status": "completed",
"checkoutUrl": "https://checkout.swiftpay.cx/sess_abc123",
"customerEmail": "customer@example.com",
"metadata": {
"orderId": "order_12345",
"productName": "Premium Plan"
},
"successUrl": "https://yoursite.com/success",
"cancelUrl": "https://yoursite.com/cancel",
"expiresAt": "2024-01-15T11:30:00Z",
"completedAt": "2024-01-15T10:35:00Z",
"createdAt": "2024-01-15T10:30:00Z"
}
}
{
"success": false,
"error": {
"type": "not_found",
"message": "Checkout session not found",
"requestId": "req_abc123"
}
}
Checkout Sessions
Get Checkout Session
Retrieve a specific checkout session by ID
GET
/
api
/
checkout
/
sessions
/
:id
curl https://api.swiftpay.cx/api/checkout/sessions/sess_abc123 \
-H "Authorization: Bearer mp_live_your_api_key"
const sessionId = "sess_abc123";
const response = await fetch(
`https://api.swiftpay.cx/api/checkout/sessions/${sessionId}`,
{
headers: {
Authorization: "Bearer mp_live_your_api_key",
},
}
);
const session = await response.json();
if (session.data.status === "completed") {
console.log("Payment successful!");
}
import requests
session_id = 'sess_abc123'
response = requests.get(
f'https://api.swiftpay.cx/api/checkout/sessions/{session_id}',
headers={'Authorization': 'Bearer mp_live_your_api_key'}
)
session = response.json()
if session['data']['status'] == 'completed':
print('Payment successful!')
{
"success": true,
"data": {
"id": "sess_abc123",
"amountInCents": 2999,
"currency": "USD",
"status": "completed",
"checkoutUrl": "https://checkout.swiftpay.cx/sess_abc123",
"customerEmail": "customer@example.com",
"metadata": {
"orderId": "order_12345",
"productName": "Premium Plan"
},
"successUrl": "https://yoursite.com/success",
"cancelUrl": "https://yoursite.com/cancel",
"expiresAt": "2024-01-15T11:30:00Z",
"completedAt": "2024-01-15T10:35:00Z",
"createdAt": "2024-01-15T10:30:00Z"
}
}
{
"success": false,
"error": {
"type": "not_found",
"message": "Checkout session not found",
"requestId": "req_abc123"
}
}
Get Checkout Session
Retrieves the details of an existing checkout session.Request
Bearer token with your API key
The unique identifier of the checkout session (e.g.,
sess_abc123)Response
Whether the request was successful
Show properties
Show properties
Unique session identifier
Current status:
pending, processing, completed, failed,
cancelled, refundedThe URL where the customer can complete the payment
Three-letter ISO currency code
Total amount in cents
Customer’s email address
Customer’s name (if provided)
Session description
Custom key-value pairs
Redirect URL after successful payment
Redirect URL if payment cancelled
Redirect URL if payment failed
ISO 8601 completion timestamp (if completed)
ISO 8601 creation timestamp
ISO 8601 last update timestamp
curl https://api.swiftpay.cx/api/checkout/sessions/sess_abc123 \
-H "Authorization: Bearer mp_live_your_api_key"
const sessionId = "sess_abc123";
const response = await fetch(
`https://api.swiftpay.cx/api/checkout/sessions/${sessionId}`,
{
headers: {
Authorization: "Bearer mp_live_your_api_key",
},
}
);
const session = await response.json();
if (session.data.status === "completed") {
console.log("Payment successful!");
}
import requests
session_id = 'sess_abc123'
response = requests.get(
f'https://api.swiftpay.cx/api/checkout/sessions/{session_id}',
headers={'Authorization': 'Bearer mp_live_your_api_key'}
)
session = response.json()
if session['data']['status'] == 'completed':
print('Payment successful!')
{
"success": true,
"data": {
"id": "sess_abc123",
"amountInCents": 2999,
"currency": "USD",
"status": "completed",
"checkoutUrl": "https://checkout.swiftpay.cx/sess_abc123",
"customerEmail": "customer@example.com",
"metadata": {
"orderId": "order_12345",
"productName": "Premium Plan"
},
"successUrl": "https://yoursite.com/success",
"cancelUrl": "https://yoursite.com/cancel",
"expiresAt": "2024-01-15T11:30:00Z",
"completedAt": "2024-01-15T10:35:00Z",
"createdAt": "2024-01-15T10:30:00Z"
}
}
{
"success": false,
"error": {
"type": "not_found",
"message": "Checkout session not found",
"requestId": "req_abc123"
}
}
Session Statuses
| Status | Description |
|---|---|
pending | Session created, awaiting customer payment |
processing | Payment is being processed |
completed | Payment successful |
expired | Session expired before payment |
failed | Payment failed |
Sessions expire after 1 hour by default. Check
expiresAt to see when a
pending session will expire.⌘I