Payment Gateway & Checkout API

Mock Payment Gateway & Hosted Checkout

Simulate realistic payment flows with 100% Stripe parity. Test deterministic card outcomes (instant success, declines, insufficient funds, card expired), 3D Secure modal challenges, payment intents, refunds, and hosted checkout sessions with automated receipt email delivery.

Live Interactive Payment Studio

Active Identity Sandbox

Try direct charges, flip the 3D card preview, test 3D Secure authentication challenges, create hosted checkout sessions, and issue refunds directly in your browser.

Playground Card
Visa
4242 4242 4242 4242
Cardholder
Alex Taylor
Expires
12/28
CVV / CVC
123
Simulated Sandbox Payment Gateway • Zero Real Funds Charged
1-Click Test Card PresetsClick to autofill

Simulate Direct Charge (`POST /payments/charge`)

USD $29.99
Brand: Visa

Deterministic Card Numbers

Test 8+ dedicated card numbers triggering instant success, insufficient funds (402), generic decline, expired cards, 3DS authentication, and 500 processing errors.

3D Secure 2.0 Challenge Flow

Full support for requires_action state with interactive authorization challenge modal and confirm-3ds endpoint.

Automatic Inbox Receipt Email

When receipt_email is provided, an itemized HTML invoice receipt is dispatched to your virtual Sandbox Inbox (/docs/inbox).

TypeScript SDK & API Integration

1. Direct 1-Step Payment Charge

typescript
1
// 1. Direct Payment Intent Charge with TypeScript SDK
2
import { PlaygroundClient } from 'playground-api';
3
4
const client = new PlaygroundClient({
5
identityToken: 'your_sandbox_token'
6
});
7
8
// Direct Charge Helper (Create & Confirm in 1-step)
9
const payment = await client.payments.charge({
10
amount: 4900, // $49.00 in cents
11
currency: 'usd',
12
cardNumber: '4242424242424242',
13
expMonth: 12,
14
expYear: 2028,
15
cvc: '123',
16
receipt_email: 'buyer@example.com',
17
description: 'Pro Subscription - Monthly'
18
});
19
20
console.log('Status:', payment.status); // 'succeeded'
21
console.log('Payment ID:', payment.id); // 'pi_test_...'

2. 3D Secure Verification Challenge

typescript
1
// 2. Handling 3D Secure Authentication Challenge
2
const intent = await client.payments.confirmIntent('pi_test_12345', {
3
cardNumber: '4000000000000341', // Triggers 3DS challenge
4
expMonth: 12,
5
expYear: 2028,
6
cvc: '123'
7
});
8
9
if (intent.status === 'requires_action') {
10
console.log('Redirecting customer to 3DS Challenge:', intent.next_action?.redirect_to_url?.url);
11
12
// Once customer confirms OTP in iframe/modal:
13
const verifiedIntent = await client.payments.confirm3DS(intent.id);
14
console.log('Verified Status:', verifiedIntent.status); // 'succeeded'
15
}

3. Hosted Checkout Session Creation

typescript
1
// 3. Hosted Checkout Session
2
const session = await client.checkout.createSession({
3
customer_email: 'customer@example.com',
4
mode: 'payment',
5
line_items: [
6
{
7
name: 'Design System Masterclass',
8
amount: 19900, // $199.00
9
quantity: 1,
10
currency: 'usd'
11
}
12
],
13
success_url: 'https://myapp.com/checkout/success?session_id={CHECKOUT_SESSION_ID}',
14
cancel_url: 'https://myapp.com/checkout/canceled'
15
});
16
17
console.log('Redirect user to checkout:', session.url);

4. Issuing Full or Partial Refunds

typescript
1
// 4. Processing Full or Partial Refund
2
const refund = await client.payments.createRefund({
3
payment_intent: 'pi_test_12345',
4
amount: 2500, // $25.00 partial refund (omit for full refund)
5
reason: 'requested_by_customer'
6
});
7
8
console.log('Refund Status:', refund.status); // 'succeeded'
9
console.log('Refund ID:', refund.id); // 're_test_...'

5. cURL Direct Request

bash
1
curl -X POST "https://playground.nileslabs.com/api/v1/payments/charge" \
2
-H "Content-Type: application/json" \
3
-H "X-Playground-Identity: your_session_token" \
4
-d {
5
"amount": 2999,
6
"currency": "usd",
7
"cardNumber": "4242424242424242",
8
"expMonth": 12,
9
"expYear": 2028,
10
"cvc": "123",
11
"receipt_email": "customer@example.com",
12
"description": "Premium License"
13
}

Payment & Checkout Endpoints Reference

MethodEndpointDescription
POST/api/v1/payments/chargeDirect 1-step charge helper (creates & confirms intent).
POST/api/v1/payments/intentsCreate new payment intent (requires_payment_method).
POST/api/v1/payments/intents/:id/confirmConfirm payment intent with test card credentials.
POST/api/v1/payments/intents/:id/confirm-3dsAuthorize and complete 3D Secure verification challenge.
POST/api/v1/payments/intents/:id/cancelCancel uncaptured or pending payment intent.
GET/api/v1/payments/intentsList all sandbox payment intents.
GET/api/v1/payments/intents/:idGet single payment intent by ID.
POST/api/v1/payments/refundsIssue full or partial refund for succeeded payment.
POST/api/v1/checkout/sessionsCreate hosted checkout session with line items.
POST/api/v1/checkout/sessions/:id/completeSimulate customer checkout submission & payment.
POST/api/v1/customersCreate mock customer profile.