# Creación de QR

## Entornos Disponibles

* **Producción**: `https://api.payvalida.com/api/v4/merchants/qr/ligopay`
* **Sandbox**: `https://api-test.payvalida.com/api/v4/merchants/qr/ligopay`

Todas las peticiones deben autenticarse mediante un **checksum** (query parameters), el cual se construye utilizando el algoritmo `SHA-512` con la siguiente estructura:

```
checksum = SHA512(merchant + order + timestamp + fixedhash)
```

Donde:

* `merchant`: Nombre del comercio asignado por Payválida.
* `order`: Identificador único de la orden asignada por el comercio
* `timestamp`: Marca de tiempo en formato ISO 8601 (Ejemplo: 2025-06-09T15:29:35.437Z)
* `fixedhash`: Valor fijo confidencial proporcionado al comercio por Payválida.

{% hint style="danger" %}
Es fundamental mantener el `fixedhash` seguro. No debe ser expuesto en el frontend ni compartido con terceros.
{% endhint %}

***

#### Headers requeridos

```http
Content-Type: application/json
Accept: application/json
```

#### Parámetros de consulta (query parameters)

| Parámetro | Tipo   | Requerido | Descripción                                               |
| --------- | ------ | --------- | --------------------------------------------------------- |
| merchant  | string | Sí        | Identificador del comercio.                               |
| order     | string | Sí        | Identificador único de la orden asignado por el comercio. |
| timestamp | string | Sí        | Marca de tiempo en formato UNIX epoch.                    |
| checksum  | string | Sí        | SHA-512 de `merchant + order + timestamp + fixedhash`.    |

#### Ejemplo de solicitud

```http
GET https://api-test.payvalida.com/api/v4/merchants/qr/ligopay?merchant=kuanto&order=ordenpago123&timestamp=2025-06-09T15:29:35.437Z&checksum=abc123...
Content-Type: application/json
Accept: application/json
```

#### Respuesta exitosa

```json
{
  "CODE": "0000",
  "DESC": "OK",
  "DATA": {
    "hash": "00020101021226370002800103903022025070409211954377000520448295303604540410005802PE5912DEMO LIGOPAY6004Lima80550003ID10144suGASdIEsZFzlFh4eZ"
  }
}
```

#### Campos de la respuesta

* `CODE`: Código de respuesta. `"0000"` indica éxito.
* `DESC`: Descripción del resultado.
* `DATA.hash`: Información con la que debe crearse el código QR.

***

#### Ejemplo en cURL

```bash
curl -X GET "https://api-test.payvalida.com/api/v4/merchants/qr/ligopay?merchant=kuanto&order=ordenpago123&timestamp=2025-06-09T15:29:35.437Z&checksum=abc123... \
  -H "Content-Type: application/json" \
  -H "Accept: application/json"
```

***

### Posibles errores

La API puede responder con los siguientes códigos de error en caso de solicitudes malformadas o fallas internas. Todos los errores mantienen la misma estructura de respuesta, cambiando los valores de `CODE` y `DESC`.

#### Formato de error

```json
{
  "CODE": "0001",
  "DESC": "Invalid body"
}
```

#### Tabla de errores

| CODE | DESC                  | Descripción                                               |
| ---- | --------------------- | --------------------------------------------------------- |
| 0001 | Invalid body          | La estructura de los parámetros enviados no es válida.    |
| 0002 | Internal server error | Error interno del servidor. Intente nuevamente más tarde. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payvalida.com/api-qr-interoperable/metodo/creacion-de-qr.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
