# Pagos

![](https://images.unsplash.com/photo-1609429019995-8c40f49535a5?crop=entropy\&cs=tinysrgb\&fm=jpg\&ixid=MnwxOTcwMjR8MHwxfHNlYXJjaHwxfHxwYWdvc3xlbnwwfHx8fDE2NTU4NDQyMDA\&ixlib=rb-1.2.1\&q=80)

## Listar métodos de pago

{% hint style="info" %}
Dentro de la petición se debe especificar el id del usuario que tengas para obtener el listado exitoso de los diferentes recursos de pago que tienes disponibles para compartir al cliente.
{% endhint %}

## Listado

<mark style="color:green;">`POST`</mark> `https://sandbox.apagar.co/api/v1/payments/method/list`

#### Request Body

| Name                                            | Type   | Description               |
| ----------------------------------------------- | ------ | ------------------------- |
| data<mark style="color:red;">\*</mark>          | Object | Datos principales         |
| PaymentMethod<mark style="color:red;">\*</mark> | Object | Método de Pago            |
| type<mark style="color:red;">\*</mark>          | string | Tipo de metodos de pago   |
| User<mark style="color:red;">\*</mark>          | Object | Datos de usuario          |
| id                                              | int    | identificador del usuario |

{% tabs %}
{% tab title="200 Listado generado" %}
{% code title="Request" overflow="wrap" lineNumbers="true" %}

```javascript
{
  "data": {
    "paymentMethods": [
      {
        "id": 4,
        "name": "Credibanco",
        "type": "LINK",
        "icons": [
          {
            "url": "charge/mastercard.png",
            "width": 19
          },
          {
            "url": "charge/visa.png",
            "width": 27
          },
          {
            "url": "charge/american-express.png",
            "width": 35
          }
        ]
      },
      {
        "id": 7,
        "name": "Bancolombia",
        "type": "LINK",
        "icons": [
          {
            "url": "charge/bancolombia.png",
            "width": 84
          }
        ]
      },
      {
        "id": 8,
        "name": "ACH-PSE",
        "type": "LINK",
        "icons": [
          {
            "url": "charge/pse.png",
            "width": 77
          }
        ]
      },
      {
        "id": 9,
        "name": "Contraentrega",
        "type": "LINK",
        "icons": null
      }
    ]
  },
  "signature": null,
  "date": 1623358363596,
  "status": 200,
  "message": "Successful"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request No existen métodos de pago." %}
{% code title="Response" overflow="wrap" lineNumbers="true" %}

```javascript
{
    "signature": null,
    "path": "/method/list",
    "date": 1655***7411513,
    "status": 400,
    "errorCode": "paymentMethod.type.notExist",
    "message": "No existen métodos de pago con el tipo referenciado"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Generar Recurso de pago

Para generar un recurso de pago es necesario observar detenidamente cual opción de pago se quiere generar ya que dependiendo de ello la estructura del ***request*** , será diferente.&#x20;

A continuación algunas recomendaciones para cada uno de las peticiones.

{% hint style="warning" %}
No olvides permanecer con la sesión de tu usuario activa para obtener el resultado de esta petición de manera correcta.
{% endhint %}

{% hint style="info" %}
Para cada Método de pago QR, existe el dinámico y el estático. Lo único que cambia dentro de la petición es que el dinámico tiene el dato de monto y el estático no.
{% endhint %}

{% tabs %}
{% tab title="QR Dinámico Credibanco" %}

```
{
    "data": {
        "PaymentMethod": {
            "id": 1,
            "features": {
                "Commerce": {
                    "Type": {
                        "id": 1
                    },
                    "City": {
                        "id": 898
                    }
                }
            }
        },
        "Bill": {
            "amount": 1000,
            "tax": 19,
            "Products": [
                {
                    "image": "https://cutt.ly/AmSBqyi",
                    "name": "Multiproducto",
                    "amount": 5000,
                    "tax": 8,
                    "description": "100 ml"
                }
            ]
        },
        "description": "Venta multiproducto"
    },
    "_channel": "web",
    "_deviceKey": "laptop"
}
```

{% endtab %}

{% tab title="QR Dinámico Bancolombia" %}

```
{
    "data": {
        "PaymentMethod": {
            "id": 2
        },
        "Bill": {
            "amount": 1000,
            "tax": 19,
            "Products": [
                {
                    "image": "https://cutt.ly/AmSBqyi",
                    "name": "Multiproducto",
                    "amount": 5000,
                    "tax": 8,
                    "description": "100 ml"
                }
            ]
        },
        "description": "Venta multiproducto"
    },
    "_channel": "web",
    "_deviceKey": "laptop"
}
```

{% endtab %}

{% tab title="QR Daviplata" %}

```
{
    "data": {
        "PaymentMethod": {
            "id": 3
        },
        "Bill": {
            "tax": 19,
            "Products": [
                {
                    "image": "https://cutt.ly/AmSBqyi",
                    "name": "Multiproducto",
                    "amount": 5000,
                    "tax": 8,
                    "description": "100 ml"
                }
            ]
        },
        "description": "Venta multiproducto"
    },
    "_channel": "web",
    "_deviceKey": "laptop"
}
```

{% endtab %}
{% endtabs %}

{% hint style="danger" %}
Recuerda que los datos utilizados en las peticiones, son un ejemplo pero no deben ser utilizados.
{% endhint %}

{% tabs %}
{% tab title="Boton Bancolombia" %}

```
{
    "data": {
        "PaymentMethod": {
            "id": 7
        },
        "Bill": {
            "amount": 1000,
            "tax": 19,
            "Products": [
                {
                    "image": "https://cutt.ly/AmSBqyi",
                    "name": "Multiproducto",
                    "amount": 5000,
                    "tax": 8,
                    "description": "100 ml"
                }
            ]
        },
        "description": "Venta multiproducto"
    },
    "_channel": "web",
    "_deviceKey": "laptop"
}
```

{% endtab %}

{% tab title="ACH PSE" %}

```
{
    "data": {
        "PaymentMethod": {
            "id": 8,
              "features": {
                "bank": 1077,
                "typePerson": "person",
                "People": {
                    "docType": "CC",
                    "docNumber": "10538*****",
                    "name": "Julian *****",
                    "cellphone": "3017******",
                    "address": "calle *****" , 
                    "email": "j.***@*****.com"
                }
            }
        },
        "Bill": {
            "amount": 1000,
            "tax": 19,
            "Products": [
                {
                    "image": "https://cutt.ly/AmSBqyi",
                    "name": "Multiproducto",
                    "amount": 5000,
                    "tax": 8,
                    "description": "100 ml"
                }
            ]
        },
        "description": "Venta multiproducto"
    },
    "_channel": "web",
    "_deviceKey": "laptop"
}
```

{% endtab %}

{% tab title="Nequi" %}

```
{
    "data": {
        "PaymentMethod": {
            "id": 10
        },
        "Bill": {
            "amount": 1000,
            "tax": 19,
            "Products": [
                {
                    "image": "https://cutt.ly/AmSBqyi",
                    "name": "Multiproducto",
                    "amount": 5000,
                    "tax": 8,
                    "description": "100 ml"
                }
            ]
        },
        "description": "Venta multiproducto",
        "cellphone": "3174167191"
    },
    "_channel": "web",
    "_deviceKey": "laptop"
}
```

{% endtab %}

{% tab title="Daviplata" %}

```
{
    "data": {
        "PaymentMethod": {
            "id": 11,
            "features": {
                "info": "ey****NOdW1iZXIiOiAiMTM4OTEyMzUyOCIsImRvY1R5cGUiOiAiMDQifQ=="
            }
        },
        "Bill": {
            "amount": 1000,
            "tax": 19,
            "Products": [
                {
                    "image": "https://cutt.ly/AmSBqyi",
                    "name": "Multiproducto",
                    "amount": 5000,
                    "tax": 8,
                    "description": "100 ml"
                }
            ]
        },
        "description": "Venta multiproducto"
    },
    "_channel": "web",
    "_deviceKey": "laptop"
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
Para identificar a tu cliente en la generación del recurso de pago , deberás incluir en tu petición en el object Bill los campos de reference el id de tu cliente , tal como se muestra en la petición inferior ***Generación del recurso*** .

Así podrás identificar quien realizó la transferencia .
{% endhint %}

## Generación del recurso

<mark style="color:green;">`POST`</mark> `https://sandbox.apagar.co/api/v1/payments/resource/generate`

#### Request Body

| Name                                            | Type   | Description                                                             |
| ----------------------------------------------- | ------ | ----------------------------------------------------------------------- |
| data<mark style="color:red;">\*</mark>          | Object | Datos principales                                                       |
| PaymentMethod<mark style="color:red;">\*</mark> | Object | Método de Pago                                                          |
| id<mark style="color:red;">\*</mark>            | int    | Id del método o canal de pago                                           |
| features<mark style="color:red;">\*</mark>      | Object | Objeto con todas las características adicionales para el método de pago |
| Commerce                                        | Object | Objeto para tipo de comercio                                            |
| type                                            | Object | Objeto del tipo                                                         |
| id                                              | int    | id del metodo de pago                                                   |
| City                                            | Object | objeto de ciudad                                                        |
| id                                              | int    | id de ciudad                                                            |
| Bill                                            | object | Bill data                                                               |
| amount                                          | int    | Valor del recurso a generar                                             |
| tax                                             | int    | IVA o impuesto del recurso a generar                                    |
| Products                                        | Object | lista donde cada objeto representara un producto                        |
| image                                           | string | Ruta donde se aloja la imagen                                           |
| name                                            | string | Nombre del producto                                                     |
| amount                                          | int    | Valor del producto                                                      |
| tax                                             | int    | impuesto del producto                                                   |
| description                                     | string | descripción del producto                                                |
| cellphone                                       | string | Numero del celular del cliente.                                         |
| Reference                                       | String | Id del cliente                                                          |

{% tabs %}
{% tab title="200 Recurso generado" %}
{% code title="Request" overflow="wrap" lineNumbers="true" %}

```javascript
{
    "data": {
        "PaymentMethod": {
            "id": 5
        },
        "Bill": {
            "tax": 19,
            "Products": [
                {
                    "image": "https://cutt.ly/AmSBqyi",
                    "name": "Multiproducto",
                    "amount": 5000,
                    "tax": 8,
                    "description": "100 ml"
                }
            ],
        "reference1": "reference1",
        "reference2": "reference2",
        "reference3": "reference3"
        },
        "description": "Venta multiproducto"
    },
    "_channel": "web",
    "_deviceKey": "laptop"
}
```

{% endcode %}

{% code title="Response" overflow="wrap" lineNumbers="true" %}

```javascript
{
    "data": {
        "Resource": {
            "id": 3698,
            "type": "SHARE",
            "data": "cc6****95d1e6c80ce1f6",
            "url": "https://sandbox.apagar.co/pagar/cc6a95d1e6c80ce1f6",
            "reference": "ccc6****95d1e6c80***f6",
            "createdAt": "2022-06-02 22:06:20",
            "expDate": "2022-06-02 22:26:20"
        }
    },
    "signature": "****533654a7854789487e7792dd6ed1d3326c7e",
    "date": 1654225580****,
    "status": 200,
    "message": "Successful"
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized Sesión terminada" %}
{% code title="Response" overflow="wrap" lineNumbers="true" %}

```javascript
{ 
"signature": null, 
"path": "/resource/generate", 
"date": 1655855799157, 
"status": 401, "errorCode": "auth.sessionEnded", 
"message": "Sesión terminada" 
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request No existe el método de pago asociado al usuario" %}
{% code title="Response" overflow="wrap" lineNumbers="true" %}

```javascript
{
    "signature": "85fd728f9f9f1ad09ced06e0e8b4606c912ec470",
    "path": "/resource/generate",
    "date": 1657036055908,
    "status": 400,
    "errorCode": "transaction.cost.notSupport",
    "message": "No existe un costo soportado"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Generar recurso link de pago

{% hint style="info" %}
Este recurso de pago generado a través de un link nos permite compartirlo al cliente a través de whatssap para así brindar mas opciones a nuestro cliente.&#x20;
{% endhint %}

## Generación del link del recurso de pago

<mark style="color:green;">`POST`</mark> `https://sandbox.apagar.co/api/v1/payments/resource/generate`

#### Request Body

| Name                                            | Type   | Description                                                             |
| ----------------------------------------------- | ------ | ----------------------------------------------------------------------- |
| data<mark style="color:red;">\*</mark>          | Object | Datos principales                                                       |
| PaymentMethod<mark style="color:red;">\*</mark> | Object | Método de Pago                                                          |
| id<mark style="color:red;">\*</mark>            | int    | Id del método o canal de pago                                           |
| features<mark style="color:red;">\*</mark>      | Object | Objeto con todas las características adicionales para el método de pago |
| Resource<mark style="color:red;">\*</mark>      | Object | Resource data                                                           |
| id<mark style="color:red;">\*</mark>            | int    | id del recurso de pago                                                  |
| User<mark style="color:red;">\*</mark>          | Object | Dato de usuario                                                         |
| id<mark style="color:red;">\*</mark>            | int    | id de usuario o comercio                                                |
| typePerson<mark style="color:red;">\*</mark>    | String | Natural o jurídica                                                      |
| bank                                            | int    | id banco                                                                |
| docType<mark style="color:red;">\*</mark>       | String | Tipo de documento                                                       |

{% tabs %}
{% tab title="200 Recurso generado" %}
{% code title="Request" overflow="wrap" lineNumbers="true" %}

```javascript
{
  "data": {
    "reference": 6
  },
  "signature": "****06c9118b613bd3fb2aece63a5762c1c2d9e6",
  "date": 163355295****,
  "status": 200,
  "message": "Successful"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Transacción finalizada" %}
{% code title="Response" overflow="wrap" lineNumbers="true" %}

```javascript
{
    "signature": "59c075fae7929a260758ae0e95634c10fc93eadc",
    "path": "/resource/get/web-page/checkout",
    "date": 1655857554312,
    "status": 400,
    "errorCode": "transaction.progress",
    "message": "Ya tienes una transacción pendiente o finalizada para este recurso de pago. Completa el pago o vuelve a intentarlo más tarde"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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://tecnologia-superpagos.gitbook.io/refacil-api-doc/reference-apis/api-refacil-pay/pagos.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.
