Retrieves a list of payment intents for a specific customer. Results are paginated and sorted by creation date, with the most recent payments appearing first.
The API returns paginated results. To fetch additional pages:
const fetchAllPayments = async (customerId) => { let allPayments = []; let hasMore = true; let lastPaymentId = null; while (hasMore) { const params = new URLSearchParams({ userId: customerId, limit: '100' }); if (lastPaymentId) { params.append('starting_after', lastPaymentId); } const response = await fetch(`/api/payments?${params}`); const { data } = await response.json(); allPayments = allPayments.concat(data.data); hasMore = data.has_more; if (hasMore) { lastPaymentId = data.data[data.data.length - 1].id; } } return allPayments;};
The limit parameter is capped at 100. If you pass a value greater than 100, the API will automatically use 100 instead. Non-numeric values will default to 20.