refacil-pay-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,931 @@
1
+ # refacil-pay MCP Server
2
+
3
+ Servidor MCP (Model Context Protocol) generado automáticamente para la API refacil-pay.
4
+
5
+ ## 🚀 Características
6
+
7
+ - **21 herramientas** generadas automáticamente desde la colección Postman
8
+ - **Autenticación flexible**: Sin autenticación
9
+ - **Servidor HTTP** con Fastify
10
+ - **Protocolo MCP** estándar para integración con IDEs
11
+
12
+ ## 📋 Requisitos
13
+
14
+ - Node.js 20+
15
+ - npm o yarn
16
+
17
+ ## 📦 Instalación desde NPM
18
+
19
+ Si este paquete está publicado en npm, puedes instalarlo globalmente:
20
+
21
+ ```bash
22
+ # Instalación global (recomendado)
23
+ npm install -g refacil-pay-mcp
24
+
25
+ # Verificar instalación
26
+ refacil-pay-mcp --version
27
+ ```
28
+
29
+ ### Configuración Rápida en IDEs
30
+
31
+ #### Cursor
32
+
33
+ 1. Abrir **Settings** → **Features** → **Model Context Protocol**
34
+ 2. Click en **"Edit Config"**
35
+ 3. Agregar:
36
+
37
+ **Windows**: `%APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json`
38
+
39
+ **macOS/Linux**: `~/.config/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
40
+
41
+ ```json
42
+ {
43
+ "mcpServers": {
44
+ "refacil-pay": {
45
+ "command": "refacil-pay-mcp",
46
+ "env": {
47
+ "BASE_URL": "https://pay-api.qa.refacil.co",
48
+
49
+ }
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ 4. Reiniciar Cursor
56
+
57
+ #### Claude Desktop
58
+
59
+ Editar archivo de configuración:
60
+
61
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
62
+
63
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
64
+
65
+ **Linux**: `~/.config/Claude/claude_desktop_config.json`
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "refacil-pay": {
71
+ "command": "refacil-pay-mcp",
72
+ "env": {
73
+ "BASE_URL": "https://pay-api.qa.refacil.co",
74
+
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ Reiniciar Claude Desktop.
82
+
83
+ #### Visual Studio Code
84
+
85
+ 1. Instalar extensión **MCP for VS Code**
86
+ 2. Editar `settings.json`:
87
+
88
+ ```json
89
+ {
90
+ "mcp.servers": {
91
+ "refacil-pay": {
92
+ "command": "refacil-pay-mcp",
93
+ "env": {
94
+ "BASE_URL": "https://pay-api.qa.refacil.co",
95
+
96
+ }
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ 3. Recargar VS Code
103
+
104
+ ## 🛠️ Instalación para Desarrollo
105
+
106
+ Si quieres contribuir o ejecutar desde el código fuente:
107
+
108
+ ```bash
109
+ # Clonar el repositorio
110
+ git clone https://github.com/refacil/refacil-pay-mcp.git
111
+ cd refacil-pay-mcp
112
+
113
+ # Instalar dependencias
114
+ npm install
115
+
116
+ # Construir el proyecto
117
+ npm run build
118
+
119
+ # Iniciar en desarrollo
120
+ npm run dev
121
+
122
+ # Iniciar en producción
123
+ npm start
124
+ ```
125
+
126
+ ## 🔧 Configuración
127
+
128
+ El servidor se configura mediante variables de entorno:
129
+
130
+ ```bash
131
+ # Copiar archivo de ejemplo
132
+ cp .env.example .env
133
+
134
+ # Editar configuración
135
+ nano .env
136
+ ```
137
+
138
+ ### Variables de Entorno
139
+
140
+ | Variable | Descripción | Valor por defecto |
141
+ |----------|-------------|-------------------|
142
+ | `PORT` | Puerto del servidor | `3009` |
143
+ | `ENVIRONMENT` | Entorno de ejecución | `development` |
144
+ | `BASE_URL` | URL base de la API | `https://pay-api.qa.refacil.co` |
145
+
146
+
147
+ | `MCP_TOKEN` | Token de autenticación del MCP | `mcp-secret-token-refacil-pay` |
148
+
149
+ ## 🐳 Docker
150
+
151
+ ```bash
152
+ # Construir imagen
153
+ docker build -t refacil-pay-mcp .
154
+
155
+ # Ejecutar contenedor
156
+ docker run -p 3009:3009 refacil-pay-mcp
157
+
158
+ # O usar docker-compose
159
+ docker-compose up
160
+ ```
161
+
162
+ ## ☸️ Kubernetes
163
+
164
+ ```bash
165
+ # Aplicar manifests
166
+ kubectl apply -f k8s/
167
+
168
+ # Verificar despliegue
169
+ kubectl get pods -l app=refacil-pay-mcp
170
+ ```
171
+
172
+ ## 🔌 Uso del MCP
173
+
174
+ ### Endpoints Disponibles
175
+
176
+ - **`/mcp`**: Endpoint principal del protocolo MCP
177
+ - **`/health`**: Health check del servidor
178
+ - **`/tools`**: Lista de herramientas disponibles
179
+
180
+ ### Modo Multi-Usuario (HTTP)
181
+
182
+ El servidor MCP soporta **múltiples usuarios simultáneamente** en modo HTTP mediante el header `X-Secret-ID`.
183
+
184
+ #### ¿Cómo funciona?
185
+
186
+ 1. **Sin `X-Secret-ID`**: Usa el `SECRET_ID` del archivo `.env` (modo single-user)
187
+ 2. **Con `X-Secret-ID`**: Usa el secretId proporcionado en el header (modo multi-user)
188
+
189
+ #### Ejemplo de uso:
190
+
191
+ ```bash
192
+ # Usuario 1
193
+ curl -X POST http://localhost:3009/mcp \
194
+ -H "Authorization: Bearer mcp-token" \
195
+ -H "X-Secret-ID: user1-secret-id" \
196
+ -H "Content-Type: application/json" \
197
+ -d '{"method": "tools/call", "params": {...}}'
198
+
199
+ # Usuario 2
200
+ curl -X POST http://localhost:3009/mcp \
201
+ -H "Authorization: Bearer mcp-token" \
202
+ -H "X-Secret-ID: user2-secret-id" \
203
+ -H "Content-Type: application/json" \
204
+ -d '{"method": "tools/call", "params": {...}}'
205
+ ```
206
+
207
+ #### Ventajas del Modo Multi-Usuario:
208
+
209
+ - ✅ Cada usuario usa sus propias credenciales
210
+ - ✅ Tokens cacheados por secretId (mejor performance)
211
+ - ✅ Un solo servidor para múltiples clientes
212
+ - ✅ Compatible con modo single-user (fallback al .env)
213
+
214
+ #### Configuración para HTTP Multi-Usuario:
215
+
216
+ ```bash
217
+ # .env
218
+ BASE_URL=https://pay-api.qa.refacil.co
219
+ AUTH_ENDPOINT=/auth/login
220
+ TOKEN_CACHE_TTL=3600
221
+ MCP_TOKEN=your-mcp-token
222
+
223
+ # SECRET_ID es opcional en HTTP mode
224
+ # Si no se proporciona, DEBE enviarse via header X-Secret-ID
225
+ ```
226
+
227
+ ### Configuración en IDEs
228
+
229
+ #### Cursor
230
+ ```json
231
+ {
232
+ "mcpServers": {
233
+ "refacil-pay-mcp": {
234
+ "command": "node",
235
+ "args": ["/ruta/a/refacil-pay-mcp/dist/index.js"],
236
+ "env": {
237
+ "MCP_TOKEN": "tu-token-secreto"
238
+ }
239
+ }
240
+ }
241
+ }
242
+ ```
243
+
244
+ #### Visual Studio Code
245
+ Configurar en la extensión MCP con:
246
+ - **Command**: `node`
247
+ - **Args**: `["/ruta/a/refacil-pay-mcp/dist/index.js"]`
248
+ - **Env**: `{"MCP_TOKEN": "tu-token-secreto"}`
249
+
250
+ ## 🛠️ Herramientas Disponibles
251
+
252
+ - **`auth_login`**: | **Name** | **Type** | **Description** |
253
+ | --- | --- | --- |
254
+ | **username** \* | string | User |
255
+ | **password** \* | string | Password |
256
+ - **`trx_token_generate`**: | **Name** | **Type** | **Description** |
257
+ | --- | --- | --- |
258
+ | **service** \* | string | Value of the service to be consumed |
259
+ - **`trx_token_generate_3`**: | **Name** | **Type** | **Description** |
260
+ | --- | --- | --- |
261
+ | **service** \* | string | Value of the service to be consumed |
262
+ - **`trx_token_generate_4`**: | **Name** | **Type** | **Description** |
263
+ | --- | --- | --- |
264
+ | **service** \* | string | Value of the service to be consumed |
265
+ - **`trx_token_generate_5`**: | **Name** | **Type** | **Description** |
266
+ | --- | --- | --- |
267
+ | **service** \* | string | Value of the service to be consumed |
268
+ - **`trx_token_generate_6`**: | **Name** | **Type** | **Description** |
269
+ | --- | --- | --- |
270
+ | **service** \* | string | Value of the service to be consumed |
271
+ - **`cash_in_generate_payment_link_token`**: ## 📥 Request Body Parameters
272
+
273
+ | **Field** | **Type** | **Required** | **Description** |
274
+ | --- | --- | --- | --- |
275
+ | `amount` | number | ✅ | Value of the payment. |
276
+ | `brandId` | number | ❌ | ID of the customer's white label; if one is not available, the default ID 79 is sent. |
277
+ | `expiresIn` | number | ❌ | Time in minutes for the expiration of the resource or payment link. |
278
+ | `reference1` | string | ✅ | Customer identifier, must be between 1 and 30 characters. |
279
+ | `reference2` | object | ❌ | Object for additional information. |
280
+ | `reference2.Commerce` | object | ❌ | Object for information related to the store or commerce. |
281
+ | `reference2.Data` | object | ❌ | Object for information related to the conciliation of the transaction. |
282
+ | `reference2.Label` | object | ❌ | Object to send information to be displayed in the payment summary. |
283
+ | `returnUrl` | string | ❌ | Link that the customer will see when clicking on the back to commerce button. |
284
+ | `showSummary` | boolean | ❌ | Indicates whether the RefácilPay payment summary will be shown or not (false: do not show, true: show). Default: true. |
285
+ | `userMetadata` | object | ✅ | Object containing key details about the user or merchant generating the payment resource. |
286
+ | `userMetadata.identifier` | string | ✅ | Unique identifier of the user or merchant generating the payment resource (max 36 characters). |
287
+ | `userMetadata.ip` | string | ✅ | IP address associated with the user's identifier. Must be a valid IP address. |
288
+ | `userMetadata.urlCommerce` | string | ✅ | URL that identifies the commerce. Must follow valid URL structure with http:// or https:// protocol. Maximum length: 500 characters. |
289
+ | `webhookUrl` | string | ✅ | URL of the client's webhook to receive real-time payment status updates. |
290
+
291
+ - **`cash_in_generate_payment_method_token`**: This endpoint allows you to **generate payment requests** through the available _cash-in_ methods.
292
+
293
+ ---
294
+
295
+ ### 💡 Overview
296
+
297
+ The table below lists the available payment methods along with their corresponding IDs and **minimum expiration times** (`expiresIn`) required when creating a payment request.
298
+
299
+ | **Method ID** | **Description** | **Minimum Expiration (seconds)** |
300
+ | --- | --- | --- |
301
+ | `130` | Cash-in via **Nequi** | 43,200 |
302
+ | `131` | Cash-in via **Daviplata** | 43,200 |
303
+ | `133` | Cash-in via **PSE** | 1,800 |
304
+ | `262` | Cash-in via **PSE Gateway** | 1,800 |
305
+ | `134` | Cash-in via **IPay** | 43,200 |
306
+ | `153` | Cash-in via **Recaudo Efectivo** | 86,400 |
307
+ | `155` | Cash-in via **Transfiya Recaudo** | 43,200 |
308
+ | `163` | Cash-in via **TPaga** | 43,200 |
309
+ | `248` | Cash-in via **QR Interoperable** | N/A |
310
+
311
+ > ⚠ **Important:**
312
+ The value provided in the `expiresIn` field **must be greater than or equal** to the minimum expiration defined for the selected payment method.
313
+
314
+
315
+ ---
316
+
317
+ ## 🧩 Payment Method Details
318
+
319
+ Each payment method requires a specific object structure within the `"paymentMethod"` field.
320
+
321
+ ---
322
+
323
+ ### **Nequi**
324
+
325
+ ``` json
326
+ "paymentMethod": {
327
+ "id": 130,
328
+ "cellphone": "3105293225"
329
+ }
330
+
331
+ ```
332
+
333
+ ---
334
+
335
+ ### **Daviplata**
336
+
337
+ ``` json
338
+ "paymentMethod": {
339
+ "id": 131,
340
+ "cellphone": "3208385715"
341
+ }
342
+
343
+ ```
344
+
345
+ ---
346
+
347
+ ### **PSE**
348
+
349
+ For this payment method, depending on the `typePerson` selected, only specific document types are accepted:
350
+
351
+ - **`typePerson`****:** **`"0"`** → corresponds to a **Natural Person** and only accepts the following values for `documentType`:
352
+
353
+ - `RCN`
354
+
355
+ - `TI`
356
+
357
+ - `CC`
358
+
359
+ - `TE`
360
+
361
+ - `CE`
362
+
363
+ - `PA`
364
+
365
+ - `DIE`
366
+
367
+ - **`typePerson`****:** **`"1"`** → corresponds to a **Legal Person** and only accepts the following value for `documentType`:
368
+
369
+ - `NIT`
370
+
371
+
372
+ ``` json
373
+ "paymentMethod": {
374
+ "id": 133,
375
+ "documentType": "CC",
376
+ "typePerson": "0",
377
+ "bankId": "string",
378
+ "documentNumber": "string",
379
+ "name": "string",
380
+ "cellphone": "string",
381
+ "address": "string",
382
+ "email": "string"
383
+ }
384
+
385
+ ```
386
+
387
+ ---
388
+
389
+ ### **PSE Gateway**
390
+
391
+ This payment method enables direct integration with the PSE network for processing online bank payments.
392
+ To consume this product, it is required to have the following parameters previously configured and associated with your product:
393
+
394
+ - `entity_code`
395
+
396
+ - `service_code`
397
+
398
+ - `company_ciiu`
399
+
400
+ - `company_name`
401
+
402
+
403
+ These parameters identify your company within the PSE network and are necessary for successful transaction routing and validation.
404
+
405
+ > 💬 **For more information or to request these credentials, please contact the support team.**
406
+
407
+
408
+ This method follows **the same structure and validation rules** as **PSE**, but must use the following identifier:
409
+
410
+ ``` json
411
+ "paymentMethod": {
412
+ "id": 262,
413
+ "documentType": "CC",
414
+ "typePerson": "0",
415
+ "bankId": "string",
416
+ "documentNumber": "string",
417
+ "name": "string",
418
+ "cellphone": "string",
419
+ "address": "string",
420
+ "email": "string"
421
+ }
422
+
423
+ ```
424
+
425
+ The **PSE integration** relies heavily on the correct configuration of the `showSummary` and `returnUrl` parameters.
426
+ These parameters control the **user experience** and the **finalization flow** of the payment process.
427
+
428
+ | Scenario | `showSummary` | `returnUrl` | Flow Description |
429
+ | --- | --- | --- | --- |
430
+ | **1\. Standard Redirect (Default)** | `true` or not sent | ✅ Present | Displays a transaction summary screen with key payment details and retrieves the final transaction status. After the payment is completed, the user is redirected to the specified `returnUrl`. |
431
+ | **2\. Without Transaction Summary Screen** | `false` | ✅ Present | Skips the transaction summary screen and redirects the user directly to the `returnUrl`. In this case, the merchant’s system must display the transaction summary on the destination page. |
432
+
433
+ > ⚠️ **Note:**
434
+ For **PSE** and **PSE Gateway**, it is **strongly recommended** to use `showSummary: true` along with a valid `returnUrl` to ensure a seamless customer experience and accurate transaction tracking.
435
+
436
+ > 🔗 **See also:**
437
+
438
+
439
+ - [Transaction Summary](https://documenter.getpostman.com/view/35146358/2sA3QpDEFA#45e0d76a-fabd-442e-9b17-e2f6b8354ec5)
440
+
441
+ - [Transaction Status](https://documenter.getpostman.com/view/35146358/2sA3QpDEFA#dd3ba9f5-1f10-4109-b59d-6e5aad5e3799)
442
+
443
+
444
+ ---
445
+
446
+ ### **IPay**
447
+
448
+ ``` json
449
+ "paymentMethod": {
450
+ "id": 134
451
+ }
452
+
453
+ ```
454
+
455
+ ---
456
+
457
+ ### **Recaudo Efectivo**
458
+
459
+ ``` json
460
+ "paymentMethod": {
461
+ "id": 153
462
+ }
463
+
464
+ ```
465
+
466
+ ---
467
+
468
+ ### **Transfiya Recaudo**
469
+
470
+ ``` json
471
+ "paymentMethod": {
472
+ "id": 155,
473
+ "cellphone": "3105293225"
474
+ }
475
+
476
+ ```
477
+
478
+ ---
479
+
480
+ ### **TPaga**
481
+
482
+ This payment method supports an optional parameter called `isQr`, which determines the type of resource returned in the `url` field:
483
+
484
+ | **Value** | **Description** |
485
+ | --- | --- |
486
+ | `true` | The `url` field returns a link to a **QR code** displaying transaction details. |
487
+ | `false` | The `url` field returns a **deeplink** to open directly in the TPAGA wallet app. |
488
+
489
+ > 🧠 **Behavior:**
490
+ If `isQr` is not provided, the default behavior is equivalent to `isQr: false`.
491
+ Transactions can only be completed **from a mobile device**.
492
+ If the request is made from a desktop or tablet, it is recommended to send `isQr: true` so the user can scan the QR from a mobile device.
493
+
494
+
495
+ ``` json
496
+ "paymentMethod": {
497
+ "id": 163,
498
+ "isQr": false
499
+ }
500
+
501
+ ```
502
+
503
+ ---
504
+
505
+ ### **QR Interoperable**
506
+
507
+ For this method, the following fields are **optional**:
508
+
509
+ - `cellphone`
510
+
511
+ - `documentNumber`
512
+
513
+ - `documentType`
514
+
515
+ - `merchantId`
516
+
517
+
518
+ The service can function using only the payment method ID; however, providing these optional fields can **improve response time**.
519
+ You may retrieve this data through the `enrollment-data` service in the [Merchant Enrollment](https://documenter.getpostman.com/view/35146358/2sA3QpDEFA#8c9f5a18-a19a-4b8f-baba-cd7501aa29a0) section.
520
+
521
+ > ⚠ **Prerequisite:**
522
+ The merchant must complete the **Merchant Enrollment** process before using this method.
523
+ See the _Merchant Enrollment_ section for setup details.
524
+
525
+ > 🔁 **Open Resource:**
526
+ The **QR Interoperable** operates as an _open resource_, meaning the generated QR can be used multiple times by the same user.
527
+
528
+ > ⚙️ **Technical Note — Dynamic QR Behavior:**
529
+ Dynamic QR codes may be scanned multiple times due to current limitations in the Redeban system.
530
+ This is **not** an error in our platform.
531
+
532
+
533
+ #### Behavior Details
534
+
535
+ - Redeban does not automatically invalidate a dynamic QR after its first scan.
536
+
537
+ - As a result, the same QR may generate multiple transaction records.
538
+
539
+
540
+ #### Recommendations
541
+
542
+ - Implement **application-level validation** to detect multiple payments from the same QR code.
543
+
544
+ - Monitor dynamic QR transactions and confirm status before marking payments as completed.
545
+
546
+ - Inform end-users to verify the success of a transaction before rescanning.
547
+
548
+
549
+ #### Future Considerations
550
+
551
+ - Redeban is evaluating support for **single-use dynamic QR control**.
552
+
553
+ - Stay updated with interoperability provider announcements to adjust integrations accordingly.
554
+
555
+
556
+ ``` json
557
+ "paymentMethod": {
558
+ "id": 248,
559
+ "cellphone": "string",
560
+ "documentType": "string",
561
+ "documentNumber": "string",
562
+ "merchantId": "string"
563
+ }
564
+
565
+ ```
566
+
567
+ ---
568
+
569
+ ## 📥 Request Body Parameters
570
+
571
+ | **Field** | **Type** | **Required** | **Description** |
572
+ | --- | --- | --- | --- |
573
+ | `amount` | number | ✅ | Value of the payment. |
574
+ | `brandId` | number | ❌ | ID of the customer's white label; if one is not available, the default ID 79 is sent. |
575
+ | `expiresIn` | number | ❌ | Time in seconds for the expiration of the resource or payment link. |
576
+ | `paymentMethod` | object | ✅ | Object specifying the payment method and its details. |
577
+ | `paymentMethod.id` | number | ✅ | ID of the selected payment method (see available payment methods). |
578
+ | `reference1` | string | ✅ | Customer identifier, must be between 1 and 30 characters. |
579
+ | `reference2` | object | ❌ | Object for additional information. |
580
+ | `reference2.Commerce` | object | ❌ | Object for information related to the store or commerce. |
581
+ | `reference2.Data` | object | ❌ | Object for information related to the conciliation of the transaction. |
582
+ | `reference2.Label` | object | ❌ | Object to send information to be displayed in the payment summary. |
583
+ | `returnUrl` | string | ❌ | Link that the customer will see when clicking on the back to commerce button. |
584
+ | `showSummary` | boolean | ❌ | Indicates whether the RefácilPay payment summary will be shown or not (false: do not show, true: show). Default: true. |
585
+ | `userMetadata` | object | ✅ | Object containing key details about the user or merchant generating the payment resource. |
586
+ | `userMetadata.identifier` | string | ✅ | Unique identifier of the user or merchant generating the payment resource (max 36 characters). |
587
+ | `userMetadata.ip` | string | ✅ | IP address associated with the user's identifier. Must be a valid IP address. |
588
+ | `userMetadata.urlCommerce` | string | ✅ | URL that identifies the commerce. Must follow valid URL structure with http:// or https:// protocol. Maximum length: 500 characters. |
589
+ | `webhookUrl` | string | ✅ | URL of the client's webhook to receive real-time payment status updates. |
590
+ - **`cash_out_generate_withdraw_method_token`**: This endpoint allows you to **generate withdrawal (cash-out) requests** through the available payout methods.
591
+
592
+ ---
593
+
594
+ ### 💡 Overview
595
+
596
+ The table below lists the available payout methods along with their corresponding IDs and brief descriptions.
597
+
598
+ | **Method ID** | **Description** |
599
+ | --- | --- |
600
+ | `245` | Cash-out via **Transfiya** |
601
+ | `264` | Cash-out via **Bre-B** |
602
+
603
+ > ⚠ **Note:**
604
+ Each withdrawal method requires a specific object structure within the `"withdrawMethod"` field, as shown below.
605
+
606
+
607
+ ---
608
+
609
+ ## 🧩 Payout Method Details
610
+
611
+ ### **Transfiya**
612
+
613
+ ``` json
614
+ "withdrawMethod": {
615
+ "id": 245,
616
+ "cellphone": "3125763074"
617
+ }
618
+
619
+ ```
620
+
621
+ **Description:**
622
+ Transfers funds to a recipient using their registered Transfiya cellphone number.
623
+
624
+ > ⚠ **Important:**
625
+ Ensure the cellphone number is registered with Transfiya and capable of receiving funds.
626
+
627
+
628
+ ---
629
+
630
+ ### **Bre-B**
631
+
632
+ ``` json
633
+ "withdrawMethod": {
634
+ "id": 264,
635
+ "key": "@REPRUEBAL7717"
636
+ }
637
+
638
+ ```
639
+
640
+ **Description:**
641
+ Transfers funds directly to a Bre-B account using the beneficiary’s unique Bre-B key.
642
+
643
+ > 💡 **Tip:**
644
+ The `key` field must contain a valid Bre-B account alias in the format `@USERNAME`.
645
+
646
+
647
+ ---
648
+
649
+ ## 📥 Request Body Parameters
650
+
651
+ | **Field** | **Type** | **Required** | **Description** |
652
+ | --- | --- | --- | --- |
653
+ | `amount` | number | ✅ | Amount to be withdrawn. |
654
+ | `reference1` | string | ✅ | Unique transaction reference generated by the client (max 20 characters). |
655
+ | `webhookRequest` | string | ✅ | Customer’s webhook URL to receive real-time withdrawal status updates. |
656
+ | `userMetadata` | object | ✅ | Object containing metadata related to the origin of the transaction. |
657
+ | `userMetadata.identifier` | string | ✅ | Identifier for the user or merchant initiating the transaction. |
658
+ | `userMetadata.ip` | string | ✅ | IP address from which the transaction was initiated. |
659
+ | `userMetadata.urlCommerce` | string | ✅ | Commerce or customer’s URL associated with the transaction. |
660
+ | `withdrawMethod` | object | ✅ | Object specifying the withdrawal method and destination details. |
661
+ | `withdrawMethod.id` | number | ✅ | ID of the selected payout method (see table above). |
662
+ | `withdrawMethod.cellphone` | string | Conditional | Required for **Transfiya** withdrawals. |
663
+ | `withdrawMethod.key` | string | Conditional | Required for **Bre-B** withdrawals. |
664
+ | `withdrawMethod.bankName` | string | ❌ | Optional bank name, if applicable for future payout methods. |
665
+
666
+ ---
667
+ - **`customer_getbalance`**: This service allows you to consult the balance exchange and the dispersion exchange associated with the client's identifier.
668
+
669
+ > To use the service, an authentication token is required, which must be sent as an Authorization header.
670
+
671
+
672
+ Headers
673
+
674
+ | **Name** | **Value** |
675
+ | --- | --- |
676
+ | Content-Type | application/json |
677
+ | Authorization | Bearer |
678
+
679
+ Body
680
+
681
+ | Name | Type | Description |
682
+ | --- | --- | --- |
683
+ | `userId`\* | number | Integrated unique user identifier |
684
+ - **`payment_transfiya_banks`**: This service allows you to consult the balance exchange and the dispersion exchange associated with the client's identifier.
685
+
686
+ > To use the service, an authentication token is required, which must be sent as an Authorization header.
687
+
688
+
689
+ Headers
690
+
691
+ | **Name** | **Value** |
692
+ | --- | --- |
693
+ | Content-Type | application/json |
694
+ | Authorization | Bearer |
695
+
696
+ Body
697
+
698
+ | Name | Type | Description |
699
+ | --- | --- | --- |
700
+ | `cellphone`\* | number | The cell phone number to be used to consult the list of banks. |
701
+ - **`payment_status`**: This service allows you to check the status of a transaction made, for this you must have the _reference_ data that returned the response when generating any payment resource.
702
+
703
+ In the response you will get the _status_ _id_ which will mean the following
704
+
705
+ 0 - Transaction Rejected
706
+
707
+ 1 - Pending Transaction
708
+
709
+ 2 - Transaction Approved
710
+
711
+ 3 - Failed Transaction
712
+
713
+ 5 - Transaction Cancelled
714
+
715
+ 9 - Processing Transaction
716
+
717
+ Headers
718
+
719
+ | **Name** | **Value** |
720
+ | --- | --- |
721
+ | Content-Type | application/json |
722
+ | Authorization | Bearer |
723
+
724
+ Body
725
+
726
+ | Name | Type | Description |
727
+ | --- | --- | --- |
728
+ | `reference`\* | string | Product reference |
729
+ - **`payment_customer_reference_status`**: ## 🔍 Check Transaction by Customer Reference
730
+
731
+ This endpoint allows **API Pay** users to query the status of a transaction using only the `customerReference` value originally provided when generating a resource as `reference1` through any of the following endpoints:
732
+
733
+ - `/cash-in/generate/payment-link/token`
734
+
735
+ - `/cash-in/generate/payment-method/token`
736
+
737
+ - `/cash-out/generate/withdraw-method/token`
738
+
739
+
740
+ This service is useful for retrieving the internal **Refacil** transaction information associated with a previously submitted customer reference.
741
+
742
+ ---
743
+
744
+ ## 🔐 Authentication
745
+
746
+ This endpoint **requires** a valid Bearer Token in the request headers. Requests without valid authentication will be rejected with an `Unauthorized` error.
747
+
748
+ ## 📤 Successful Response
749
+
750
+ - `exists`: `true` indicates that the transaction associated with the provided `customerReference` was found.
751
+
752
+ - `id`: Internal Refacil transaction ID.
753
+
754
+ - `status`: Transaction status code (see table below).
755
+
756
+ - `reference`: Full Refacil transaction reference, which can be used to query `/payment/status`.
757
+
758
+
759
+ ### ℹ️ Status Code Reference
760
+
761
+ | Status Code | Meaning |
762
+ | --- | --- |
763
+ | `0` | Transaction Rejected |
764
+ | `1` | Transaction Pending |
765
+ | `2` | Transaction Approved |
766
+ | `3` | Transaction Failed |
767
+ | `5` | Transaction Cancelled |
768
+ | `9` | Transaction Processing |
769
+
770
+ ---
771
+ - **`payment_features`**: This service allows you to consult the necessary characteristics of a payment method to successfully generate a resource. For example, obtain the PSE banks
772
+
773
+ Headers
774
+
775
+ | **Name** | **Value** |
776
+ | --- | --- |
777
+ | Content-Type | application/json |
778
+ | Authorization | Bearer |
779
+
780
+ Body
781
+
782
+ | Name | Type | Description |
783
+ | --- | --- | --- |
784
+ | `id`\* | integer | Product identification |
785
+ - **`webhook_notify`**: Body
786
+
787
+ | Name | Type | Description |
788
+ | --- | --- | --- |
789
+ | amount\* | Integer | Total transaction value |
790
+ | cost\* | Integer | Transaction cost |
791
+ | Resource | Object | Object |
792
+ | id | Integer | Identifier of the payment resource |
793
+ | updatedAt | String | Date and time at which the transaction was processed |
794
+ | status\* | Object | Transaction status identifier |
795
+ | transfiyaStatus | String | The TransfiYa status, see the details below |
796
+ | id\* | String | Transaction status ID : 1 Pending , 2 Approved ,3 Failed |
797
+ | id \* | Integer | transaction identifier |
798
+ | description | String | Status detail |
799
+ | Key | interger | Key |
800
+ | PaymentMethod | Object | Payment method |
801
+ | id | String | Method identifier |
802
+ | name | String | payment method name |
803
+ | type | String | method |
804
+ | extra | Object | Object |
805
+ | reference1\* | String | Unique reference to the transaction provided when sending the request to generate the resource |
806
+ | reference2 | String | Allows to append extra information provided by the client |
807
+ | reference3 | String | Allows to append extra information provided by the customer |
808
+ | commerceId | String | Commerce identifier |
809
+ | createdAt | String | Date and time the transaction was created |
810
+ | signature | String | Signature generated for webhook notification |
811
+ | data | Object | Object with all data |
812
+ | Transaction | String | |
813
+
814
+
815
+ ## TransfiYa Status
816
+
817
+ | **transfiyaStatus** | Description |
818
+ | --- | --- |
819
+ | `CREATED` | Transfer is received and queued for processing. |
820
+ | `PENDING` | Transfer is valid and is waiting for the target to accept it. |
821
+ | `ACCEPTED` | Transfer has been accepted by the target, and payment is pending in the target bank. |
822
+ | `COMPLETED` | The payment is valid and completely processed, visible in the receiving bank account. |
823
+ | `REJECTED` | Payment was rejected. |
824
+ | `ERROR` | An error occurred during payment. |
825
+
826
+ ### Transfer state machine
827
+
828
+ <img src="https://content.pstmn.io/89f89557-2e1b-44c2-8dcb-d9e7d2f32c54/aW1hZ2UucG5n" width="293" height="380">
829
+ - **`merchant_enrollment`**: This endpoint initiates the merchant enrollment process required to use the QR interoperable payment method. Once the request is made, the enrollment process may take up to **7 minutes** to complete.
830
+ - **`merchant_enrollment_data`**: This endpoint retrieves the merchant's enrollment details after the enrollment process has been completed. It provides necessary information to use the QR interoperable payment method.
831
+ - **`merchant_key_create`**: This endpoint will allow you to create 4 types of keys: `alias`, `email`, `cellphone`, and `document`.
832
+
833
+ ⚠ **Important**:
834
+
835
+ - **Alias key:** To generate this key, it is not necessary to send the `key` field and the `otp` field. A random key is generated from various parameters of the merchant user, beginning with the character @.
836
+
837
+ - **Document key:** To generate this key, it is not necessary to send the `otp` field, and the key field must contain the document provided in the technical data sheet shared with the merchant.
838
+
839
+ - **Email key:** To generate this key, you must first use the service that generates and sends the OTP to the `email` address. The key field must contain the `email` address provided in the technical data sheet.
840
+
841
+ - **Cellphone key:** To generate this key, you must first use the service that generates and sends the OTP to the `cellphone`. The key field must contain the `cellphone` number provided in the technical data sheet.
842
+
843
+
844
+ Headers
845
+
846
+ | **Name** | **Value** |
847
+ | --- | --- |
848
+ | Content-Type | application/json |
849
+ | Authorization | Bearer |
850
+ | x-transaction-token | 9b48edde-652d-11ed-984e-02c840fe**** |
851
+
852
+ Body
853
+
854
+ | Name | Type | Description |
855
+ | --- | --- | --- |
856
+ | `webhookUrl`\* | string | URL of the client's webhook. |
857
+ | `userMetadata`\* | object | Object containing key details about the user or merchant generating the payment resource. |
858
+ | `ip`\* | string | Alphanumeric parameter that provides the IP address associated with the user's identifier |
859
+ | `identifier`\* | string | Alphanumeric parameter of 20 characters specifying the unique identifier of the user or merchant generating the payment resource. |
860
+ | `urlCommerce`\* | string | URL that identifies the commerce. Must follow valid URL structure with http:// or https:// protocol. Maximum length: 500 characters. |
861
+ | `reference1`\* | string | Customer identifier, must not exceed 20 characters. |
862
+ | `reference2` | object | Object for additional information. |
863
+ | `Label` | object | Object to send information to be displayed in the payment summary. |
864
+ | `Data` | object | Object for information related to the conciliation of the transaction. |
865
+ | `typeKey`\* | string | Can be `alias`, `document`, `email`, and `cellphone` |
866
+ | `key` | string | Key to create |
867
+ | `otp` | string | OTP code for cellphone and email keys |
868
+ | `termsAndConditions`\* | boolean | It must always be set to true. |
869
+ - **`merchant_key_cancel`**: This endpoint allows you to cancel an existing key, which will then become inactive and unable to receive transactions.
870
+
871
+ Headers
872
+
873
+ | **Name** | **Value** |
874
+ | --- | --- |
875
+ | Content-Type | application/json |
876
+ | Authorization | Bearer |
877
+ | x-transaction-token | 9b48edde-652d-11ed-984e-02c840fe**** |
878
+
879
+ Body
880
+
881
+ | Name | Type | Description |
882
+ | --- | --- | --- |
883
+ | `userMetadata`\* | object | Object containing key details about the user or merchant generating the payment resource. |
884
+ | `ip`\* | string | Alphanumeric parameter that provides the IP address associated with the user's identifier |
885
+ | `identifier`\* | string | Alphanumeric parameter of 20 characters specifying the unique identifier of the user or merchant generating the payment resource. |
886
+ | `urlCommerce`\* | string | URL that identifies the commerce. Must follow valid URL structure with http:// or https:// protocol. Maximum length: 500 characters. |
887
+ | `key` | string | Key to cancel |
888
+ - **`merchant_key_generate_otp`**: This endpoint will allow you to generate and send an OTP. It is only permitted and necessary for `email` and `cellphone` keys. This OTP will be sent to its corresponding destination.
889
+
890
+ Headers
891
+
892
+ | **Name** | **Value** |
893
+ | --- | --- |
894
+ | Content-Type | application/json |
895
+ | Authorization | Bearer |
896
+
897
+ Body
898
+
899
+ | Name | Type | Description |
900
+ | --- | --- | --- |
901
+ | `typeKey`\* | string | Can be `email` and `cellphone` |
902
+ | `key` | string | key for which the OTP will be generated |
903
+ - **`merchant_key_get_keys`**: This endpoint allows you to obtain all keys created and in active status that belong to the merchant.
904
+
905
+ ## 📝 Logs
906
+
907
+ El servidor genera logs detallados de todas las operaciones:
908
+
909
+ ```
910
+ [2024-01-01T12:00:00.000Z] get_users iniciada
911
+ [2024-01-01T12:00:01.000Z] get_users completada exitosamente
912
+ ```
913
+
914
+ ## 🔍 Troubleshooting
915
+
916
+ ### Error de autenticación
917
+ Verificar que las credenciales estén configuradas correctamente en las variables de entorno.
918
+
919
+ ### Error de conexión a la API
920
+ Verificar que `BASE_URL` sea accesible y la API esté funcionando.
921
+
922
+ ### Error de puerto
923
+ Verificar que el puerto `3009` no esté siendo usado por otro servicio.
924
+
925
+ ## 📞 Soporte
926
+
927
+ Para soporte técnico, contactar al equipo de desarrollo.
928
+
929
+ ---
930
+
931
+ *Generado automáticamente por Refacil MCP Framework*