Skip to content

402 Payment Required

Rarely used, originally intended for digital micro-payments. Now used by some APIs (like Stripe) to indicate failed payments or exceeded quotas.

Mostly experimental, but you can use this if a user tries to use your API but they have exhausted their prepaid credits or their subscription payment failed.

import { HttpException, get } from 'shokupan';
export const getResource = get('/resource', () => {
throw new HttpException('Payment Required', 402);
});