Playground API
DocsStatsBlogStudio
Documentation Tree
Technical BlogFeature Deep Dives
  • Introduction
  • Quickstart
    5 min
  • How It Works
  • Recipes & Cookbooks
  • Platform Comparisons
  • Real-World Showcase
  • Interactive Studio
    Studio
  • GraphiQL IDE
    IDE
  • Session Quotas & Activity
  • Network Chaos Simulator
  • Atomic Sandbox Reset
  • Overview & Models
    Hub
  • Users Resource
  • Posts Resource
  • Comments Resource
  • Todos Resource
  • Custom Collections
    Custom
  • Multipart File Uploads
    Upload
  • Dynamic SVG Avatars
    SVG
  • Image Thumbnails
    CDN
  • Relational Filtering
  • Full-Text Search
  • Dynamic Sorting
  • Offset Pagination
  • Cursor Pagination
    Scroll
  • CSV & Excel Export & Import
    IO
  • Custom Collections
    CRUD
  • Overview & Architecture
    Hub
  • JWT Auth Flow
  • Refresh Token Rotation
    Mutex
  • RBAC Permission Matrix
    Roles
  • Expiry Simulation
  • Clock Skew Drift
  • Password Recovery Loop
  • Dual-Mode Sandboxing
  • GraphiQL IDE
    IDE
  • Relational Queries
  • Stateful Mutations
  • Realtime Subscriptions
  • Overview & Flowcharts
    Hub
  • Hosted Checkout
    Stripe
  • Payment Intents API
  • 3DS Challenge Modal
    Modal
  • Customers Vault
  • Charges & Refunds
  • Test Cards Catalog
  • Overview & Channels
    Hub
  • Virtual Email Mailbox
    Mailtrap
  • Virtual SMS Terminal
    Phone
  • In-App Notifications
  • Message Dispatcher
  • Realtime Studio
    Studio
  • Native WebSocket (/ws)
  • Socket.io Gateway
  • Presence & Echo Bot
  • Server-Sent Events (SSE)
    SSE
  • Analytics Telemetry
  • Webhook Subscriptions
  • HMAC SHA-256 Signatures
  • Delivery Logs
  • Manual Retry Simulator
  • Network Latency Delay
  • HTTP Status Codes
  • Rate-Limit Simulator
    429
  • Flaky Network & Jitter
    Chaos
  • Session Quotas & Activity
  • JSON Snapshots
    JSON
  • Headless CI/CD Testing
    CI
  • Mobile QR Code Sync
  • System Metrics & Health
  • Atomic Sandbox Reset
  • Official TypeScript SDK
  • Multi-Language Generators
  • DevTools Extension
  • OpenAPI 3.1 Spec
    JSON
  • Postman Collection v2.1
  • Bruno Collection
  • Insomnia Workspace
  • TypeScript .d.ts
    .d.ts
  • AI Prompt Rules
    Rules
  • Context Index (llms.txt)
  • Full Schema (llms-full.txt)
  • Manifest (product.json)
  • All Feature Articles
    Blog
  • React CRUD Without Backend
    Deep Dive
  • Why Static APIs Fail
  • Mocking Stateful Auth
  • WebSockets & SSE Guide
Technical Blog
Articles

In-depth articles explaining stateful mock APIs, WebSockets, payments, and frontend resilience.

Read Articles
PreviousOverview & Flowcharts
NextPayment Intents API
Mock Commerce & Billing

Hosted Checkout Sessions

Integrate zero-PCI hosted checkout pages modeled directly after Stripe Checkout. Generate hosted session URLs, handle dynamic multi-line item carts, test success/cancel callback redirects, and trigger automated webhook fulfillment.

API PlaygroundLifecycle & Webhooks

Interactive Cart Builder

Configure line items and preview the generated Stripe-like hosted session.

Developer Pro SaaS (Monthly)

$29.00 USD each

1
$29.00
Dedicated Dedicated IP Add-on

$15.00 USD each

1
$15.00
Subtotal & Total Due$44.00 USD

Interactive Checkout Endpoints

Test creating sessions, inspecting state, and simulating completion against your active sandbox.

1. Create Checkout Session

Create Checkout Session

POST
response.json
1
{
2
// Click "Send" above to execute this request against the live server.
3
}

2. Complete Session Simulation

Simulate Buyer Completing Checkout

POST
response.json
1
{
2
// Click "Send" above to execute this request against the live server.
3
}

Production Integration Recipes

Server-side session generation and webhook fulfillment architecture.

Next.js / Node Route (Create Session & Redirect)

typescript
1
// app/api/checkout/route.ts
2
import { NextResponse } from 'next/server';
3
4
export async function POST(req: Request) {
5
const { cartItems, userId } = await req.json();
6
7
const session = await fetch('https://playground.nileslabs.com/api/v1/checkout/sessions', {
8
method: 'POST',
9
headers: { 'Content-Type': 'application/json' },
10
body: JSON.stringify({
11
line_items: cartItems.map((item: any) => ({
12
name: item.title,
13
amount: item.priceCents,
14
quantity: item.qty,
15
})),
16
mode: 'payment',
17
success_url: ${process.env.APP_URL}/dashboard?payment=success&session_id={CHECKOUT_SESSION_ID},
18
cancel_url: ${process.env.APP_URL}/cart,
19
metadata: { userId },
20
}),
21
}).then(res => res.json());
22
23
// Redirect buyer to the hosted checkout page
24
return NextResponse.json({ url: session.url });
25
}

Webhook Fulfillment Handler

javascript
1
// Listen for checkout.session.completed
2
export async function handleWebhook(event) {
3
if (event.type === 'checkout.session.completed') {
4
const session = event.data;
5
const userId = session.metadata?.userId;
6
const totalAmount = session.amount_total;
7
8
console.log(Order fulfilled for user ${userId}, total: ${totalAmount});
9
// 1. Grant entitlements in your database
10
await grantProSubscription(userId);
11
// 2. Receipt email was already dispatched to Virtual Inbox!
12
}
13
}