Skip to main content
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

Authorization
string
required
Bearer token with your API key
id
string
required
The unique identifier of the checkout session (e.g., sess_abc123)

Response

success
boolean
Whether the request was successful
data
object
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

StatusDescription
pendingSession created, awaiting customer payment
processingPayment is being processed
completedPayment successful
expiredSession expired before payment
failedPayment failed
Sessions expire after 1 hour by default. Check expiresAt to see when a pending session will expire.