Skip to main content

GET /api/payments

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.

Query Parameters

userId
string
required
The Stripe customer ID to retrieve payments for. Must be a valid Stripe customer ID starting with cus_.Example: cus_NffrFeUfNV2Hib
limit
integer
default:"20"
The number of payment intents to return. Maximum value is 100. If not specified, defaults to 20.Example: 50

Response

status
boolean
Indicates if the request was successful
message
string
Human-readable message describing the resultExample: Pagos del usuario obtenidos correctamente
data
object
Stripe’s paginated list response object

Success Response

{
  "status": true,
  "message": "Pagos del usuario obtenidos correctamente",
  "data": {
    "object": "list",
    "data": [
      {
        "id": "pi_3OJxRe2eZvKYlo2C0XYZ1234",
        "object": "payment_intent",
        "amount": 100000,
        "currency": "eur",
        "customer": "cus_NffrFeUfNV2Hib",
        "payment_method": "pm_1Nvmn6LkdIwHu7ix",
        "status": "succeeded",
        "created": 1672531200
      },
      {
        "id": "pi_3OJxRe2eZvKYlo2C0ABC5678",
        "object": "payment_intent",
        "amount": 50000,
        "currency": "eur",
        "customer": "cus_NffrFeUfNV2Hib",
        "payment_method": "pm_1Nvmn6LkdIwHu7ix",
        "status": "succeeded",
        "created": 1672444800
      }
    ],
    "has_more": false,
    "url": "/v1/payment_intents"
  }
}

Error Responses

{
  "status": false,
  "message": "userId es requerido",
  "code": null
}

Code Examples

curl -X GET "https://api.example.com/api/payments?userId=cus_NffrFeUfNV2Hib&limit=50" \
  -H "Authorization: Bearer YOUR_API_KEY"

Pagination

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.

Build docs developers (and LLMs) love