Checkout

The Checkout API provides a powerful way to create payment sessions, manage payment flows, and process transactions through Fystack's secure infrastructure.


POST/checkouts

Create a checkout

To create a new checkout, send a POST request to the /checkouts endpoint with the required parameters.

Required parameters

  • Name
    price
    Type
    string
    Description

    The payment amount as a string (e.g., "66").

  • Name
    currency
    Type
    string
    Description

    Three-letter ISO currency code (e.g., USD, EUR). Currently only USD is supported.

  • Name
    supported_assets
    Type
    array
    Description

    List of supported cryptocurrency assets in the format "SYMBOL:CHAIN_ID" (e.g., "SOL:1399811149").

    Chain Chain ID Format Example
    Solana 1399811149 SOL:1399811149
    Ethereum 1 ETH:1, USDC:1
    BNB Chain 56 BNB:56
    Base 8453 ETH:8453
    Polygon 137 POL:137
  • Name
    success_url
    Type
    string
    Description

    URL to redirect customers to after successful payment.

  • Name
    cancel_url
    Type
    string
    Description

    URL to redirect customers to if they cancel the checkout process.

Optional parameters

  • Name
    description
    Type
    string
    Description

    Description of what the customer is purchasing.

  • Name
    product_id
    Type
    string
    Description

    Unique identifier for the product being purchased.

  • Name
    customer_id
    Type
    string
    Description

    Link this checkout to an existing customer in your system.

  • Name
    order_id
    Type
    string
    Description

    Unique identifier for the order.

  • Name
    enable_localization
    Type
    boolean
    Description

    Whether to enable localization for the checkout page. Default is false.

  • Name
    destination_wallet_id
    Type
    string
    Description

    Wallet ID where the payment will be sent to.

    Copy Wallet ID
  • Name
    expiry_duration_seconds
    Type
    number
    Description

    Number of seconds until the checkout session expires. Default is 86400 (24 hours).

Response

  • Name
    id
    Type
    string
    Description

    Unique identifier for the checkout session.

  • Name
    checkout_url
    Type
    string
    Description

    URL to the hosted checkout page. Redirect customers to this URL.

  • Name
    status
    Type
    string
    Description

    Status of the checkout session (pending, complete, expired, canceled).

  • Name
    expires_at
    Type
    timestamp
    Description

    Time at which the checkout session expires.

  • Name
    created_at
    Type
    timestamp
    Description

    Time at which the checkout session was created.

  • Name
    updated_at
    Type
    timestamp
    Description

    Time at which the checkout session was last updated.

  • Name
    currency
    Type
    string
    Description

    Three-letter ISO currency code.

  • Name
    price
    Type
    string
    Description

    The payment amount as a string.

  • Name
    product_id
    Type
    string
    Description

    Unique identifier for the product being purchased.

  • Name
    order_id
    Type
    string
    Description

    Unique identifier for the order.

  • Name
    workspace_id
    Type
    string
    Description

    Identifier for the workspace this checkout belongs to.

  • Name
    description
    Type
    string
    Description

    Description of what the customer is purchasing.

  • Name
    supported_assets
    Type
    array
    Description

    List of cryptocurrency assets supported for this checkout.

  • Name
    customer_id
    Type
    string
    Description

    Identifier for the customer associated with this checkout.

  • Name
    expiry_duration_seconds
    Type
    number
    Description

    Number of seconds until the checkout session expires.

  • Name
    enable_localization
    Type
    boolean
    Description

    Whether localization is enabled for the checkout page.

  • Name
    success_url
    Type
    string
    Description

    URL to redirect customers to after successful payment.

  • Name
    cancel_url
    Type
    string
    Description

    URL to redirect customers to if they cancel the checkout process.

  • Name
    outcome
    Type
    object|null
    Description

    Information about the payment outcome, if available.

  • Name
    from_address
    Type
    string|null
    Description

    The address from which the payment was made, if available.

Request

POST
/checkouts
import { PaymentService, Environment } from '@fystack/sdk'
const paymentService = new PaymentService({
apiKey: apiCredentials.APIKey,
environment: Environment.Production
})
await paymentService.createCheckout({
price: '66',
currency: 'USD',
supported_assets: ['SOL:1399811149', 'USDC:1399811149', 'ETH:8453', 'ETH:1', 'USDC:1'],
description: 'Access to premium features and exclusive content.',
success_url: 'https://example.com/payment/success',
cancel_url: 'https://example.com/payment/cancel',
product_id: '4c57fae9-1a54-4a1b-9d94-00d5b4a3e1d2',
customer_id: 'bc5bd50d-265e-4ea9-b312-bd8de5118683',
order_id: 'bc5bd50d-265e-4ea9-b312-bd8de5118683',
enable_localization: false,
destination_wallet_id: 'ca6b5c4d-753f-4c2d-af18-520f66a42bd4',
expiry_duration_seconds: 3600
})

GET/checkouts/{id}

Retrieve a checkout

Retrieve the details of a checkout by its ID.

Response

  • Name
    id
    Type
    string
    Description

    Unique identifier for the checkout.

  • Name
    status
    Type
    string
    Description

    Status of the checkout (pending, complete, expired, canceled).

  • Name
    price
    Type
    string
    Description

    The payment amount as a string.

  • Name
    currency
    Type
    string
    Description

    Three-letter ISO currency code.

  • Name
    created_at
    Type
    timestamp
    Description

    Time at which the checkout was created.

  • Name
    updated_at
    Type
    timestamp
    Description

    Time at which the checkout was last updated.

  • Name
    product_id
    Type
    string
    Description

    Unique identifier for the product being purchased.

  • Name
    order_id
    Type
    string
    Description

    Unique identifier for the order.

  • Name
    workspace_id
    Type
    string
    Description

    Identifier for the workspace this checkout belongs to.

  • Name
    description
    Type
    string
    Description

    Description of what the customer is purchasing.

  • Name
    supported_assets
    Type
    array
    Description

    List of cryptocurrency assets supported for this checkout.

  • Name
    customer_id
    Type
    string
    Description

    Identifier for the customer associated with this checkout.

  • Name
    expiry_duration_seconds
    Type
    number
    Description

    Number of seconds until the checkout expires.

  • Name
    success_url
    Type
    string
    Description

    URL to redirect customers to after successful payment.

  • Name
    cancel_url
    Type
    string
    Description

    URL to redirect customers to if they cancel the checkout process.

  • Name
    checkout_url
    Type
    string
    Description

    URL to the hosted checkout page.

  • Name
    outcome
    Type
    object|null
    Description

    Information about the payment outcome, if available.

  • Name
    from_address
    Type
    string|null
    Description

    The address from which the payment was made, if available.

Request

GET
/checkouts/{id}
import { PaymentService, Environment } from '@fystack/sdk'
const paymentService = new PaymentService({
apiKey: apiCredentials.APIKey,
environment: Environment.Production
})
const checkout = await paymentService.getCheckout('17976d0a-e4ff-44a6-a47e-c7e2bbab3db2')

POST/checkouts/{id}/payment

Create a checkout payment

Create a payment for an existing checkout session by specifying which supported asset to use for payment.

Required parameters

  • Name
    pay_asset_id
    Type
    string
    Description

    The ID of the asset to use for payment. Must be one of the supported assets in the checkout session.

Optional parameters

  • Name
    customer_email
    Type
    string
    Description

    Email address of the customer making the payment.

Response

  • Name
    id
    Type
    string
    Description

    Unique identifier for the payment.

  • Name
    checkout_id
    Type
    string
    Description

    ID of the associated checkout session.

  • Name
    customer_email
    Type
    string|null
    Description

    Email of the customer, if provided.

  • Name
    pay_asset_id
    Type
    string
    Description

    ID of the asset being used for payment.

  • Name
    network_id
    Type
    string
    Description

    ID of the blockchain network for the transaction.

  • Name
    expired_at
    Type
    timestamp
    Description

    Time at which the payment will expire.

  • Name
    payer_address
    Type
    string|null
    Description

    Address from which the payment was sent, if available.

  • Name
    tx_hash
    Type
    string|null
    Description

    Transaction hash, if available.

  • Name
    converted_crypto_price
    Type
    string
    Description

    The payment amount converted to the selected cryptocurrency.

  • Name
    deposit_address
    Type
    string
    Description

    Address where payment should be sent.

  • Name
    deposit_qr
    Type
    string
    Description

    URL to a QR code containing the deposit address.

  • Name
    created_at
    Type
    timestamp
    Description

    Time at which the payment was created.

  • Name
    updated_at
    Type
    timestamp
    Description

    Time at which the payment was last updated.

Request

POST
/checkouts/{id}/payment
import { PaymentService, Environment } from '@fystack/sdk'
const paymentService = new PaymentService({
apiKey: apiCredentials.APIKey,
environment: Environment.Production
})
// First get the checkout to see available assets
const checkout = await paymentService.getCheckout('2912168a-6bb6-4b5c-88bb-723706718e4a')
// Then create a payment using one of the supported assets
const payment = await paymentService.createCheckoutPayment(checkout.id, {
pay_asset_id: checkout.supported_assets[0].id
})

GET/checkouts/payment/{id}

Retrieve a checkout payment

Retrieve detailed information about a checkout payment by its ID.

Response

  • Name
    id
    Type
    string
    Description

    Unique identifier for the payment.

  • Name
    checkout_id
    Type
    string
    Description

    ID of the associated checkout session.

  • Name
    checkout
    Type
    object
    Description

    The complete checkout session object.

  • Name
    customer_email
    Type
    string|null
    Description

    Email of the customer, if provided.

  • Name
    pay_asset_id
    Type
    string
    Description

    ID of the asset being used for payment.

  • Name
    pay_asset
    Type
    object
    Description

    Details of the asset being used for payment.

  • Name
    network_id
    Type
    string
    Description

    ID of the blockchain network for the transaction.

  • Name
    network
    Type
    object
    Description

    Details of the blockchain network.

  • Name
    expired_at
    Type
    timestamp
    Description

    Time at which the payment will expire.

  • Name
    payer_address
    Type
    string|null
    Description

    Address from which the payment was sent, if available.

  • Name
    tx_hash
    Type
    string|null
    Description

    Transaction hash, if available.

  • Name
    converted_crypto_price
    Type
    string
    Description

    The payment amount converted to the selected cryptocurrency.

  • Name
    deposit_address
    Type
    string
    Description

    Address where payment should be sent.

  • Name
    deposit_qr
    Type
    string
    Description

    URL to a QR code containing the deposit address.

  • Name
    created_at
    Type
    timestamp
    Description

    Time at which the payment was created.

  • Name
    updated_at
    Type
    timestamp
    Description

    Time at which the payment was last updated.

Request

GET
/checkouts/payment/{id}
import { PaymentService, Environment } from '@fystack/sdk'
const paymentService = new PaymentService({
apiKey: apiCredentials.APIKey,
environment: Environment.Production
})
const checkoutPayment = await paymentService.getCheckoutPayment('06d92c50-e6f1-4637-8c20-72cf7e7d7b8a')
console.log('checkout payment', checkoutPayment)

Checkout Webhooks

Fystack's Checkout API uses webhooks to notify your application when important events occur, such as when a checkout session is completed or a payment succeeds or fails.

Common webhook events

  • payment.received: Triggered when a payment is received.
  • payment.success: Triggered when a payment is successful.

Verifying webhook events

For security reasons, you should always verify webhook events to ensure they were actually sent by Fystack. Each webhook request includes a signature in the X-Webhook-Signature header that you can use to verify the authenticity of the webhook payload. The event type is also included in the X-Webhook-Event header.

To verify a webhook event, you'll need:

  1. The webhook event payload
  2. The signature from the X-Webhook-Signature header

Using the SDK's verifyEvent method, you can easily check if the webhook is valid before processing it.

Event payload structure

  • Name
    webhook_id
    Type
    string
    Description

    Unique identifier for the webhook configuration.

  • Name
    resource_id
    Type
    string
    Description

    Identifier for the resource associated with the event.

  • Name
    url
    Type
    string
    Description

    The URL where the webhook was sent.

  • Name
    payload
    Type
    object
    Description

    The actual event data, containing details about the checkout or payment.

  • Name
    event
    Type
    string
    Description

    The type of event (e.g., "payment.received", "payment.success").

Verifying a webhook event

import { APIService, Environment } from '@fystack/sdk'
// Express.js example
app.post('/webhook', express.raw({type: 'application/json'}), async (req, res) => {
const signature = req.headers['x-webhook-signature'] as string;
const eventType = req.headers['x-webhook-event'] as string;
const event = req.body;
const apiService = new APIService(apiCredentials, Environment.Production);
try {
const isValid = await apiService.Webhook.verifyEvent(event, signature);
if (isValid) {
// Process the webhook event
if (eventType === 'payment.received') {
const { checkout_id, tx_hash, status } = event.payload;
console.log(`Payment received for checkout ${checkout_id}: ${tx_hash}`);
// Update your database, notify your user, etc.
}
res.status(200).send('Webhook received and verified');
} else {
console.warn('Invalid webhook signature');
res.status(400).send('Invalid signature');
}
} catch (error) {
console.error('Webhook verification failed', error);
res.status(400).send('Webhook verification failed');
}
});

Example webhook payload