Skip to main content

GET /api/payments/:paymentIntentId

Retrieves detailed information about a specific payment intent by its ID. Use this endpoint to check the status of a payment or retrieve payment details.

Path Parameters

paymentIntentId
string
required
The unique identifier for the payment intent. Must be a valid Stripe payment intent ID starting with pi_.Example: pi_3OJxRe2eZvKYlo2C0XYZ1234

Response

status
boolean
Indicates if the request was successful
message
string
Human-readable message describing the resultExample: Pago obtenido correctamente
data
object
The complete Stripe PaymentIntent object

Success Response

{
  "status": true,
  "message": "Pago obtenido correctamente",
  "data": {
    "id": "pi_3OJxRe2eZvKYlo2C0XYZ1234",
    "object": "payment_intent",
    "amount": 100000,
    "amount_received": 100000,
    "currency": "eur",
    "customer": "cus_NffrFeUfNV2Hib",
    "payment_method": "pm_1Nvmn6LkdIwHu7ix",
    "payment_method_types": ["card"],
    "status": "succeeded",
    "charges": {
      "object": "list",
      "data": [
        {
          "id": "ch_3OJxRe2eZvKYlo2C0ABC5678",
          "object": "charge",
          "amount": 100000,
          "currency": "eur",
          "status": "succeeded",
          "paid": true,
          "refunded": false,
          "amount_refunded": 0
        }
      ],
      "has_more": false
    },
    "latest_charge": "ch_3OJxRe2eZvKYlo2C0ABC5678",
    "created": 1672531200,
    "livemode": false
  }
}

Error Responses

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

Code Examples

curl -X GET https://api.example.com/api/payments/pi_3OJxRe2eZvKYlo2C0XYZ1234 \
  -H "Authorization: Bearer YOUR_API_KEY"

Use Cases

Check Payment Status

const checkPaymentStatus = async (paymentIntentId) => {
  const response = await fetch(`/api/payments/${paymentIntentId}`);
  const { data } = await response.json();
  
  switch (data.status) {
    case 'succeeded':
      console.log('Payment completed successfully!');
      break;
    case 'processing':
      console.log('Payment is being processed...');
      break;
    case 'requires_action':
      console.log('Payment requires customer action');
      break;
    case 'canceled':
      console.log('Payment was canceled');
      break;
    default:
      console.log(`Payment status: ${data.status}`);
  }
  
  return data.status;
};

Get Charge Information

const getChargeInfo = async (paymentIntentId) => {
  const response = await fetch(`/api/payments/${paymentIntentId}`);
  const { data } = await response.json();
  
  if (data.charges.data.length > 0) {
    const charge = data.charges.data[0];
    
    return {
      chargeId: charge.id,
      amount: charge.amount,
      paid: charge.paid,
      refunded: charge.refunded,
      amountRefunded: charge.amount_refunded
    };
  }
  
  return null;
};
This endpoint is useful for polling payment status after creation or confirmation. However, for production applications, it’s recommended to use Stripe webhooks to receive real-time payment updates instead of polling.

Build docs developers (and LLMs) love