> ## Documentation Index
> Fetch the complete documentation index at: https://docs.juicyway.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch Payment

> Retrieve details of a specific payment by ID

## Overview

The Fetch Payment endpoint allows you to retrieve detailed information about a specific payment using its unique identifier. This is useful for checking payment status, verifying transaction details, or retrieving customer information associated with the payment.

## Endpoint

```bash theme={null}
GET /payments/{id}
```

## Authentication

<Note>
  All requests must include your API key in the Authorization header:

  ```bash theme={null}
  Authorization:  YOUR_API_KEY
  ```
</Note>

## Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier of the payment to retrieve.

  * Format: UUID v4
  * Example: `2315fca8-9aec-42ee-8bee-a9d10add170e`
</ParamField>

## Response Structure

<ResponseField name="data" type="object">
  The payment details object

  <Expandable title="Payment Object">
    <ResponseField name="id" type="string">
      Unique identifier for the payment
    </ResponseField>

    <ResponseField name="amount" type="integer">
      Payment amount in minor units (e.g., cents, kobo)
    </ResponseField>

    <ResponseField name="currency" type="string">
      Three-letter currency code (e.g., NGN, USD)
    </ResponseField>

    <ResponseField name="status" type="string">
      Current status of the payment. One of:

      * pending
      * processing
      * succeeded
      * failed
      * cancelled
    </ResponseField>

    <ResponseField name="customer" type="object">
      Details about the customer who made the payment
    </ResponseField>

    <ResponseField name="payment_method" type="object">
      Information about the payment method used
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.spendjuice.com/payments/2315fca8-9aec-42ee-8bee-a9d10add170e" \
  -H "Authorization:  YOUR_API_KEY" \
  -H "Content-Type: application/json"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.spendjuice.com/payments/2315fca8-9aec-42ee-8bee-a9d10add170e',
    {
      headers: {
        'Authorization': ' YOUR_API_KEY',
        'Content-Type': 'application/json'
      }
    }
  );

  const payment = await response.json();
  ```

  ```python Python theme={null}
  import requests

  headers = {
      'Authorization': ' YOUR_API_KEY',
      'Content-Type': 'application/json'
  }

  response = requests.get(
      'https://api.spendjuice.com/payments/2315fca8-9aec-42ee-8bee-a9d10add170e',
      headers=headers
  )

  payment = response.json()
  ```
</CodeGroup>

## Response Examples

<CodeGroup>
  ```json 200 - Successful Response theme={null}
  {
    "data": {
      "amount": 10000,
      "cancellation_reason": null,
      "correlation_id": "a3f53cea-e05a-11ee-8a6d-8a7019bc5d83",
      "currency": "NGN",
      "customer": {
        "billing_address": {
          "city": "Torphy",
          "country": "NG",
          "line1": "46259 Brekke Adella Rapids",
          "line2": "Suite 304",
          "state": "River",
          "zip_code": "53292"
        },
        "email": "greg_gleichner@hansen.net",
        "first_name": "Murray Inc",
        "id": "53380ca0-b29d-4dd4-8732-8fd518f4a394",
        "last_name": "",
        "phone_number": "+2348023321025"
      },
      "date": "2024-03-12T10:23:59.750724Z",
      "description": "Test",
      "id": "a3f53772-e05a-11ee-9444-8a7019bc5d83",
      "order": {
        "identifier": "Veniam quaerat dolor?",
        "items": [
          {
            "name": "Small Rubber Shoes",
            "type": "digital"
          }
        ]
      }
      "mode": "test",
      "payment_method": {
        "account_name": "Carrie Romaguera Sr.",
        "account_number": "34521736",
        "account_type": "savings",
        "bank_name": "Conn Group",
        "id": "1e140102-3ddc-41d1-aaaf-b101cd195377",
        "type": "bank_account"
      },
      "reference": "Possimus rerum.",
      "status": "pending"
    }
  }
  ```

  ```json 404 - Payment Not Found theme={null}
  {
    "error": {
      "code": "payment_not_found",
      "message": "No payment found with ID: 2315fca8-9aec-42ee-8bee-a9d10add170e"
    }
  }
  ```

  ```json 401 - Unauthorized theme={null}
  {
    "error": {
      "code": "unauthorized",
      "message": "Invalid or missing API key"
    }
  }
  ```
</CodeGroup>

## Error Handling

| Status Code | Description                | Possible Solution                           |
| ----------- | -------------------------- | ------------------------------------------- |
| 401         | Invalid or missing API key | Check your API key and authorization header |
| 403         | Permission denied          | Verify your API key has correct permissions |
| 404         | Payment not found          | Verify the payment ID exists and is valid   |
| 429         | Rate limit exceeded        | Implement exponential backoff               |
| 500         | Internal server error      | Contact support                             |

## Best Practices

<AccordionGroup>
  <Accordion title="Error Handling">
    1. Implement proper error handling for all status codes
    2. Use exponential backoff for retries
    3. Log errors with payment IDs for debugging
    4. Handle network timeouts appropriately
  </Accordion>

  <Accordion title="Security">
    1. Never log complete payment details
    2. Keep API keys secure
    3. Use HTTPS for all API calls
    4. Validate payment IDs before making requests
  </Accordion>

  <Accordion title="Performance">
    1. Cache payment details when appropriate
    2. Implement request timeouts
    3. Monitor API response times
    4. Use connection pooling for multiple requests
  </Accordion>
</AccordionGroup>

## Rate Limits

<Info>
  This endpoint is subject to rate limiting:

  * 100 requests per minute per API key
  * Rate limit info included in response headers:
    * X-RateLimit-Limit
    * X-RateLimit-Remaining
    * X-RateLimit-Reset
</Info>

<Card title="Need Help?">
  For additional assistance:

  * Review our [Error Handling Guide](/errors)
  * Contact [support@juicyway.com](mailto:support@juicyway.com)
</Card>
