> For the complete documentation index, see [llms.txt](https://api-comercio.gitbook.io/api-comercios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-comercio.gitbook.io/api-comercios/reference/api-reference/qr.md).

# QR

Mostrá el QR del comercio con o sin monto.

## Generar qr estático sin monto

<mark style="color:green;">`GET`</mark>  /api/paymentQr

#### Headers

| Key          | Value            |
| ------------ | ---------------- |
| Content-Type | application/json |
| apikey       | su\_api\_key     |
| X-TRACE-ID   | uuidv4()         |
| X-VERSION    | 1                |

#### Request Body

```javascript
{}
```

## Generar qr dinámico con monto

<mark style="color:green;">`POST`</mark>  /api/paymentQr

#### Request Body

<table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-postman_json" data-full-width="true"><code class="lang-postman_json">totalAmount
</code></pre></td><td>number</td><td>monto del qr</td></tr></tbody></table>

**Response**&#x20;

{% tabs %}
{% tab title="200 OK" %}

```javascript
// response.successUrl será su link de pago

{
    "success": "ok",
    "data": {
        "id": "number",
        "imgUrl": "string",
        "qrString": "string",
        "subscriptionUrl": "string",
        "hash": "string"
    },
    "whatsappUrl": "string",
    "facebookUrl": "string"
}
```

{% endtab %}

{% tab title="400 Bad Request" %}

```json
// Si no se envía 'amount'

{
    "statusText": "Bad Request",
    "jsonSchemaValidation": true,
    "validations": {
        "body": [
            {
                "keyword": "string",
                "dataPath": "string",
                "schemaPath": "string",
                "params": {
                    "missingProperty": "string"
                },
                "message": "string"
            }
        ]
    }
}
```

{% endtab %}

{% tab title="401 Unauthorized" %}

```javascript
// Si apikey no es enviado en el Headers: 
{"message":"Missing API key found in request"}

// Si apikey es enviada de forma errónea:
{"message":"Invalid API key in request"}

```

{% endtab %}

{% tab title="500 Internal Server Error" %}

```javascript
// Error de parámetros

{
   "status": 500,
   "message": "status 500",
   "timestamp": "2024-05-28T12:30:04Z"
}
```

{% endtab %}
{% endtabs %}

Aquí algunos ejemplos de peticiones:

{% tabs %}
{% tab title="cURL" %}

```
curl --location 'http://api-gwt.sipago.online/services/api/paymentButtonsToken' \
--header 'apikey: su_api_key' \
--header 'X-TRACE-ID: uuidv4()' \
--header 'X-VERSION: 1' \
--header 'Content-Type: application/json' \
--data '{"amount": 100, "description": "coca-cola"}'
```

{% endtab %}

{% tab title="NodeJs - Axios" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "amount": 100,
  "description": "coca-cola"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'http://api-gwt.sipago.online/services/api/paymentButtonsToken',
  headers: { 
    'apikey': 'su_api_key', 
    'X-TRACE-ID': 'uuid', 
    'X-VERSION': '100', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python - Requests" %}

```python
import requests
import json

url = "http://api-gwt.sipago.online/services/api/paymentButtonsToken"

payload = json.dumps({
  "amount": 100,
  "description": "coca-cola"
})
headers = {
  'apikey': 'su_api_key',
  'X-TRACE-ID': 'uuid',
  'X-VERSION': '100',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}
{% endtabs %}
