@hanix.io/business 0.1.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/LICENSE +21 -0
- package/README.md +135 -0
- package/dist/auth/hmac.d.ts +15 -0
- package/dist/auth/hmac.d.ts.map +1 -0
- package/dist/auth/hmac.js +41 -0
- package/dist/auth/hmac.js.map +1 -0
- package/dist/client.d.ts +38 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +69 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/http/request.d.ts +14 -0
- package/dist/http/request.d.ts.map +1 -0
- package/dist/http/request.js +87 -0
- package/dist/http/request.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/json/stable-stringify.d.ts +6 -0
- package/dist/json/stable-stringify.d.ts.map +1 -0
- package/dist/json/stable-stringify.js +22 -0
- package/dist/json/stable-stringify.js.map +1 -0
- package/dist/types/payment-order.d.ts +50 -0
- package/dist/types/payment-order.d.ts.map +1 -0
- package/dist/types/payment-order.js +2 -0
- package/dist/types/payment-order.js.map +1 -0
- package/dist/types/requests.d.ts +33 -0
- package/dist/types/requests.d.ts.map +1 -0
- package/dist/types/requests.js +2 -0
- package/dist/types/requests.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hanix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# @hanix.io/business
|
|
2
|
+
|
|
3
|
+
SDK oficial de Node.js para la **Hanix Business API**: crear y consultar órdenes de pago con autenticación HMAC-SHA256.
|
|
4
|
+
|
|
5
|
+
## Instalación
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @hanix.io/business
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @hanix.io/business
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Requisitos
|
|
16
|
+
|
|
17
|
+
- Node.js 22.12 o superior
|
|
18
|
+
- **merchantId**: UUID del comercio (cabecera `business-merchant-id`)
|
|
19
|
+
- **apiKey**: secreto HMAC del comercio (no se envía en la red; solo firma las solicitudes). Obtén ambos en el panel Hanix o en `GET /merchants/me` con tu sesión merchant.
|
|
20
|
+
|
|
21
|
+
El SDK apunta por defecto a `https://api.hanix.io/api/v1`.
|
|
22
|
+
|
|
23
|
+
## Inicio rápido
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { HanixBusinessClient } from '@hanix.io/business';
|
|
27
|
+
|
|
28
|
+
const client = new HanixBusinessClient({
|
|
29
|
+
merchantId: process.env.HANIX_MERCHANT_ID!,
|
|
30
|
+
apiKey: process.env.HANIX_API_KEY!,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const order = await client.createPaymentOrder({
|
|
34
|
+
merchant_reference: 'pedido-1001',
|
|
35
|
+
amount_in_cents: 15000,
|
|
36
|
+
currency_id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
37
|
+
country_id: 'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy',
|
|
38
|
+
description: 'Suscripción mensual',
|
|
39
|
+
customer_email: 'cliente@ejemplo.com',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
console.log(order.payment_url);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API del cliente
|
|
46
|
+
|
|
47
|
+
### `new HanixBusinessClient(options)`
|
|
48
|
+
|
|
49
|
+
| Opción | Obligatorio | Descripción |
|
|
50
|
+
|--------|-------------|-------------|
|
|
51
|
+
| `merchantId` | Sí | UUID del comercio |
|
|
52
|
+
| `apiKey` | Sí | Clave API (secreto HMAC) |
|
|
53
|
+
| `timeoutMs` | No | Tiempo máximo por solicitud (default: 30000) |
|
|
54
|
+
| `fetch` | No | Implementación de `fetch` (tests o entornos custom) |
|
|
55
|
+
| `userAgent` | No | Cabecera `User-Agent` (default: `@hanix.io/business`) |
|
|
56
|
+
|
|
57
|
+
### `createPaymentOrder(input)`
|
|
58
|
+
|
|
59
|
+
Crea una orden de pago (`POST /business/payment-orders`).
|
|
60
|
+
|
|
61
|
+
Campos obligatorios: `merchant_reference`, `amount_in_cents`, `currency_id`, `country_id`.
|
|
62
|
+
|
|
63
|
+
Opcionales: `description`, `customer_email`, `success_url`, `cancel_url`, `expires_at`, `metadata`.
|
|
64
|
+
|
|
65
|
+
Devuelve una `PaymentOrder` con `payment_url`, `public_token`, `status`, etc.
|
|
66
|
+
|
|
67
|
+
### `listPaymentOrders(params?)`
|
|
68
|
+
|
|
69
|
+
Lista órdenes del comercio (`GET /business/payment-orders`).
|
|
70
|
+
|
|
71
|
+
Filtros opcionales: `status`, `merchant_reference`, `currency_id`, `country_id`, `created_from`, `created_to`, `expires_from`, `expires_to`, `page`, `limit`, `sort` (`created_at_asc` \| `created_at_desc`).
|
|
72
|
+
|
|
73
|
+
### `getPaymentOrder(paymentOrderId)`
|
|
74
|
+
|
|
75
|
+
Obtiene una orden por id (`GET /business/payment-orders/:id`).
|
|
76
|
+
|
|
77
|
+
### `listPaymentOrderAttempts(paymentOrderId, params?)`
|
|
78
|
+
|
|
79
|
+
Lista intentos de pago de una orden (`GET /business/payment-orders/:id/attempts`).
|
|
80
|
+
|
|
81
|
+
Filtros opcionales: `status` (`initiated`, `processing`, `succeeded`, `failed`, `expired`, `abandoned`), `page`, `limit`, `sort`.
|
|
82
|
+
|
|
83
|
+
## Autenticación
|
|
84
|
+
|
|
85
|
+
Cada solicitud lleva estas cabeceras (generadas por el SDK):
|
|
86
|
+
|
|
87
|
+
| Cabecera | Descripción |
|
|
88
|
+
|----------|-------------|
|
|
89
|
+
| `business-merchant-id` | UUID del comercio |
|
|
90
|
+
| `business-timestamp` | Unix en segundos |
|
|
91
|
+
| `business-signature` | `HMAC-SHA256(apiKey, timestamp + rawBody)` en hexadecimal |
|
|
92
|
+
|
|
93
|
+
En `GET`, el cuerpo firmado es la cadena vacía. En `POST`, el cuerpo JSON se serializa con claves ordenadas para que la firma coincida con los bytes enviados.
|
|
94
|
+
|
|
95
|
+
## Errores
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import {
|
|
99
|
+
HanixBusinessError,
|
|
100
|
+
HanixBusinessNetworkError,
|
|
101
|
+
HanixBusinessConfigError,
|
|
102
|
+
} from '@hanix.io/business';
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
await client.getPaymentOrder('...');
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error instanceof HanixBusinessError) {
|
|
108
|
+
// 4xx / 5xx de la API (error.status, error.message, error.body)
|
|
109
|
+
} else if (error instanceof HanixBusinessNetworkError) {
|
|
110
|
+
// Timeout o fallo de red (error.cause)
|
|
111
|
+
} else if (error instanceof HanixBusinessConfigError) {
|
|
112
|
+
// merchantId o apiKey inválidos al crear el cliente
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
| Clase | Cuándo |
|
|
118
|
+
|-------|--------|
|
|
119
|
+
| `HanixBusinessError` | Respuesta HTTP no exitosa de Hanix |
|
|
120
|
+
| `HanixBusinessNetworkError` | Timeout, red o `fetch` no disponible |
|
|
121
|
+
| `HanixBusinessConfigError` | Opciones inválidas del cliente |
|
|
122
|
+
|
|
123
|
+
## Buenas prácticas
|
|
124
|
+
|
|
125
|
+
- Guarda `apiKey` en variables de entorno o un gestor de secretos; no la subas al repositorio.
|
|
126
|
+
- La `apiKey` nunca viaja en cabeceras ni en el cuerpo; solo se usa para firmar.
|
|
127
|
+
- Usa `merchant_reference` único por orden para evitar conflictos (409).
|
|
128
|
+
|
|
129
|
+
## Utilidades exportadas
|
|
130
|
+
|
|
131
|
+
Para integraciones avanzadas o pruebas manuales:
|
|
132
|
+
|
|
133
|
+
- `HANIX_BUSINESS_API_BASE_URL` — URL base de la API
|
|
134
|
+
- `stableStringify`, `signBusinessPayload`, `buildBusinessAuthHeaders`, `verifyBusinessPayload`
|
|
135
|
+
- Constantes de cabeceras: `BUSINESS_MERCHANT_ID_HEADER`, `BUSINESS_TIMESTAMP_HEADER`, `BUSINESS_SIGNATURE_HEADER`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const BUSINESS_MERCHANT_ID_HEADER = "business-merchant-id";
|
|
2
|
+
export declare const BUSINESS_TIMESTAMP_HEADER = "business-timestamp";
|
|
3
|
+
export declare const BUSINESS_SIGNATURE_HEADER = "business-signature";
|
|
4
|
+
export declare function assertValidMerchantId(merchantId: string): void;
|
|
5
|
+
export declare function assertValidApiKey(apiKey: string): void;
|
|
6
|
+
export declare function signBusinessPayload(apiKey: string, timestamp: string, rawBody: string): string;
|
|
7
|
+
/** Solo para pruebas o verificación local; el servidor valida la firma. */
|
|
8
|
+
export declare function verifyBusinessPayload(apiKey: string, timestamp: string, rawBody: string, signature: string): boolean;
|
|
9
|
+
export declare function buildBusinessAuthHeaders(input: {
|
|
10
|
+
merchantId: string;
|
|
11
|
+
apiKey: string;
|
|
12
|
+
rawBody: string;
|
|
13
|
+
timestamp?: number;
|
|
14
|
+
}): Record<string, string>;
|
|
15
|
+
//# sourceMappingURL=hmac.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../../src/auth/hmac.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAClE,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAC9D,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAK9D,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAI9D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAItD;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,MAAM,CAGR;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAQT;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBzB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
export const BUSINESS_MERCHANT_ID_HEADER = 'business-merchant-id';
|
|
3
|
+
export const BUSINESS_TIMESTAMP_HEADER = 'business-timestamp';
|
|
4
|
+
export const BUSINESS_SIGNATURE_HEADER = 'business-signature';
|
|
5
|
+
const MERCHANT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
6
|
+
export function assertValidMerchantId(merchantId) {
|
|
7
|
+
if (!MERCHANT_ID_RE.test(merchantId)) {
|
|
8
|
+
throw new Error('merchantId debe ser un UUID válido');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function assertValidApiKey(apiKey) {
|
|
12
|
+
if (typeof apiKey !== 'string' || apiKey.trim().length < 16) {
|
|
13
|
+
throw new Error('apiKey inválida');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function signBusinessPayload(apiKey, timestamp, rawBody) {
|
|
17
|
+
const payload = `${timestamp}${rawBody}`;
|
|
18
|
+
return createHmac('sha256', apiKey).update(payload, 'utf8').digest('hex');
|
|
19
|
+
}
|
|
20
|
+
/** Solo para pruebas o verificación local; el servidor valida la firma. */
|
|
21
|
+
export function verifyBusinessPayload(apiKey, timestamp, rawBody, signature) {
|
|
22
|
+
const expected = signBusinessPayload(apiKey, timestamp, rawBody);
|
|
23
|
+
const a = Buffer.from(expected, 'hex');
|
|
24
|
+
const b = Buffer.from(signature.trim(), 'hex');
|
|
25
|
+
if (a.length !== b.length) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return timingSafeEqual(a, b);
|
|
29
|
+
}
|
|
30
|
+
export function buildBusinessAuthHeaders(input) {
|
|
31
|
+
assertValidMerchantId(input.merchantId);
|
|
32
|
+
assertValidApiKey(input.apiKey);
|
|
33
|
+
const timestamp = String(input.timestamp ?? Math.floor(Date.now() / 1000));
|
|
34
|
+
const signature = signBusinessPayload(input.apiKey, timestamp, input.rawBody);
|
|
35
|
+
return {
|
|
36
|
+
[BUSINESS_MERCHANT_ID_HEADER]: input.merchantId,
|
|
37
|
+
[BUSINESS_TIMESTAMP_HEADER]: timestamp,
|
|
38
|
+
[BUSINESS_SIGNATURE_HEADER]: signature,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=hmac.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src/auth/hmac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,sBAAsB,CAAC;AAClE,MAAM,CAAC,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAC9D,MAAM,CAAC,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAE9D,MAAM,cAAc,GAClB,4EAA4E,CAAC;AAE/E,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAc,EACd,SAAiB,EACjB,OAAe;IAEf,MAAM,OAAO,GA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,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Paginated, PaymentAttempt, PaymentOrder } from './types/payment-order.js';
|
|
2
|
+
import type { CreatePaymentOrderInput, ListPaymentOrderAttemptsParams, ListPaymentOrdersParams } from './types/requests.js';
|
|
3
|
+
/** URL base de la Hanix Business API (mismo valor que `merchants_business_api_url`). */
|
|
4
|
+
export declare const HANIX_BUSINESS_API_BASE_URL: "https://api.hanix.io/api/v1";
|
|
5
|
+
export type HanixBusinessClientOptions = {
|
|
6
|
+
/** UUID del comercio (cabecera business-merchant-id). */
|
|
7
|
+
merchantId: string;
|
|
8
|
+
/**
|
|
9
|
+
* Clave API del comercio (secreto HMAC). No se envía en la solicitud;
|
|
10
|
+
* solo se usa para firmar. Obtenerla en el panel Hanix / GET merchants/me.
|
|
11
|
+
*/
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/** Tiempo máximo por solicitud en ms (default 30000). */
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
/** Implementación de fetch (útil en tests o entornos sin fetch global). */
|
|
16
|
+
fetch?: typeof fetch;
|
|
17
|
+
/** User-Agent personalizado. */
|
|
18
|
+
userAgent?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare class HanixBusinessClient {
|
|
21
|
+
private readonly baseUrl;
|
|
22
|
+
private readonly merchantId;
|
|
23
|
+
private readonly apiKey;
|
|
24
|
+
private readonly timeoutMs;
|
|
25
|
+
private readonly fetchImpl;
|
|
26
|
+
private readonly userAgent;
|
|
27
|
+
constructor(options: HanixBusinessClientOptions);
|
|
28
|
+
/** Crea una orden de pago. */
|
|
29
|
+
createPaymentOrder(input: CreatePaymentOrderInput): Promise<PaymentOrder>;
|
|
30
|
+
/** Lista órdenes de pago del comercio autenticado. */
|
|
31
|
+
listPaymentOrders(params?: ListPaymentOrdersParams): Promise<Paginated<PaymentOrder>>;
|
|
32
|
+
/** Obtiene una orden de pago por id. */
|
|
33
|
+
getPaymentOrder(paymentOrderId: string): Promise<PaymentOrder>;
|
|
34
|
+
/** Lista intentos de pago de una orden. */
|
|
35
|
+
listPaymentOrderAttempts(paymentOrderId: string, params?: ListPaymentOrderAttemptsParams): Promise<Paginated<PaymentAttempt>>;
|
|
36
|
+
private request;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAI7B,wFAAwF;AACxF,eAAO,MAAM,2BAA2B,EACtC,6BAAsC,CAAC;AAEzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;gBAEnC,OAAO,EAAE,0BAA0B;IAY/C,8BAA8B;IAC9B,kBAAkB,CAChB,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,YAAY,CAAC;IAOxB,sDAAsD;IACtD,iBAAiB,CACf,MAAM,GAAE,uBAA4B,GACnC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAQnC,wCAAwC;IACxC,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAO9D,2CAA2C;IAC3C,wBAAwB,CACtB,cAAc,EAAE,MAAM,EACtB,MAAM,GAAE,8BAAmC,GAC1C,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAQrC,OAAO,CAAC,OAAO;CAgChB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { assertValidApiKey, assertValidMerchantId, } from './auth/hmac.js';
|
|
2
|
+
import { signedRequest } from './http/request.js';
|
|
3
|
+
import { stableStringify } from './json/stable-stringify.js';
|
|
4
|
+
const PAYMENT_ORDERS_PATH = '/business/payment-orders';
|
|
5
|
+
/** URL base de la Hanix Business API (mismo valor que `merchants_business_api_url`). */
|
|
6
|
+
export const HANIX_BUSINESS_API_BASE_URL = 'https://api.hanix.io/api/v1';
|
|
7
|
+
export class HanixBusinessClient {
|
|
8
|
+
baseUrl;
|
|
9
|
+
merchantId;
|
|
10
|
+
apiKey;
|
|
11
|
+
timeoutMs;
|
|
12
|
+
fetchImpl;
|
|
13
|
+
userAgent;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.baseUrl = HANIX_BUSINESS_API_BASE_URL;
|
|
16
|
+
this.merchantId = options.merchantId.trim();
|
|
17
|
+
this.apiKey = options.apiKey;
|
|
18
|
+
this.timeoutMs = options.timeoutMs;
|
|
19
|
+
this.fetchImpl = options.fetch;
|
|
20
|
+
this.userAgent = options.userAgent;
|
|
21
|
+
assertValidMerchantId(this.merchantId);
|
|
22
|
+
assertValidApiKey(this.apiKey);
|
|
23
|
+
}
|
|
24
|
+
/** Crea una orden de pago. */
|
|
25
|
+
createPaymentOrder(input) {
|
|
26
|
+
const rawBody = stableStringify(input);
|
|
27
|
+
return this.request('POST', PAYMENT_ORDERS_PATH, {
|
|
28
|
+
body: rawBody,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Lista órdenes de pago del comercio autenticado. */
|
|
32
|
+
listPaymentOrders(params = {}) {
|
|
33
|
+
return this.request('GET', PAYMENT_ORDERS_PATH, { query: params });
|
|
34
|
+
}
|
|
35
|
+
/** Obtiene una orden de pago por id. */
|
|
36
|
+
getPaymentOrder(paymentOrderId) {
|
|
37
|
+
return this.request('GET', `${PAYMENT_ORDERS_PATH}/${encodeURIComponent(paymentOrderId)}`);
|
|
38
|
+
}
|
|
39
|
+
/** Lista intentos de pago de una orden. */
|
|
40
|
+
listPaymentOrderAttempts(paymentOrderId, params = {}) {
|
|
41
|
+
return this.request('GET', `${PAYMENT_ORDERS_PATH}/${encodeURIComponent(paymentOrderId)}/attempts`, { query: params });
|
|
42
|
+
}
|
|
43
|
+
request(method, path, extra) {
|
|
44
|
+
const requestOptions = {
|
|
45
|
+
baseUrl: this.baseUrl,
|
|
46
|
+
merchantId: this.merchantId,
|
|
47
|
+
apiKey: this.apiKey,
|
|
48
|
+
method,
|
|
49
|
+
path,
|
|
50
|
+
};
|
|
51
|
+
if (extra?.body !== undefined) {
|
|
52
|
+
requestOptions.body = extra.body;
|
|
53
|
+
}
|
|
54
|
+
if (extra?.query !== undefined) {
|
|
55
|
+
requestOptions.query = extra.query;
|
|
56
|
+
}
|
|
57
|
+
if (this.timeoutMs !== undefined) {
|
|
58
|
+
requestOptions.timeoutMs = this.timeoutMs;
|
|
59
|
+
}
|
|
60
|
+
if (this.fetchImpl !== undefined) {
|
|
61
|
+
requestOptions.fetchImpl = this.fetchImpl;
|
|
62
|
+
}
|
|
63
|
+
if (this.userAgent !== undefined) {
|
|
64
|
+
requestOptions.userAgent = this.userAgent;
|
|
65
|
+
}
|
|
66
|
+
return signedRequest(requestOptions);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=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IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,cAAc,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5C,CAAC;QACD,OAAO,aAAa,CAAI,cAAc,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type HanixBusinessApiErrorBody = {
|
|
2
|
+
message?: string;
|
|
3
|
+
statusCode?: number;
|
|
4
|
+
};
|
|
5
|
+
export declare class HanixBusinessError extends Error {
|
|
6
|
+
readonly status: number;
|
|
7
|
+
readonly body: HanixBusinessApiErrorBody | undefined;
|
|
8
|
+
constructor(message: string, status: number, body?: HanixBusinessApiErrorBody);
|
|
9
|
+
}
|
|
10
|
+
export declare class HanixBusinessConfigError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class HanixBusinessNetworkError extends Error {
|
|
14
|
+
readonly cause: unknown;
|
|
15
|
+
constructor(message: string, cause: unknown);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,yBAAyB,GAAG,SAAS,CAAC;gBAGnD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,yBAAyB;CAOnC;AAED,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAK5C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class HanixBusinessError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
body;
|
|
4
|
+
constructor(message, status, body) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'HanixBusinessError';
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.body = body;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class HanixBusinessConfigError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'HanixBusinessConfigError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class HanixBusinessNetworkError extends Error {
|
|
18
|
+
cause;
|
|
19
|
+
constructor(message, cause) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'HanixBusinessNetworkError';
|
|
22
|
+
this.cause = cause;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,MAAM,CAAS;IACf,IAAI,CAAwC;IAErD,YACE,OAAe,EACf,MAAc,EACd,IAAgC;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,KAAK,CAAU;IAExB,YAAY,OAAe,EAAE,KAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type SignedRequestOptions = {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
merchantId: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
method: 'GET' | 'POST';
|
|
6
|
+
path: string;
|
|
7
|
+
query?: Record<string, string | number | undefined>;
|
|
8
|
+
body?: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
fetchImpl?: typeof fetch;
|
|
11
|
+
userAgent?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function signedRequest<T>(options: SignedRequestOptions): Promise<T>;
|
|
14
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/http/request.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAuEhF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { buildBusinessAuthHeaders } from '../auth/hmac.js';
|
|
2
|
+
import { HanixBusinessError, HanixBusinessNetworkError, } from '../errors.js';
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
4
|
+
const DEFAULT_USER_AGENT = '@hanix.io/business';
|
|
5
|
+
export async function signedRequest(options) {
|
|
6
|
+
const fetchFn = options.fetchImpl ?? globalThis.fetch;
|
|
7
|
+
if (typeof fetchFn !== 'function') {
|
|
8
|
+
throw new Error('fetch no está disponible; pase fetchImpl en Node < 18');
|
|
9
|
+
}
|
|
10
|
+
const rawBody = options.body ?? '';
|
|
11
|
+
const url = buildUrl(options.baseUrl, options.path, options.query);
|
|
12
|
+
const authHeaders = buildBusinessAuthHeaders({
|
|
13
|
+
merchantId: options.merchantId,
|
|
14
|
+
apiKey: options.apiKey,
|
|
15
|
+
rawBody,
|
|
16
|
+
});
|
|
17
|
+
const headers = {
|
|
18
|
+
Accept: 'application/json',
|
|
19
|
+
'User-Agent': options.userAgent ?? DEFAULT_USER_AGENT,
|
|
20
|
+
...authHeaders,
|
|
21
|
+
};
|
|
22
|
+
if (rawBody.length > 0) {
|
|
23
|
+
headers['Content-Type'] = 'application/json';
|
|
24
|
+
}
|
|
25
|
+
const controller = new AbortController();
|
|
26
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
27
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
28
|
+
try {
|
|
29
|
+
const init = {
|
|
30
|
+
method: options.method,
|
|
31
|
+
headers,
|
|
32
|
+
signal: controller.signal,
|
|
33
|
+
};
|
|
34
|
+
if (rawBody.length > 0) {
|
|
35
|
+
init.body = rawBody;
|
|
36
|
+
}
|
|
37
|
+
const response = await fetchFn(url, init);
|
|
38
|
+
const text = await response.text();
|
|
39
|
+
const parsed = parseJson(text);
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
const body = parsed && typeof parsed === 'object'
|
|
42
|
+
? parsed
|
|
43
|
+
: undefined;
|
|
44
|
+
const message = body?.message ??
|
|
45
|
+
`Hanix Business API respondió ${response.status}`;
|
|
46
|
+
throw new HanixBusinessError(message, response.status, body);
|
|
47
|
+
}
|
|
48
|
+
return parsed;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error instanceof HanixBusinessError) {
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
55
|
+
throw new HanixBusinessNetworkError(`La solicitud excedió el tiempo de espera (${timeoutMs} ms)`, error);
|
|
56
|
+
}
|
|
57
|
+
throw new HanixBusinessNetworkError('Error de red al contactar Hanix Business API', error);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function buildUrl(baseUrl, path, query) {
|
|
64
|
+
const base = baseUrl.replace(/\/+$/, '');
|
|
65
|
+
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
|
66
|
+
const url = new URL(`${base}${normalizedPath}`);
|
|
67
|
+
if (query) {
|
|
68
|
+
for (const [key, value] of Object.entries(query)) {
|
|
69
|
+
if (value !== undefined && value !== '') {
|
|
70
|
+
url.searchParams.set(key, String(value));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return url.toString();
|
|
75
|
+
}
|
|
76
|
+
function parseJson(text) {
|
|
77
|
+
if (!text.trim()) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
return JSON.parse(text);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return text;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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T,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CACf,OAAe,EACf,IAAY,EACZ,KAAmD;IAEnD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAChE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,cAAc,EAAE,CAAC,CAAC;IAEhD,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;gBACxC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { HanixBusinessClient, HANIX_BUSINESS_API_BASE_URL, type HanixBusinessClientOptions, } from './client.js';
|
|
2
|
+
export { BUSINESS_MERCHANT_ID_HEADER, BUSINESS_SIGNATURE_HEADER, BUSINESS_TIMESTAMP_HEADER, buildBusinessAuthHeaders, signBusinessPayload, verifyBusinessPayload, } from './auth/hmac.js';
|
|
3
|
+
export { stableStringify } from './json/stable-stringify.js';
|
|
4
|
+
export { HanixBusinessConfigError, HanixBusinessError, HanixBusinessNetworkError, type HanixBusinessApiErrorBody, } from './errors.js';
|
|
5
|
+
export type { CreatePaymentOrderInput, ListPaymentOrderAttemptsParams, ListPaymentOrdersParams, } from './types/requests.js';
|
|
6
|
+
export type { Paginated, PaymentAttempt, PaymentAttemptStatus, PaymentOrder, PaymentOrderStatus, } from './types/payment-order.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,KAAK,0BAA0B,GAChC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,yBAAyB,GAC/B,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { HanixBusinessClient, HANIX_BUSINESS_API_BASE_URL, } from './client.js';
|
|
2
|
+
export { BUSINESS_MERCHANT_ID_HEADER, BUSINESS_SIGNATURE_HEADER, BUSINESS_TIMESTAMP_HEADER, buildBusinessAuthHeaders, signBusinessPayload, verifyBusinessPayload, } from './auth/hmac.js';
|
|
3
|
+
export { stableStringify } from './json/stable-stringify.js';
|
|
4
|
+
export { HanixBusinessConfigError, HanixBusinessError, HanixBusinessNetworkError, } from './errors.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,2BAA2B,GAE5B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stable-stringify.d.ts","sourceRoot":"","sources":["../../src/json/stable-stringify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializa JSON con claves ordenadas de forma estable para que la firma HMAC
|
|
3
|
+
* coincida con el cuerpo enviado en la solicitud.
|
|
4
|
+
*/
|
|
5
|
+
export function stableStringify(value) {
|
|
6
|
+
return JSON.stringify(sortValue(value));
|
|
7
|
+
}
|
|
8
|
+
function sortValue(value) {
|
|
9
|
+
if (value === null || typeof value !== 'object') {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
return value.map(sortValue);
|
|
14
|
+
}
|
|
15
|
+
const record = value;
|
|
16
|
+
const sorted = {};
|
|
17
|
+
for (const key of Object.keys(record).sort()) {
|
|
18
|
+
sorted[key] = sortValue(record[key]);
|
|
19
|
+
}
|
|
20
|
+
return sorted;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=stable-stringify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stable-stringify.js","sourceRoot":"","sources":["../../src/json/stable-stringify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7C,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type PaymentOrderStatus = 'pending' | 'processing' | 'paid' | 'expired' | 'cancelled';
|
|
2
|
+
export type PaymentAttemptStatus = 'initiated' | 'processing' | 'succeeded' | 'failed' | 'expired' | 'abandoned';
|
|
3
|
+
export type PaymentOrder = {
|
|
4
|
+
id: string;
|
|
5
|
+
merchant_id: string;
|
|
6
|
+
merchant_reference: string;
|
|
7
|
+
public_token: string;
|
|
8
|
+
status: PaymentOrderStatus;
|
|
9
|
+
amount_in_cents: string;
|
|
10
|
+
currency_id: string;
|
|
11
|
+
country_id: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
customer_email: string | null;
|
|
14
|
+
success_url: string | null;
|
|
15
|
+
cancel_url: string | null;
|
|
16
|
+
expires_at: string | null;
|
|
17
|
+
paid_attempt_id: string | null;
|
|
18
|
+
paid_at: string | null;
|
|
19
|
+
cancelled_at: string | null;
|
|
20
|
+
metadata: Record<string, unknown> | null;
|
|
21
|
+
payment_url: string;
|
|
22
|
+
created_at: string;
|
|
23
|
+
updated_at: string;
|
|
24
|
+
};
|
|
25
|
+
export type PaymentAttempt = {
|
|
26
|
+
id: string;
|
|
27
|
+
payment_order_id: string;
|
|
28
|
+
merchant_psp_method_id: string;
|
|
29
|
+
status: PaymentAttemptStatus;
|
|
30
|
+
amount_in_cents: string;
|
|
31
|
+
psp_reference: string;
|
|
32
|
+
psp_transaction_id: string | null;
|
|
33
|
+
psp_status: string | null;
|
|
34
|
+
failure_code: string | null;
|
|
35
|
+
failure_message: string | null;
|
|
36
|
+
initiated_at: string;
|
|
37
|
+
completed_at: string | null;
|
|
38
|
+
created_at: string;
|
|
39
|
+
updated_at: string;
|
|
40
|
+
};
|
|
41
|
+
export type Paginated<T> = {
|
|
42
|
+
items: T[];
|
|
43
|
+
pagination: {
|
|
44
|
+
page: number;
|
|
45
|
+
limit: number;
|
|
46
|
+
total: number;
|
|
47
|
+
total_pages: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=payment-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-order.d.ts","sourceRoot":"","sources":["../../src/types/payment-order.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,YAAY,GACZ,MAAM,GACN,SAAS,GACT,WAAW,CAAC;AAEhB,MAAM,MAA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AC;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-order.js","sourceRoot":"","sources":["../../src/types/payment-order.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PaymentAttemptStatus, PaymentOrderStatus } from './payment-order.js';
|
|
2
|
+
export type CreatePaymentOrderInput = {
|
|
3
|
+
merchant_reference: string;
|
|
4
|
+
amount_in_cents: number;
|
|
5
|
+
currency_id: string;
|
|
6
|
+
country_id: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
customer_email?: string;
|
|
9
|
+
success_url?: string;
|
|
10
|
+
cancel_url?: string;
|
|
11
|
+
expires_at?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
export type ListPaymentOrdersParams = {
|
|
15
|
+
status?: PaymentOrderStatus;
|
|
16
|
+
merchant_reference?: string;
|
|
17
|
+
currency_id?: string;
|
|
18
|
+
country_id?: string;
|
|
19
|
+
created_from?: string;
|
|
20
|
+
created_to?: string;
|
|
21
|
+
expires_from?: string;
|
|
22
|
+
expires_to?: string;
|
|
23
|
+
page?: number;
|
|
24
|
+
limit?: number;
|
|
25
|
+
sort?: 'created_at_asc' | 'created_at_desc';
|
|
26
|
+
};
|
|
27
|
+
export type ListPaymentOrderAttemptsParams = {
|
|
28
|
+
status?: PaymentAttemptStatus;
|
|
29
|
+
page?: number;
|
|
30
|
+
limit?: number;
|
|
31
|
+
sort?: 'created_at_asc' | 'created_at_desc';
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,uBAAuB,GAAG;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;CAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.js","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hanix.io/business",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"description": "SDK oficial de Node.js para la Hanix Business API (órdenes de pago con autenticación HMAC)",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"packageManager": "pnpm@11.1.2",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22.12.0"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.build.json",
|
|
30
|
+
"test": "tsc -p tsconfig.test.json && node --test .test-dist/tests/*.test.js",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"verify": "pnpm run typecheck && pnpm test && pnpm run build && pnpm audit --audit-level=moderate",
|
|
33
|
+
"prepublishOnly": "pnpm run verify"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"hanix",
|
|
37
|
+
"payments",
|
|
38
|
+
"business-api",
|
|
39
|
+
"hmac",
|
|
40
|
+
"sdk"
|
|
41
|
+
],
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/hanix/hanix.git",
|
|
45
|
+
"directory": "sdks/hanix-business"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^22.15.21",
|
|
49
|
+
"typescript": "^5.8.3"
|
|
50
|
+
}
|
|
51
|
+
}
|