> ## Documentation Index
> Fetch the complete documentation index at: https://beta-developers.mizaniyapay.dz/llms.txt
> Use this file to discover all available pages before exploring further.

# Product Information API: GET /{reference} Endpoint

> The GET endpoint partners must expose for VTPE to retrieve payment details by reference, including response fields and implementation examples.

The Product Information API is the first endpoint you must implement. When a customer initiates a payment through VTPE, the platform calls your server to retrieve the payment details for a specific reference.

## Endpoint

```text theme={null}
GET {API_URL}/{reference}
```

## Authentication

VTPE authenticates each request with the following headers:

| Header          | Value                    |
| --------------- | ------------------------ |
| `Authorization` | `Bearer YOUR_API_SECRET` |
| `X-Timestamp`   | Unix timestamp (seconds) |

Your handler must validate the `Authorization` header before returning any data.

## Path Parameters

<ResponseField name="reference" type="string" required>
  The unique payment reference generated by your system.
</ResponseField>

## Response Fields

<ResponseField name="reference" type="string" required>
  The unique payment reference.
</ResponseField>

<ResponseField name="total_amount" type="number" required>
  The total amount to be paid.
</ResponseField>

<ResponseField name="currency" type="string" required>
  The currency code (for example, DZD).
</ResponseField>

<ResponseField name="amount_detail" type="array" optional>
  Breakdown of the total amount. Each item contains:

  * `label_ar`: Arabic label
  * `label_en`: English label
  * `label_fr`: French label
  * `value`: Amount value
</ResponseField>

<ResponseField name="details" type="array" optional>
  Additional payment details. Each item contains:

  * `label_ar`: Arabic label
  * `label_en`: English label
  * `label_fr`: French label
  * `value`: Detail value
</ResponseField>

## Implementation Examples

<CodeGroup>
  ```javascript Node.js theme={null}
  import express from "express";
  const app = express();
  app.use(express.json());

  app.get("/payments/:reference", (req, res) => {
    const auth = req.headers["authorization"];
    if (auth !== `Bearer ${process.env.VTPE_API_SECRET}`) {
      return res.status(401).json({ error: "UNAUTHORIZED", errorMessage: "Invalid or missing API Secret" });
    }

    const { reference } = req.params;

    // Look up reference in your database
    const order = db.findOrder(reference);

    if (!order) {
      return res.status(404).json({ error: "NOT_FOUND", errorMessage: "Reference not found" });
    }
    if (order.isPaid) {
      return res.status(409).json({ error: "ALREADY_PAID", errorMessage: "Payment already completed" });
    }

    return res.json({
      reference: order.reference,
      total_amount: order.totalAmount,
      currency: order.currency,
      amount_detail: order.amountDetail ?? [],
      details: order.details ?? []
    });
  });
  ```

  ```python Python theme={null}
  from flask import Flask, request, jsonify
  import os

  app = Flask(__name__)

  @app.route("/payments/<reference>")
  def get_payment(reference):
      auth = request.headers.get("Authorization", "")
      if auth != f"Bearer {os.environ['VTPE_API_SECRET']}":
          return jsonify({"error": "UNAUTHORIZED", "errorMessage": "Invalid or missing API Secret"}), 401

      # Look up reference in your database
      order = db.find_order(reference)

      if not order:
          return jsonify({"error": "NOT_FOUND", "errorMessage": "Reference not found"}), 404
      if order.is_paid:
          return jsonify({"error": "ALREADY_PAID", "errorMessage": "Payment already completed"}), 409

      return jsonify({
          "reference": order.reference,
          "total_amount": order.total_amount,
          "currency": order.currency,
          "amount_detail": order.amount_detail or [],
          "details": order.details or []
      })
  ```
</CodeGroup>

## Response Example

```json theme={null}
{
  "reference": "ORD-2024-001",
  "total_amount": 5000.00,
  "currency": "DZD",
  "amount_detail": [
    {
      "label_ar": "المبلغ الأساسي",
      "label_en": "Base Amount",
      "label_fr": "Montant de base",
      "value": 4500.00
    },
    {
      "label_ar": "رسوم التوصيل",
      "label_en": "Delivery Fee",
      "label_fr": "Frais de livraison",
      "value": 500.00
    }
  ],
  "details": [
    {
      "label_ar": "اسم العميل",
      "label_en": "Customer Name",
      "label_fr": "Nom du client",
      "value": "Ahmed Benali"
    }
  ]
}
```

## Error Responses

| HTTP Status | Error Code           | Example Response                                                                      |
| ----------- | -------------------- | ------------------------------------------------------------------------------------- |
| 404         | NOT\_FOUND           | `{"error": "NOT_FOUND", "errorMessage": "Reference not found"}`                       |
| 409         | ALREADY\_PAID        | `{"error": "ALREADY_PAID", "errorMessage": "Payment already completed"}`              |
| 503         | SERVICE\_UNAVAILABLE | `{"error": "SERVICE_UNAVAILABLE", "errorMessage": "Service temporarily unavailable"}` |

For more details on error handling, see the [Errors guide](/concepts/errors).
