@npmtapi/embed 1.3.0 → 1.5.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 +15 -3
- package/dist/{chunk-2WNQZXMS.js → chunk-IZQ3PVG6.js} +1 -1
- package/dist/chunk-IZQ3PVG6.js.map +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/react.cjs +67 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +21 -2
- package/dist/react.d.ts +21 -2
- package/dist/react.js +68 -1
- package/dist/react.js.map +1 -1
- package/dist/{types-BIb8B1hp.d.cts → types-CJRvC3_b.d.cts} +90 -4
- package/dist/{types-BIb8B1hp.d.ts → types-CJRvC3_b.d.ts} +90 -4
- package/package.json +1 -1
- package/dist/chunk-2WNQZXMS.js.map +0 -1
package/README.md
CHANGED
|
@@ -34,13 +34,15 @@ Los tipos están incluidos — no necesitas `@types/tapipay`.
|
|
|
34
34
|
|
|
35
35
|
### Script tag (sin bundler)
|
|
36
36
|
|
|
37
|
+
Se requiere `container` + `identifier` + **uno de** `organization` o `companyCode` (si se pasan ambos, `companyCode` tiene prioridad).
|
|
38
|
+
|
|
37
39
|
```html
|
|
38
40
|
<script src="https://app.tapipay.la/embed.js"></script>
|
|
39
41
|
<div id="widget"></div>
|
|
40
42
|
<script>
|
|
41
43
|
tapipay.initialize({
|
|
42
44
|
container: "#widget",
|
|
43
|
-
organization: "acme",
|
|
45
|
+
organization: "acme", // o companyCode: "acme-mx"
|
|
44
46
|
identifier: "CLI-001"
|
|
45
47
|
});
|
|
46
48
|
|
|
@@ -88,9 +90,12 @@ export function PagoPage({ clienteId }: { clienteId: string }) {
|
|
|
88
90
|
|
|
89
91
|
### Props
|
|
90
92
|
|
|
93
|
+
Se requiere `identifier` + **uno de** `organization` o `companyCode`. Si se pasan ambos, `companyCode` tiene prioridad.
|
|
94
|
+
|
|
91
95
|
| Prop | Tipo | Requerido | Por defecto | Descripción |
|
|
92
96
|
|------|------|-----------|-------------|-------------|
|
|
93
|
-
| `organization` | `string` |
|
|
97
|
+
| `organization` | `string` | Uno de los dos | — | Alias de la organización en TapiPay. Requerido si no se pasa `companyCode` |
|
|
98
|
+
| `companyCode` | `string` | Uno de los dos | — | Código de compañía en TapiPay. Alternativa a `organization`. Si se pasan ambos, `companyCode` tiene prioridad |
|
|
94
99
|
| `identifier` | `string` | Sí | — | Identificador del cliente |
|
|
95
100
|
| `externalRequestId` | `string` | No | — | ID de deuda a preseleccionar. Tiene precedencia sobre `selectionStrategy` |
|
|
96
101
|
| `selectionStrategy` | `"oldestCreated"` | No | más reciente | Estrategia de selección automática de deuda pendiente. `"oldestCreated"`: la más antigua. Por defecto (omitido): la más reciente |
|
|
@@ -103,6 +108,10 @@ export function PagoPage({ clienteId }: { clienteId: string }) {
|
|
|
103
108
|
| `onAutopayActivated` | `(data) => void` | No | — | (Vista autopay) Callback cuando una nueva domiciliación queda activa (una sola vez por adhesión nueva) |
|
|
104
109
|
| `onAutopayRemoved` | `(data) => void` | No | — | (Vista autopay) Callback cuando el usuario desadhiere un medio con éxito |
|
|
105
110
|
| `onAutopayError` | `(data) => void` | No | — | (Vista autopay) Callback ante un error de carga o de desadhesión |
|
|
111
|
+
| `onDomiciliationBankSelected` | `(data) => void` | No | — | (Vista autopay) El usuario eligió su banco en el alta de domiciliación |
|
|
112
|
+
| `onDomiciliationFormCompleted` | `(data) => void` | No | — | (Vista autopay) Los datos de cuenta pasaron la validación del backend. Dispara al confirmar el método de verificación, no al salir del formulario |
|
|
113
|
+
| `onDomiciliationVerificationCompleted` | `(data) => void` | No | — | (Vista autopay) La verificación llegó a un desenlace. Solo emite al outcome final: un intento fallido con reintentos disponibles no dispara el evento |
|
|
114
|
+
| `onDomiciliationConfirmed` | `() => void` | No | — | (Vista autopay) El usuario confirmó la domiciliación. **No** significa que quedó registrada — la confirmación real llega por `onAutopayActivated` |
|
|
106
115
|
| `className` | `string` | No | — | Clases CSS del contenedor |
|
|
107
116
|
| `style` | `CSSProperties` | No | — | Estilos inline del contenedor |
|
|
108
117
|
|
|
@@ -204,10 +213,13 @@ export class TapipayWidgetComponent implements OnInit, OnDestroy {
|
|
|
204
213
|
|
|
205
214
|
### `initialize(options)`
|
|
206
215
|
|
|
216
|
+
Se requiere `container` + `identifier` + **uno de** `organization` o `companyCode`. Si se pasan ambos, `companyCode` tiene prioridad.
|
|
217
|
+
|
|
207
218
|
| Parámetro | Tipo | Requerido | Por defecto | Descripción |
|
|
208
219
|
|-----------|------|-----------|-------------|-------------|
|
|
209
220
|
| `container` | `string \| HTMLElement` | Sí | — | Selector CSS o referencia DOM |
|
|
210
|
-
| `organization` | `string` |
|
|
221
|
+
| `organization` | `string` | Uno de los dos | — | Alias de la organización en TapiPay. Requerido si no se pasa `companyCode` |
|
|
222
|
+
| `companyCode` | `string` | Uno de los dos | — | Código de compañía en TapiPay. Alternativa a `organization`. Si se pasan ambos, `companyCode` tiene prioridad |
|
|
211
223
|
| `identifier` | `string` | Sí | — | Identificador del cliente (DNI, número de cuenta, etc.) |
|
|
212
224
|
| `externalRequestId` | `string` | No | — | ID externo de una deuda específica a preseleccionar. Tiene precedencia sobre `selectionStrategy` |
|
|
213
225
|
| `selectionStrategy` | `"oldestCreated"` | No | más reciente | Estrategia de selección automática de deuda pendiente. `"oldestCreated"`: la más antigua. Por defecto (omitido): la más reciente |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/loader.ts"],"sourcesContent":["import type {\n\tLoadTapipayOptions,\n\tTapipayEnvironment,\n\tTapipayInstance,\n} from \"./types\";\n\nconst SDK_URLS: Record<TapipayEnvironment, string> = {\n\tproduction: \"https://app.tapipay.la/embed.js\",\n\thomo: \"https://homo.tapipay.la/embed.js\",\n};\n\n// Idempotencia por entorno\nconst loadPromises = new Map<TapipayEnvironment, Promise<TapipayInstance>>();\n\n/**\n * Carga el SDK de TapiPay de forma asíncrona inyectando el script en el DOM.\n *\n * - Idempotente por entorno: múltiples llamadas con el mismo `environment` retornan la misma Promise.\n * - Si window.tapipay ya existe (script cargado sync), resuelve inmediatamente.\n * - Compatible con React Strict Mode (doble mount/unmount).\n *\n * @example\n * // Producción (default)\n * const tapipay = await loadTapipay();\n *\n * // Homologación\n * const tapipay = await loadTapipay({ environment: 'homo' });\n *\n * // Se requiere UNO de { organization, companyCode } (companyCode tiene prioridad).\n * tapipay.initialize({ container: \"#widget\", organization: \"acme\", identifier: \"CLI-001\" });\n * tapipay.initialize({ container: \"#widget\", companyCode: \"acme-mx\", identifier: \"CLI-001\" });\n */\nexport function loadTapipay(\n\toptions?: LoadTapipayOptions,\n): Promise<TapipayInstance> {\n\tconst env: TapipayEnvironment = options?.environment ?? \"production\";\n\tconst SDK_URL = SDK_URLS[env];\n\tconst SCRIPT_ID = `tapipay-embed-sdk-${env}`;\n\n\t// SSR guard\n\tif (typeof window === \"undefined\") {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\"[TapiPay] loadTapipay() requires a browser environment.\"),\n\t\t);\n\t}\n\n\t// Ya cargado de forma síncrona (script tag directo)\n\tif (window.tapipay && !window.tapipay._q) {\n\t\treturn Promise.resolve(window.tapipay);\n\t}\n\n\t// Reutilizar promise existente (idempotencia por entorno)\n\tconst existing = loadPromises.get(env);\n\tif (existing) return existing;\n\n\tconst promise = new Promise<TapipayInstance>((resolve, reject) => {\n\t\t// Si ya hay un script inyectado, esperar a que cargue\n\t\tconst existingScript = document.getElementById(\n\t\t\tSCRIPT_ID,\n\t\t) as HTMLScriptElement | null;\n\n\t\tconst onLoad = () => {\n\t\t\tif (window.tapipay) {\n\t\t\t\tresolve(window.tapipay);\n\t\t\t} else {\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\"[TapiPay] El script cargó pero window.tapipay no está definido.\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst onError = () => {\n\t\t\tloadPromises.delete(env);\n\t\t\treject(new Error(`[TapiPay] Error al cargar el SDK desde ${SDK_URL}`));\n\t\t};\n\n\t\tif (existingScript) {\n\t\t\texistingScript.addEventListener(\"load\", onLoad);\n\t\t\texistingScript.addEventListener(\"error\", onError);\n\t\t\treturn;\n\t\t}\n\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.id = SCRIPT_ID;\n\t\tscript.src = SDK_URL;\n\t\tscript.async = true;\n\t\tscript.addEventListener(\"load\", onLoad);\n\t\tscript.addEventListener(\"error\", onError);\n\t\tdocument.head.appendChild(script);\n\t});\n\n\tloadPromises.set(env, promise);\n\treturn promise;\n}\n"],"mappings":";AAMA,IAAM,WAA+C;AAAA,EACpD,YAAY;AAAA,EACZ,MAAM;AACP;AAGA,IAAM,eAAe,oBAAI,IAAkD;AAoBpE,SAAS,YACf,SAC2B;AAlC5B;AAmCC,QAAM,OAA0B,wCAAS,gBAAT,YAAwB;AACxD,QAAM,UAAU,SAAS,GAAG;AAC5B,QAAM,YAAY,qBAAqB,GAAG;AAG1C,MAAI,OAAO,WAAW,aAAa;AAClC,WAAO,QAAQ;AAAA,MACd,IAAI,MAAM,yDAAyD;AAAA,IACpE;AAAA,EACD;AAGA,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,IAAI;AACzC,WAAO,QAAQ,QAAQ,OAAO,OAAO;AAAA,EACtC;AAGA,QAAM,WAAW,aAAa,IAAI,GAAG;AACrC,MAAI,SAAU,QAAO;AAErB,QAAM,UAAU,IAAI,QAAyB,CAAC,SAAS,WAAW;AAEjE,UAAM,iBAAiB,SAAS;AAAA,MAC/B;AAAA,IACD;AAEA,UAAM,SAAS,MAAM;AACpB,UAAI,OAAO,SAAS;AACnB,gBAAQ,OAAO,OAAO;AAAA,MACvB,OAAO;AACN;AAAA,UACC,IAAI;AAAA,YACH;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,UAAU,MAAM;AACrB,mBAAa,OAAO,GAAG;AACvB,aAAO,IAAI,MAAM,0CAA0C,OAAO,EAAE,CAAC;AAAA,IACtE;AAEA,QAAI,gBAAgB;AACnB,qBAAe,iBAAiB,QAAQ,MAAM;AAC9C,qBAAe,iBAAiB,SAAS,OAAO;AAChD;AAAA,IACD;AAEA,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,KAAK;AACZ,WAAO,MAAM;AACb,WAAO,QAAQ;AACf,WAAO,iBAAiB,QAAQ,MAAM;AACtC,WAAO,iBAAiB,SAAS,OAAO;AACxC,aAAS,KAAK,YAAY,MAAM;AAAA,EACjC,CAAC;AAED,eAAa,IAAI,KAAK,OAAO;AAC7B,SAAO;AACR;","names":[]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/loader.ts"],"sourcesContent":["export { loadTapipay } from \"./loader\";\nexport type {\n\tLoadTapipayOptions,\n\tTapipayAutopayActivatedEvent,\n\tTapipayAutopayAdhesionSummary,\n\tTapipayAutopayErrorEvent,\n\tTapipayAutopayLoadedEvent,\n\tTapipayAutopayMediaType,\n\tTapipayAutopayRemovedEvent,\n\tTapipayEnvironment,\n\tTapipayInstance,\n\tTapipayOptions,\n\tTapipayPaymentCancelledEvent,\n\tTapipayPaymentSubmittedEvent,\n\tTapipayPaymentWindowOpenedEvent,\n\tTapipayView,\n} from \"./types\";\n","import type {\n\tLoadTapipayOptions,\n\tTapipayEnvironment,\n\tTapipayInstance,\n} from \"./types\";\n\nconst SDK_URLS: Record<TapipayEnvironment, string> = {\n\tproduction: \"https://app.tapipay.la/embed.js\",\n\thomo: \"https://homo.tapipay.la/embed.js\",\n};\n\n// Idempotencia por entorno\nconst loadPromises = new Map<TapipayEnvironment, Promise<TapipayInstance>>();\n\n/**\n * Carga el SDK de TapiPay de forma asíncrona inyectando el script en el DOM.\n *\n * - Idempotente por entorno: múltiples llamadas con el mismo `environment` retornan la misma Promise.\n * - Si window.tapipay ya existe (script cargado sync), resuelve inmediatamente.\n * - Compatible con React Strict Mode (doble mount/unmount).\n *\n * @example\n * // Producción (default)\n * const tapipay = await loadTapipay();\n *\n * // Homologación\n * const tapipay = await loadTapipay({ environment: 'homo' });\n *\n * tapipay.initialize({ container: \"#widget\", organization: \"acme\", identifier: \"CLI-001\" });\n */\nexport function loadTapipay(\n\toptions?: LoadTapipayOptions,\n): Promise<TapipayInstance> {\n\tconst env: TapipayEnvironment = options?.environment ?? \"production\";\n\tconst SDK_URL = SDK_URLS[env];\n\tconst SCRIPT_ID = `tapipay-embed-sdk-${env}`;\n\n\t// SSR guard\n\tif (typeof window === \"undefined\") {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\"[TapiPay] loadTapipay() requires a browser environment.\"),\n\t\t);\n\t}\n\n\t// Ya cargado de forma síncrona (script tag directo)\n\tif (window.tapipay && !window.tapipay._q) {\n\t\treturn Promise.resolve(window.tapipay);\n\t}\n\n\t// Reutilizar promise existente (idempotencia por entorno)\n\tconst existing = loadPromises.get(env);\n\tif (existing) return existing;\n\n\tconst promise = new Promise<TapipayInstance>((resolve, reject) => {\n\t\t// Si ya hay un script inyectado, esperar a que cargue\n\t\tconst existingScript = document.getElementById(\n\t\t\tSCRIPT_ID,\n\t\t) as HTMLScriptElement | null;\n\n\t\tconst onLoad = () => {\n\t\t\tif (window.tapipay) {\n\t\t\t\tresolve(window.tapipay);\n\t\t\t} else {\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\"[TapiPay] El script cargó pero window.tapipay no está definido.\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst onError = () => {\n\t\t\tloadPromises.delete(env);\n\t\t\treject(new Error(`[TapiPay] Error al cargar el SDK desde ${SDK_URL}`));\n\t\t};\n\n\t\tif (existingScript) {\n\t\t\texistingScript.addEventListener(\"load\", onLoad);\n\t\t\texistingScript.addEventListener(\"error\", onError);\n\t\t\treturn;\n\t\t}\n\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.id = SCRIPT_ID;\n\t\tscript.src = SDK_URL;\n\t\tscript.async = true;\n\t\tscript.addEventListener(\"load\", onLoad);\n\t\tscript.addEventListener(\"error\", onError);\n\t\tdocument.head.appendChild(script);\n\t});\n\n\tloadPromises.set(env, promise);\n\treturn promise;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAM,WAA+C;AAAA,EACpD,YAAY;AAAA,EACZ,MAAM;AACP;AAGA,IAAM,eAAe,oBAAI,IAAkD;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/loader.ts"],"sourcesContent":["export { loadTapipay } from \"./loader\";\nexport type {\n\tLoadTapipayOptions,\n\tTapipayAutopayActivatedEvent,\n\tTapipayAutopayAdhesionSummary,\n\tTapipayAutopayErrorEvent,\n\tTapipayAutopayLoadedEvent,\n\tTapipayAutopayMediaType,\n\tTapipayAutopayRemovedEvent,\n\tTapipayDomiciliationAccountType,\n\tTapipayDomiciliationBankSelectedEvent,\n\tTapipayDomiciliationConfirmedEvent,\n\tTapipayDomiciliationFormCompletedEvent,\n\tTapipayDomiciliationVerificationCompletedEvent,\n\tTapipayDomiciliationVerificationMethod,\n\tTapipayEnvironment,\n\tTapipayInstance,\n\tTapipayOptions,\n\tTapipayPaymentCancelledEvent,\n\tTapipayPaymentSubmittedEvent,\n\tTapipayPaymentWindowOpenedEvent,\n\tTapipayView,\n} from \"./types\";\n","import type {\n\tLoadTapipayOptions,\n\tTapipayEnvironment,\n\tTapipayInstance,\n} from \"./types\";\n\nconst SDK_URLS: Record<TapipayEnvironment, string> = {\n\tproduction: \"https://app.tapipay.la/embed.js\",\n\thomo: \"https://homo.tapipay.la/embed.js\",\n};\n\n// Idempotencia por entorno\nconst loadPromises = new Map<TapipayEnvironment, Promise<TapipayInstance>>();\n\n/**\n * Carga el SDK de TapiPay de forma asíncrona inyectando el script en el DOM.\n *\n * - Idempotente por entorno: múltiples llamadas con el mismo `environment` retornan la misma Promise.\n * - Si window.tapipay ya existe (script cargado sync), resuelve inmediatamente.\n * - Compatible con React Strict Mode (doble mount/unmount).\n *\n * @example\n * // Producción (default)\n * const tapipay = await loadTapipay();\n *\n * // Homologación\n * const tapipay = await loadTapipay({ environment: 'homo' });\n *\n * // Se requiere UNO de { organization, companyCode } (companyCode tiene prioridad).\n * tapipay.initialize({ container: \"#widget\", organization: \"acme\", identifier: \"CLI-001\" });\n * tapipay.initialize({ container: \"#widget\", companyCode: \"acme-mx\", identifier: \"CLI-001\" });\n */\nexport function loadTapipay(\n\toptions?: LoadTapipayOptions,\n): Promise<TapipayInstance> {\n\tconst env: TapipayEnvironment = options?.environment ?? \"production\";\n\tconst SDK_URL = SDK_URLS[env];\n\tconst SCRIPT_ID = `tapipay-embed-sdk-${env}`;\n\n\t// SSR guard\n\tif (typeof window === \"undefined\") {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\"[TapiPay] loadTapipay() requires a browser environment.\"),\n\t\t);\n\t}\n\n\t// Ya cargado de forma síncrona (script tag directo)\n\tif (window.tapipay && !window.tapipay._q) {\n\t\treturn Promise.resolve(window.tapipay);\n\t}\n\n\t// Reutilizar promise existente (idempotencia por entorno)\n\tconst existing = loadPromises.get(env);\n\tif (existing) return existing;\n\n\tconst promise = new Promise<TapipayInstance>((resolve, reject) => {\n\t\t// Si ya hay un script inyectado, esperar a que cargue\n\t\tconst existingScript = document.getElementById(\n\t\t\tSCRIPT_ID,\n\t\t) as HTMLScriptElement | null;\n\n\t\tconst onLoad = () => {\n\t\t\tif (window.tapipay) {\n\t\t\t\tresolve(window.tapipay);\n\t\t\t} else {\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\"[TapiPay] El script cargó pero window.tapipay no está definido.\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst onError = () => {\n\t\t\tloadPromises.delete(env);\n\t\t\treject(new Error(`[TapiPay] Error al cargar el SDK desde ${SDK_URL}`));\n\t\t};\n\n\t\tif (existingScript) {\n\t\t\texistingScript.addEventListener(\"load\", onLoad);\n\t\t\texistingScript.addEventListener(\"error\", onError);\n\t\t\treturn;\n\t\t}\n\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.id = SCRIPT_ID;\n\t\tscript.src = SDK_URL;\n\t\tscript.async = true;\n\t\tscript.addEventListener(\"load\", onLoad);\n\t\tscript.addEventListener(\"error\", onError);\n\t\tdocument.head.appendChild(script);\n\t});\n\n\tloadPromises.set(env, promise);\n\treturn promise;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAM,WAA+C;AAAA,EACpD,YAAY;AAAA,EACZ,MAAM;AACP;AAGA,IAAM,eAAe,oBAAI,IAAkD;AAoBpE,SAAS,YACf,SAC2B;AAlC5B;AAmCC,QAAM,OAA0B,wCAAS,gBAAT,YAAwB;AACxD,QAAM,UAAU,SAAS,GAAG;AAC5B,QAAM,YAAY,qBAAqB,GAAG;AAG1C,MAAI,OAAO,WAAW,aAAa;AAClC,WAAO,QAAQ;AAAA,MACd,IAAI,MAAM,yDAAyD;AAAA,IACpE;AAAA,EACD;AAGA,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,IAAI;AACzC,WAAO,QAAQ,QAAQ,OAAO,OAAO;AAAA,EACtC;AAGA,QAAM,WAAW,aAAa,IAAI,GAAG;AACrC,MAAI,SAAU,QAAO;AAErB,QAAM,UAAU,IAAI,QAAyB,CAAC,SAAS,WAAW;AAEjE,UAAM,iBAAiB,SAAS;AAAA,MAC/B;AAAA,IACD;AAEA,UAAM,SAAS,MAAM;AACpB,UAAI,OAAO,SAAS;AACnB,gBAAQ,OAAO,OAAO;AAAA,MACvB,OAAO;AACN;AAAA,UACC,IAAI;AAAA,YACH;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,UAAU,MAAM;AACrB,mBAAa,OAAO,GAAG;AACvB,aAAO,IAAI,MAAM,0CAA0C,OAAO,EAAE,CAAC;AAAA,IACtE;AAEA,QAAI,gBAAgB;AACnB,qBAAe,iBAAiB,QAAQ,MAAM;AAC9C,qBAAe,iBAAiB,SAAS,OAAO;AAChD;AAAA,IACD;AAEA,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,KAAK;AACZ,WAAO,MAAM;AACb,WAAO,QAAQ;AACf,WAAO,iBAAiB,QAAQ,MAAM;AACtC,WAAO,iBAAiB,SAAS,OAAO;AACxC,aAAS,KAAK,YAAY,MAAM;AAAA,EACjC,CAAC;AAED,eAAa,IAAI,KAAK,OAAO;AAC7B,SAAO;AACR;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LoadTapipayOptions, T as TapipayInstance } from './types-
|
|
2
|
-
export { a as TapipayAutopayActivatedEvent, b as TapipayAutopayAdhesionSummary, c as TapipayAutopayErrorEvent, d as TapipayAutopayLoadedEvent, e as TapipayAutopayMediaType, f as TapipayAutopayRemovedEvent, g as
|
|
1
|
+
import { L as LoadTapipayOptions, T as TapipayInstance } from './types-CJRvC3_b.cjs';
|
|
2
|
+
export { a as TapipayAutopayActivatedEvent, b as TapipayAutopayAdhesionSummary, c as TapipayAutopayErrorEvent, d as TapipayAutopayLoadedEvent, e as TapipayAutopayMediaType, f as TapipayAutopayRemovedEvent, g as TapipayDomiciliationAccountType, h as TapipayDomiciliationBankSelectedEvent, i as TapipayDomiciliationConfirmedEvent, j as TapipayDomiciliationFormCompletedEvent, k as TapipayDomiciliationVerificationCompletedEvent, l as TapipayDomiciliationVerificationMethod, m as TapipayEnvironment, n as TapipayOptions, o as TapipayPaymentCancelledEvent, p as TapipayPaymentSubmittedEvent, q as TapipayPaymentWindowOpenedEvent, r as TapipayView } from './types-CJRvC3_b.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Carga el SDK de TapiPay de forma asíncrona inyectando el script en el DOM.
|
|
@@ -15,7 +15,9 @@ export { a as TapipayAutopayActivatedEvent, b as TapipayAutopayAdhesionSummary,
|
|
|
15
15
|
* // Homologación
|
|
16
16
|
* const tapipay = await loadTapipay({ environment: 'homo' });
|
|
17
17
|
*
|
|
18
|
+
* // Se requiere UNO de { organization, companyCode } (companyCode tiene prioridad).
|
|
18
19
|
* tapipay.initialize({ container: "#widget", organization: "acme", identifier: "CLI-001" });
|
|
20
|
+
* tapipay.initialize({ container: "#widget", companyCode: "acme-mx", identifier: "CLI-001" });
|
|
19
21
|
*/
|
|
20
22
|
declare function loadTapipay(options?: LoadTapipayOptions): Promise<TapipayInstance>;
|
|
21
23
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LoadTapipayOptions, T as TapipayInstance } from './types-
|
|
2
|
-
export { a as TapipayAutopayActivatedEvent, b as TapipayAutopayAdhesionSummary, c as TapipayAutopayErrorEvent, d as TapipayAutopayLoadedEvent, e as TapipayAutopayMediaType, f as TapipayAutopayRemovedEvent, g as
|
|
1
|
+
import { L as LoadTapipayOptions, T as TapipayInstance } from './types-CJRvC3_b.js';
|
|
2
|
+
export { a as TapipayAutopayActivatedEvent, b as TapipayAutopayAdhesionSummary, c as TapipayAutopayErrorEvent, d as TapipayAutopayLoadedEvent, e as TapipayAutopayMediaType, f as TapipayAutopayRemovedEvent, g as TapipayDomiciliationAccountType, h as TapipayDomiciliationBankSelectedEvent, i as TapipayDomiciliationConfirmedEvent, j as TapipayDomiciliationFormCompletedEvent, k as TapipayDomiciliationVerificationCompletedEvent, l as TapipayDomiciliationVerificationMethod, m as TapipayEnvironment, n as TapipayOptions, o as TapipayPaymentCancelledEvent, p as TapipayPaymentSubmittedEvent, q as TapipayPaymentWindowOpenedEvent, r as TapipayView } from './types-CJRvC3_b.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Carga el SDK de TapiPay de forma asíncrona inyectando el script en el DOM.
|
|
@@ -15,7 +15,9 @@ export { a as TapipayAutopayActivatedEvent, b as TapipayAutopayAdhesionSummary,
|
|
|
15
15
|
* // Homologación
|
|
16
16
|
* const tapipay = await loadTapipay({ environment: 'homo' });
|
|
17
17
|
*
|
|
18
|
+
* // Se requiere UNO de { organization, companyCode } (companyCode tiene prioridad).
|
|
18
19
|
* tapipay.initialize({ container: "#widget", organization: "acme", identifier: "CLI-001" });
|
|
20
|
+
* tapipay.initialize({ container: "#widget", companyCode: "acme-mx", identifier: "CLI-001" });
|
|
19
21
|
*/
|
|
20
22
|
declare function loadTapipay(options?: LoadTapipayOptions): Promise<TapipayInstance>;
|
|
21
23
|
|
package/dist/index.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -104,6 +104,7 @@ function useTapipay(options) {
|
|
|
104
104
|
}
|
|
105
105
|
function TapipayWidget({
|
|
106
106
|
organization,
|
|
107
|
+
companyCode,
|
|
107
108
|
identifier,
|
|
108
109
|
externalRequestId,
|
|
109
110
|
selectionStrategy,
|
|
@@ -116,6 +117,10 @@ function TapipayWidget({
|
|
|
116
117
|
onAutopayActivated,
|
|
117
118
|
onAutopayRemoved,
|
|
118
119
|
onAutopayError,
|
|
120
|
+
onDomiciliationBankSelected,
|
|
121
|
+
onDomiciliationFormCompleted,
|
|
122
|
+
onDomiciliationVerificationCompleted,
|
|
123
|
+
onDomiciliationConfirmed,
|
|
119
124
|
className,
|
|
120
125
|
style
|
|
121
126
|
}) {
|
|
@@ -127,6 +132,12 @@ function TapipayWidget({
|
|
|
127
132
|
const onAutopayActivatedRef = (0, import_react.useRef)(onAutopayActivated);
|
|
128
133
|
const onAutopayRemovedRef = (0, import_react.useRef)(onAutopayRemoved);
|
|
129
134
|
const onAutopayErrorRef = (0, import_react.useRef)(onAutopayError);
|
|
135
|
+
const onDomiciliationBankSelectedRef = (0, import_react.useRef)(onDomiciliationBankSelected);
|
|
136
|
+
const onDomiciliationFormCompletedRef = (0, import_react.useRef)(onDomiciliationFormCompleted);
|
|
137
|
+
const onDomiciliationVerificationCompletedRef = (0, import_react.useRef)(
|
|
138
|
+
onDomiciliationVerificationCompleted
|
|
139
|
+
);
|
|
140
|
+
const onDomiciliationConfirmedRef = (0, import_react.useRef)(onDomiciliationConfirmed);
|
|
130
141
|
(0, import_react.useEffect)(() => {
|
|
131
142
|
onPaymentWindowOpenedRef.current = onPaymentWindowOpened;
|
|
132
143
|
}, [onPaymentWindowOpened]);
|
|
@@ -148,6 +159,18 @@ function TapipayWidget({
|
|
|
148
159
|
(0, import_react.useEffect)(() => {
|
|
149
160
|
onAutopayErrorRef.current = onAutopayError;
|
|
150
161
|
}, [onAutopayError]);
|
|
162
|
+
(0, import_react.useEffect)(() => {
|
|
163
|
+
onDomiciliationBankSelectedRef.current = onDomiciliationBankSelected;
|
|
164
|
+
}, [onDomiciliationBankSelected]);
|
|
165
|
+
(0, import_react.useEffect)(() => {
|
|
166
|
+
onDomiciliationFormCompletedRef.current = onDomiciliationFormCompleted;
|
|
167
|
+
}, [onDomiciliationFormCompleted]);
|
|
168
|
+
(0, import_react.useEffect)(() => {
|
|
169
|
+
onDomiciliationVerificationCompletedRef.current = onDomiciliationVerificationCompleted;
|
|
170
|
+
}, [onDomiciliationVerificationCompleted]);
|
|
171
|
+
(0, import_react.useEffect)(() => {
|
|
172
|
+
onDomiciliationConfirmedRef.current = onDomiciliationConfirmed;
|
|
173
|
+
}, [onDomiciliationConfirmed]);
|
|
151
174
|
(0, import_react.useEffect)(() => {
|
|
152
175
|
if (!containerRef.current) return;
|
|
153
176
|
const container = containerRef.current;
|
|
@@ -181,6 +204,22 @@ function TapipayWidget({
|
|
|
181
204
|
var _a;
|
|
182
205
|
(_a = onAutopayErrorRef.current) == null ? void 0 : _a.call(onAutopayErrorRef, data);
|
|
183
206
|
};
|
|
207
|
+
const handleDomiciliationBankSelected = (data) => {
|
|
208
|
+
var _a;
|
|
209
|
+
(_a = onDomiciliationBankSelectedRef.current) == null ? void 0 : _a.call(onDomiciliationBankSelectedRef, data);
|
|
210
|
+
};
|
|
211
|
+
const handleDomiciliationFormCompleted = (data) => {
|
|
212
|
+
var _a;
|
|
213
|
+
(_a = onDomiciliationFormCompletedRef.current) == null ? void 0 : _a.call(onDomiciliationFormCompletedRef, data);
|
|
214
|
+
};
|
|
215
|
+
const handleDomiciliationVerificationCompleted = (data) => {
|
|
216
|
+
var _a;
|
|
217
|
+
(_a = onDomiciliationVerificationCompletedRef.current) == null ? void 0 : _a.call(onDomiciliationVerificationCompletedRef, data);
|
|
218
|
+
};
|
|
219
|
+
const handleDomiciliationConfirmed = (data) => {
|
|
220
|
+
var _a;
|
|
221
|
+
(_a = onDomiciliationConfirmedRef.current) == null ? void 0 : _a.call(onDomiciliationConfirmedRef, data);
|
|
222
|
+
};
|
|
184
223
|
loadTapipay({ environment }).then((instance) => {
|
|
185
224
|
if (cancelled) return;
|
|
186
225
|
tapipayInstance = instance;
|
|
@@ -191,9 +230,20 @@ function TapipayWidget({
|
|
|
191
230
|
instance.on("autopayActivated", handleAutopayActivated);
|
|
192
231
|
instance.on("autopayRemoved", handleAutopayRemoved);
|
|
193
232
|
instance.on("autopayError", handleAutopayError);
|
|
233
|
+
instance.on("domiciliationBankSelected", handleDomiciliationBankSelected);
|
|
234
|
+
instance.on(
|
|
235
|
+
"domiciliationFormCompleted",
|
|
236
|
+
handleDomiciliationFormCompleted
|
|
237
|
+
);
|
|
238
|
+
instance.on(
|
|
239
|
+
"domiciliationVerificationCompleted",
|
|
240
|
+
handleDomiciliationVerificationCompleted
|
|
241
|
+
);
|
|
242
|
+
instance.on("domiciliationConfirmed", handleDomiciliationConfirmed);
|
|
194
243
|
instance.initialize({
|
|
195
244
|
container,
|
|
196
245
|
organization,
|
|
246
|
+
companyCode,
|
|
197
247
|
identifier,
|
|
198
248
|
externalRequestId,
|
|
199
249
|
selectionStrategy,
|
|
@@ -210,11 +260,28 @@ function TapipayWidget({
|
|
|
210
260
|
tapipayInstance.off("autopayActivated", handleAutopayActivated);
|
|
211
261
|
tapipayInstance.off("autopayRemoved", handleAutopayRemoved);
|
|
212
262
|
tapipayInstance.off("autopayError", handleAutopayError);
|
|
263
|
+
tapipayInstance.off(
|
|
264
|
+
"domiciliationBankSelected",
|
|
265
|
+
handleDomiciliationBankSelected
|
|
266
|
+
);
|
|
267
|
+
tapipayInstance.off(
|
|
268
|
+
"domiciliationFormCompleted",
|
|
269
|
+
handleDomiciliationFormCompleted
|
|
270
|
+
);
|
|
271
|
+
tapipayInstance.off(
|
|
272
|
+
"domiciliationVerificationCompleted",
|
|
273
|
+
handleDomiciliationVerificationCompleted
|
|
274
|
+
);
|
|
275
|
+
tapipayInstance.off(
|
|
276
|
+
"domiciliationConfirmed",
|
|
277
|
+
handleDomiciliationConfirmed
|
|
278
|
+
);
|
|
213
279
|
tapipayInstance.destroy(container);
|
|
214
280
|
}
|
|
215
281
|
};
|
|
216
282
|
}, [
|
|
217
283
|
organization,
|
|
284
|
+
companyCode,
|
|
218
285
|
identifier,
|
|
219
286
|
externalRequestId,
|
|
220
287
|
selectionStrategy,
|
package/dist/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.tsx","../src/loader.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { loadTapipay } from \"./loader\";\nimport type {\n\tLoadTapipayOptions,\n\tTapipayAutopayActivatedEvent,\n\tTapipayAutopayErrorEvent,\n\tTapipayAutopayLoadedEvent,\n\tTapipayAutopayRemovedEvent,\n\tTapipayEnvironment,\n\tTapipayInstance,\n\tTapipayOptions,\n\tTapipayPaymentCancelledEvent,\n\tTapipayPaymentSubmittedEvent,\n\tTapipayPaymentWindowOpenedEvent,\n} from \"./types\";\n\n// ─── useTapipay hook ──────────────────────────────────────────────────────────\n\n/**\n * Hook de bajo nivel que carga el SDK y retorna la instancia.\n * Útil cuando necesitas control manual sobre initialize/destroy.\n *\n * @example\n * const { tapipay, error } = useTapipay();\n * const { tapipay, error } = useTapipay({ environment: 'homo' });\n */\nexport function useTapipay(options?: LoadTapipayOptions): {\n\ttapipay: TapipayInstance | null;\n\terror: Error | null;\n} {\n\tconst [tapipay, setTapipay] = useState<TapipayInstance | null>(null);\n\tconst [error, setError] = useState<Error | null>(null);\n\tconst environment = options?.environment;\n\n\tuseEffect(() => {\n\t\tlet cancelled = false;\n\t\tloadTapipay({ environment })\n\t\t\t.then((instance) => {\n\t\t\t\tif (!cancelled) setTapipay(instance);\n\t\t\t})\n\t\t\t.catch((err: Error) => {\n\t\t\t\tif (!cancelled) setError(err);\n\t\t\t});\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [environment]);\n\n\treturn { tapipay, error };\n}\n\n// ─── TapipayWidget component ──────────────────────────────────────────────────\n\nexport interface TapipayWidgetProps extends Omit<TapipayOptions, \"container\"> {\n\t/** Entorno del SDK a cargar. Por defecto `'production'`. Usar `'homo'` para homologación. */\n\tenvironment?: TapipayEnvironment;\n\t/** Callback invocado cuando el popup de Yuno se abre exitosamente. */\n\tonPaymentWindowOpened?: (data: TapipayPaymentWindowOpenedEvent) => void;\n\t/** Callback invocado cuando el usuario completó el formulario de Yuno y fue redirigido al callback. */\n\tonPaymentSubmitted?: (data: TapipayPaymentSubmittedEvent) => void;\n\t/** Callback invocado cuando el usuario cierra el popup sin completar el pago. */\n\tonCancelled?: (data: TapipayPaymentCancelledEvent) => void;\n\t/** (Vista autopay) Callback con el conjunto de adhesiones activas; se reinvoca cuando la lista cambia. */\n\tonAutopayLoaded?: (data: TapipayAutopayLoadedEvent) => void;\n\t/** (Vista autopay) Callback cuando una nueva adhesión queda activa (una sola vez por adhesión nueva). */\n\tonAutopayActivated?: (data: TapipayAutopayActivatedEvent) => void;\n\t/** (Vista autopay) Callback cuando el usuario desadhiere un medio con éxito. */\n\tonAutopayRemoved?: (data: TapipayAutopayRemovedEvent) => void;\n\t/** (Vista autopay) Callback ante un error de carga de adhesiones o de desadhesión. */\n\tonAutopayError?: (data: TapipayAutopayErrorEvent) => void;\n\t/** Clases CSS adicionales para el contenedor del widget. */\n\tclassName?: string;\n\t/** Estilos inline adicionales para el contenedor del widget. */\n\tstyle?: React.CSSProperties;\n}\n\n/**\n * Componente React que encapsula el widget de pago TapiPay.\n *\n * Maneja internamente la carga del SDK, el ciclo de vida del widget\n * y el cleanup al desmontar. Compatible con React Strict Mode.\n *\n * @example\n * // Vista de pagos (default)\n * <TapipayWidget\n * organization=\"acme\"\n * identifier=\"CLI-001\"\n * externalRequestId=\"FAC-2024-001\"\n * onPaymentSubmitted={(data) => console.log(\"Pago enviado\", data)}\n * onCancelled={() => console.log(\"Pago cancelado por el usuario\")}\n * />\n *\n * @example\n * // Vista de gestión de adhesiones de autopay\n * <TapipayWidget\n * organization=\"acme\"\n * identifier=\"CLI-001\"\n * view=\"autopay\"\n * onAutopayLoaded={(data) => console.log(\"Adhesiones\", data.count)}\n * onAutopayActivated={(data) => console.log(\"Adhesión activada\", data.id)}\n * onAutopayRemoved={(data) => console.log(\"Adhesión eliminada\", data.id)}\n * />\n */\nexport function TapipayWidget({\n\torganization,\n\tidentifier,\n\texternalRequestId,\n\tselectionStrategy,\n\tview,\n\tenvironment,\n\tonPaymentWindowOpened,\n\tonPaymentSubmitted,\n\tonCancelled,\n\tonAutopayLoaded,\n\tonAutopayActivated,\n\tonAutopayRemoved,\n\tonAutopayError,\n\tclassName,\n\tstyle,\n}: TapipayWidgetProps) {\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\t// Refs para evitar re-renders innecesarios y closures estáticos en useEffect\n\tconst onPaymentWindowOpenedRef = useRef(onPaymentWindowOpened);\n\tconst onPaymentSubmittedRef = useRef(onPaymentSubmitted);\n\tconst onCancelledRef = useRef(onCancelled);\n\tconst onAutopayLoadedRef = useRef(onAutopayLoaded);\n\tconst onAutopayActivatedRef = useRef(onAutopayActivated);\n\tconst onAutopayRemovedRef = useRef(onAutopayRemoved);\n\tconst onAutopayErrorRef = useRef(onAutopayError);\n\n\tuseEffect(() => {\n\t\tonPaymentWindowOpenedRef.current = onPaymentWindowOpened;\n\t}, [onPaymentWindowOpened]);\n\n\tuseEffect(() => {\n\t\tonPaymentSubmittedRef.current = onPaymentSubmitted;\n\t}, [onPaymentSubmitted]);\n\n\tuseEffect(() => {\n\t\tonCancelledRef.current = onCancelled;\n\t}, [onCancelled]);\n\n\tuseEffect(() => {\n\t\tonAutopayLoadedRef.current = onAutopayLoaded;\n\t}, [onAutopayLoaded]);\n\n\tuseEffect(() => {\n\t\tonAutopayActivatedRef.current = onAutopayActivated;\n\t}, [onAutopayActivated]);\n\n\tuseEffect(() => {\n\t\tonAutopayRemovedRef.current = onAutopayRemoved;\n\t}, [onAutopayRemoved]);\n\n\tuseEffect(() => {\n\t\tonAutopayErrorRef.current = onAutopayError;\n\t}, [onAutopayError]);\n\n\tuseEffect(() => {\n\t\tif (!containerRef.current) return;\n\t\tconst container = containerRef.current;\n\n\t\tlet tapipayInstance: TapipayInstance | null = null;\n\t\tlet cancelled = false;\n\n\t\tconst handlePaymentWindowOpened = (\n\t\t\tdata: TapipayPaymentWindowOpenedEvent,\n\t\t) => {\n\t\t\tonPaymentWindowOpenedRef.current?.(data);\n\t\t};\n\t\tconst handlePaymentSubmitted = (data: TapipayPaymentSubmittedEvent) => {\n\t\t\tonPaymentSubmittedRef.current?.(data);\n\t\t};\n\t\tconst handleCancelled = (data: TapipayPaymentCancelledEvent) => {\n\t\t\tonCancelledRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayLoaded = (data: TapipayAutopayLoadedEvent) => {\n\t\t\tonAutopayLoadedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayActivated = (data: TapipayAutopayActivatedEvent) => {\n\t\t\tonAutopayActivatedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayRemoved = (data: TapipayAutopayRemovedEvent) => {\n\t\t\tonAutopayRemovedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayError = (data: TapipayAutopayErrorEvent) => {\n\t\t\tonAutopayErrorRef.current?.(data);\n\t\t};\n\n\t\tloadTapipay({ environment }).then((instance) => {\n\t\t\tif (cancelled) return;\n\t\t\ttapipayInstance = instance;\n\n\t\t\tinstance.on(\"paymentWindowOpened\", handlePaymentWindowOpened);\n\t\t\tinstance.on(\"paymentSubmitted\", handlePaymentSubmitted);\n\t\t\tinstance.on(\"paymentCancelled\", handleCancelled);\n\t\t\tinstance.on(\"autopayLoaded\", handleAutopayLoaded);\n\t\t\tinstance.on(\"autopayActivated\", handleAutopayActivated);\n\t\t\tinstance.on(\"autopayRemoved\", handleAutopayRemoved);\n\t\t\tinstance.on(\"autopayError\", handleAutopayError);\n\n\t\t\tinstance.initialize({\n\t\t\t\tcontainer,\n\t\t\t\torganization,\n\t\t\t\tidentifier,\n\t\t\t\texternalRequestId,\n\t\t\t\tselectionStrategy,\n\t\t\t\tview,\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t\tif (tapipayInstance) {\n\t\t\t\ttapipayInstance.off(\"paymentWindowOpened\", handlePaymentWindowOpened);\n\t\t\t\ttapipayInstance.off(\"paymentSubmitted\", handlePaymentSubmitted);\n\t\t\t\ttapipayInstance.off(\"paymentCancelled\", handleCancelled);\n\t\t\t\ttapipayInstance.off(\"autopayLoaded\", handleAutopayLoaded);\n\t\t\t\ttapipayInstance.off(\"autopayActivated\", handleAutopayActivated);\n\t\t\t\ttapipayInstance.off(\"autopayRemoved\", handleAutopayRemoved);\n\t\t\t\ttapipayInstance.off(\"autopayError\", handleAutopayError);\n\t\t\t\ttapipayInstance.destroy(container);\n\t\t\t}\n\t\t};\n\t\t// El widget se re-monta si cambian los parámetros de identificación o entorno\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [\n\t\torganization,\n\t\tidentifier,\n\t\texternalRequestId,\n\t\tselectionStrategy,\n\t\tview,\n\t\tenvironment,\n\t]);\n\n\treturn <div ref={containerRef} className={className} style={style} />;\n}\n","import type {\n\tLoadTapipayOptions,\n\tTapipayEnvironment,\n\tTapipayInstance,\n} from \"./types\";\n\nconst SDK_URLS: Record<TapipayEnvironment, string> = {\n\tproduction: \"https://app.tapipay.la/embed.js\",\n\thomo: \"https://homo.tapipay.la/embed.js\",\n};\n\n// Idempotencia por entorno\nconst loadPromises = new Map<TapipayEnvironment, Promise<TapipayInstance>>();\n\n/**\n * Carga el SDK de TapiPay de forma asíncrona inyectando el script en el DOM.\n *\n * - Idempotente por entorno: múltiples llamadas con el mismo `environment` retornan la misma Promise.\n * - Si window.tapipay ya existe (script cargado sync), resuelve inmediatamente.\n * - Compatible con React Strict Mode (doble mount/unmount).\n *\n * @example\n * // Producción (default)\n * const tapipay = await loadTapipay();\n *\n * // Homologación\n * const tapipay = await loadTapipay({ environment: 'homo' });\n *\n * tapipay.initialize({ container: \"#widget\", organization: \"acme\", identifier: \"CLI-001\" });\n */\nexport function loadTapipay(\n\toptions?: LoadTapipayOptions,\n): Promise<TapipayInstance> {\n\tconst env: TapipayEnvironment = options?.environment ?? \"production\";\n\tconst SDK_URL = SDK_URLS[env];\n\tconst SCRIPT_ID = `tapipay-embed-sdk-${env}`;\n\n\t// SSR guard\n\tif (typeof window === \"undefined\") {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\"[TapiPay] loadTapipay() requires a browser environment.\"),\n\t\t);\n\t}\n\n\t// Ya cargado de forma síncrona (script tag directo)\n\tif (window.tapipay && !window.tapipay._q) {\n\t\treturn Promise.resolve(window.tapipay);\n\t}\n\n\t// Reutilizar promise existente (idempotencia por entorno)\n\tconst existing = loadPromises.get(env);\n\tif (existing) return existing;\n\n\tconst promise = new Promise<TapipayInstance>((resolve, reject) => {\n\t\t// Si ya hay un script inyectado, esperar a que cargue\n\t\tconst existingScript = document.getElementById(\n\t\t\tSCRIPT_ID,\n\t\t) as HTMLScriptElement | null;\n\n\t\tconst onLoad = () => {\n\t\t\tif (window.tapipay) {\n\t\t\t\tresolve(window.tapipay);\n\t\t\t} else {\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\"[TapiPay] El script cargó pero window.tapipay no está definido.\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst onError = () => {\n\t\t\tloadPromises.delete(env);\n\t\t\treject(new Error(`[TapiPay] Error al cargar el SDK desde ${SDK_URL}`));\n\t\t};\n\n\t\tif (existingScript) {\n\t\t\texistingScript.addEventListener(\"load\", onLoad);\n\t\t\texistingScript.addEventListener(\"error\", onError);\n\t\t\treturn;\n\t\t}\n\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.id = SCRIPT_ID;\n\t\tscript.src = SDK_URL;\n\t\tscript.async = true;\n\t\tscript.addEventListener(\"load\", onLoad);\n\t\tscript.addEventListener(\"error\", onError);\n\t\tdocument.head.appendChild(script);\n\t});\n\n\tloadPromises.set(env, promise);\n\treturn promise;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;;;ACM5C,IAAM,WAA+C;AAAA,EACpD,YAAY;AAAA,EACZ,MAAM;AACP;AAGA,IAAM,eAAe,oBAAI,IAAkD;AAkBpE,SAAS,YACf,SAC2B;AAhC5B;AAiCC,QAAM,OAA0B,wCAAS,gBAAT,YAAwB;AACxD,QAAM,UAAU,SAAS,GAAG;AAC5B,QAAM,YAAY,qBAAqB,GAAG;AAG1C,MAAI,OAAO,WAAW,aAAa;AAClC,WAAO,QAAQ;AAAA,MACd,IAAI,MAAM,yDAAyD;AAAA,IACpE;AAAA,EACD;AAGA,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,IAAI;AACzC,WAAO,QAAQ,QAAQ,OAAO,OAAO;AAAA,EACtC;AAGA,QAAM,WAAW,aAAa,IAAI,GAAG;AACrC,MAAI,SAAU,QAAO;AAErB,QAAM,UAAU,IAAI,QAAyB,CAAC,SAAS,WAAW;AAEjE,UAAM,iBAAiB,SAAS;AAAA,MAC/B;AAAA,IACD;AAEA,UA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,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC;AAED,SAAO,4CAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AACpE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx","../src/loader.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { loadTapipay } from \"./loader\";\nimport type {\n\tLoadTapipayOptions,\n\tTapipayAutopayActivatedEvent,\n\tTapipayAutopayErrorEvent,\n\tTapipayAutopayLoadedEvent,\n\tTapipayAutopayRemovedEvent,\n\tTapipayDomiciliationBankSelectedEvent,\n\tTapipayDomiciliationConfirmedEvent,\n\tTapipayDomiciliationFormCompletedEvent,\n\tTapipayDomiciliationVerificationCompletedEvent,\n\tTapipayEnvironment,\n\tTapipayInstance,\n\tTapipayOptions,\n\tTapipayPaymentCancelledEvent,\n\tTapipayPaymentSubmittedEvent,\n\tTapipayPaymentWindowOpenedEvent,\n} from \"./types\";\n\n// ─── useTapipay hook ──────────────────────────────────────────────────────────\n\n/**\n * Hook de bajo nivel que carga el SDK y retorna la instancia.\n * Útil cuando necesitas control manual sobre initialize/destroy.\n *\n * @example\n * const { tapipay, error } = useTapipay();\n * const { tapipay, error } = useTapipay({ environment: 'homo' });\n */\nexport function useTapipay(options?: LoadTapipayOptions): {\n\ttapipay: TapipayInstance | null;\n\terror: Error | null;\n} {\n\tconst [tapipay, setTapipay] = useState<TapipayInstance | null>(null);\n\tconst [error, setError] = useState<Error | null>(null);\n\tconst environment = options?.environment;\n\n\tuseEffect(() => {\n\t\tlet cancelled = false;\n\t\tloadTapipay({ environment })\n\t\t\t.then((instance) => {\n\t\t\t\tif (!cancelled) setTapipay(instance);\n\t\t\t})\n\t\t\t.catch((err: Error) => {\n\t\t\t\tif (!cancelled) setError(err);\n\t\t\t});\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [environment]);\n\n\treturn { tapipay, error };\n}\n\n// ─── TapipayWidget component ──────────────────────────────────────────────────\n\nexport interface TapipayWidgetProps extends Omit<TapipayOptions, \"container\"> {\n\t/** Entorno del SDK a cargar. Por defecto `'production'`. Usar `'homo'` para homologación. */\n\tenvironment?: TapipayEnvironment;\n\t/** Callback invocado cuando el popup de Yuno se abre exitosamente. */\n\tonPaymentWindowOpened?: (data: TapipayPaymentWindowOpenedEvent) => void;\n\t/** Callback invocado cuando el usuario completó el formulario de Yuno y fue redirigido al callback. */\n\tonPaymentSubmitted?: (data: TapipayPaymentSubmittedEvent) => void;\n\t/** Callback invocado cuando el usuario cierra el popup sin completar el pago. */\n\tonCancelled?: (data: TapipayPaymentCancelledEvent) => void;\n\t/** (Vista autopay) Callback con el conjunto de adhesiones activas; se reinvoca cuando la lista cambia. */\n\tonAutopayLoaded?: (data: TapipayAutopayLoadedEvent) => void;\n\t/** (Vista autopay) Callback cuando una nueva adhesión queda activa (una sola vez por adhesión nueva). */\n\tonAutopayActivated?: (data: TapipayAutopayActivatedEvent) => void;\n\t/** (Vista autopay) Callback cuando el usuario desadhiere un medio con éxito. */\n\tonAutopayRemoved?: (data: TapipayAutopayRemovedEvent) => void;\n\t/** (Vista autopay) Callback ante un error de carga de adhesiones o de desadhesión. */\n\tonAutopayError?: (data: TapipayAutopayErrorEvent) => void;\n\t/** (Vista autopay) El usuario eligió su banco en el alta de domiciliación. Emite en cada cambio de selección. */\n\tonDomiciliationBankSelected?: (\n\t\tdata: TapipayDomiciliationBankSelectedEvent,\n\t) => void;\n\t/** (Vista autopay) Los datos de la cuenta pasaron la validación del backend. Ojo: dispara al confirmar el método de verificación, no al salir del formulario. */\n\tonDomiciliationFormCompleted?: (\n\t\tdata: TapipayDomiciliationFormCompletedEvent,\n\t) => void;\n\t/** (Vista autopay) La verificación llegó a un desenlace. Solo emite al outcome final: un intento fallido con reintentos disponibles NO dispara el evento. */\n\tonDomiciliationVerificationCompleted?: (\n\t\tdata: TapipayDomiciliationVerificationCompletedEvent,\n\t) => void;\n\t/** (Vista autopay) El usuario confirmó la domiciliación. NO significa que quedó registrada — la confirmación real llega por `onAutopayActivated`. */\n\tonDomiciliationConfirmed?: (data: TapipayDomiciliationConfirmedEvent) => void;\n\t/** Clases CSS adicionales para el contenedor del widget. */\n\tclassName?: string;\n\t/** Estilos inline adicionales para el contenedor del widget. */\n\tstyle?: React.CSSProperties;\n}\n\n/**\n * Componente React que encapsula el widget de pago TapiPay.\n *\n * Maneja internamente la carga del SDK, el ciclo de vida del widget\n * y el cleanup al desmontar. Compatible con React Strict Mode.\n *\n * Se requiere `identifier` + UNO de `{ organization, companyCode }`.\n * Si se pasan ambos, `companyCode` tiene prioridad.\n *\n * @example\n * // Vista de pagos (default)\n * <TapipayWidget\n * organization=\"acme\"\n * identifier=\"CLI-001\"\n * externalRequestId=\"FAC-2024-001\"\n * onPaymentSubmitted={(data) => console.log(\"Pago enviado\", data)}\n * onCancelled={() => console.log(\"Pago cancelado por el usuario\")}\n * />\n *\n * @example\n * // Usando companyCode en lugar de organization\n * <TapipayWidget companyCode=\"acme-mx\" identifier=\"CLI-001\" />\n *\n * @example\n * // Vista de gestión de adhesiones de autopay\n * <TapipayWidget\n * organization=\"acme\"\n * identifier=\"CLI-001\"\n * view=\"autopay\"\n * onAutopayLoaded={(data) => console.log(\"Adhesiones\", data.count)}\n * onAutopayActivated={(data) => console.log(\"Adhesión activada\", data.id)}\n * onAutopayRemoved={(data) => console.log(\"Adhesión eliminada\", data.id)}\n * onDomiciliationBankSelected={(data) => console.log(\"Banco\", data.name)}\n * onDomiciliationFormCompleted={(data) => console.log(\"Cuenta ****\" + data.lastFour)}\n * onDomiciliationVerificationCompleted={(data) => console.log(\"Verificación\", data.outcome)}\n * onDomiciliationConfirmed={() => console.log(\"Enviado — esperar onAutopayActivated\")}\n * />\n */\nexport function TapipayWidget({\n\torganization,\n\tcompanyCode,\n\tidentifier,\n\texternalRequestId,\n\tselectionStrategy,\n\tview,\n\tenvironment,\n\tonPaymentWindowOpened,\n\tonPaymentSubmitted,\n\tonCancelled,\n\tonAutopayLoaded,\n\tonAutopayActivated,\n\tonAutopayRemoved,\n\tonAutopayError,\n\tonDomiciliationBankSelected,\n\tonDomiciliationFormCompleted,\n\tonDomiciliationVerificationCompleted,\n\tonDomiciliationConfirmed,\n\tclassName,\n\tstyle,\n}: TapipayWidgetProps) {\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\t// Refs para evitar re-renders innecesarios y closures estáticos en useEffect\n\tconst onPaymentWindowOpenedRef = useRef(onPaymentWindowOpened);\n\tconst onPaymentSubmittedRef = useRef(onPaymentSubmitted);\n\tconst onCancelledRef = useRef(onCancelled);\n\tconst onAutopayLoadedRef = useRef(onAutopayLoaded);\n\tconst onAutopayActivatedRef = useRef(onAutopayActivated);\n\tconst onAutopayRemovedRef = useRef(onAutopayRemoved);\n\tconst onAutopayErrorRef = useRef(onAutopayError);\n\tconst onDomiciliationBankSelectedRef = useRef(onDomiciliationBankSelected);\n\tconst onDomiciliationFormCompletedRef = useRef(onDomiciliationFormCompleted);\n\tconst onDomiciliationVerificationCompletedRef = useRef(\n\t\tonDomiciliationVerificationCompleted,\n\t);\n\tconst onDomiciliationConfirmedRef = useRef(onDomiciliationConfirmed);\n\n\tuseEffect(() => {\n\t\tonPaymentWindowOpenedRef.current = onPaymentWindowOpened;\n\t}, [onPaymentWindowOpened]);\n\n\tuseEffect(() => {\n\t\tonPaymentSubmittedRef.current = onPaymentSubmitted;\n\t}, [onPaymentSubmitted]);\n\n\tuseEffect(() => {\n\t\tonCancelledRef.current = onCancelled;\n\t}, [onCancelled]);\n\n\tuseEffect(() => {\n\t\tonAutopayLoadedRef.current = onAutopayLoaded;\n\t}, [onAutopayLoaded]);\n\n\tuseEffect(() => {\n\t\tonAutopayActivatedRef.current = onAutopayActivated;\n\t}, [onAutopayActivated]);\n\n\tuseEffect(() => {\n\t\tonAutopayRemovedRef.current = onAutopayRemoved;\n\t}, [onAutopayRemoved]);\n\n\tuseEffect(() => {\n\t\tonAutopayErrorRef.current = onAutopayError;\n\t}, [onAutopayError]);\n\n\tuseEffect(() => {\n\t\tonDomiciliationBankSelectedRef.current = onDomiciliationBankSelected;\n\t}, [onDomiciliationBankSelected]);\n\n\tuseEffect(() => {\n\t\tonDomiciliationFormCompletedRef.current = onDomiciliationFormCompleted;\n\t}, [onDomiciliationFormCompleted]);\n\n\tuseEffect(() => {\n\t\tonDomiciliationVerificationCompletedRef.current =\n\t\t\tonDomiciliationVerificationCompleted;\n\t}, [onDomiciliationVerificationCompleted]);\n\n\tuseEffect(() => {\n\t\tonDomiciliationConfirmedRef.current = onDomiciliationConfirmed;\n\t}, [onDomiciliationConfirmed]);\n\n\tuseEffect(() => {\n\t\tif (!containerRef.current) return;\n\t\tconst container = containerRef.current;\n\n\t\tlet tapipayInstance: TapipayInstance | null = null;\n\t\tlet cancelled = false;\n\n\t\tconst handlePaymentWindowOpened = (\n\t\t\tdata: TapipayPaymentWindowOpenedEvent,\n\t\t) => {\n\t\t\tonPaymentWindowOpenedRef.current?.(data);\n\t\t};\n\t\tconst handlePaymentSubmitted = (data: TapipayPaymentSubmittedEvent) => {\n\t\t\tonPaymentSubmittedRef.current?.(data);\n\t\t};\n\t\tconst handleCancelled = (data: TapipayPaymentCancelledEvent) => {\n\t\t\tonCancelledRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayLoaded = (data: TapipayAutopayLoadedEvent) => {\n\t\t\tonAutopayLoadedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayActivated = (data: TapipayAutopayActivatedEvent) => {\n\t\t\tonAutopayActivatedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayRemoved = (data: TapipayAutopayRemovedEvent) => {\n\t\t\tonAutopayRemovedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayError = (data: TapipayAutopayErrorEvent) => {\n\t\t\tonAutopayErrorRef.current?.(data);\n\t\t};\n\t\tconst handleDomiciliationBankSelected = (\n\t\t\tdata: TapipayDomiciliationBankSelectedEvent,\n\t\t) => {\n\t\t\tonDomiciliationBankSelectedRef.current?.(data);\n\t\t};\n\t\tconst handleDomiciliationFormCompleted = (\n\t\t\tdata: TapipayDomiciliationFormCompletedEvent,\n\t\t) => {\n\t\t\tonDomiciliationFormCompletedRef.current?.(data);\n\t\t};\n\t\tconst handleDomiciliationVerificationCompleted = (\n\t\t\tdata: TapipayDomiciliationVerificationCompletedEvent,\n\t\t) => {\n\t\t\tonDomiciliationVerificationCompletedRef.current?.(data);\n\t\t};\n\t\tconst handleDomiciliationConfirmed = (\n\t\t\tdata: TapipayDomiciliationConfirmedEvent,\n\t\t) => {\n\t\t\tonDomiciliationConfirmedRef.current?.(data);\n\t\t};\n\n\t\tloadTapipay({ environment }).then((instance) => {\n\t\t\tif (cancelled) return;\n\t\t\ttapipayInstance = instance;\n\n\t\t\tinstance.on(\"paymentWindowOpened\", handlePaymentWindowOpened);\n\t\t\tinstance.on(\"paymentSubmitted\", handlePaymentSubmitted);\n\t\t\tinstance.on(\"paymentCancelled\", handleCancelled);\n\t\t\tinstance.on(\"autopayLoaded\", handleAutopayLoaded);\n\t\t\tinstance.on(\"autopayActivated\", handleAutopayActivated);\n\t\t\tinstance.on(\"autopayRemoved\", handleAutopayRemoved);\n\t\t\tinstance.on(\"autopayError\", handleAutopayError);\n\t\t\tinstance.on(\"domiciliationBankSelected\", handleDomiciliationBankSelected);\n\t\t\tinstance.on(\n\t\t\t\t\"domiciliationFormCompleted\",\n\t\t\t\thandleDomiciliationFormCompleted,\n\t\t\t);\n\t\t\tinstance.on(\n\t\t\t\t\"domiciliationVerificationCompleted\",\n\t\t\t\thandleDomiciliationVerificationCompleted,\n\t\t\t);\n\t\t\tinstance.on(\"domiciliationConfirmed\", handleDomiciliationConfirmed);\n\n\t\t\tinstance.initialize({\n\t\t\t\tcontainer,\n\t\t\t\torganization,\n\t\t\t\tcompanyCode,\n\t\t\t\tidentifier,\n\t\t\t\texternalRequestId,\n\t\t\t\tselectionStrategy,\n\t\t\t\tview,\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t\tif (tapipayInstance) {\n\t\t\t\ttapipayInstance.off(\"paymentWindowOpened\", handlePaymentWindowOpened);\n\t\t\t\ttapipayInstance.off(\"paymentSubmitted\", handlePaymentSubmitted);\n\t\t\t\ttapipayInstance.off(\"paymentCancelled\", handleCancelled);\n\t\t\t\ttapipayInstance.off(\"autopayLoaded\", handleAutopayLoaded);\n\t\t\t\ttapipayInstance.off(\"autopayActivated\", handleAutopayActivated);\n\t\t\t\ttapipayInstance.off(\"autopayRemoved\", handleAutopayRemoved);\n\t\t\t\ttapipayInstance.off(\"autopayError\", handleAutopayError);\n\t\t\t\ttapipayInstance.off(\n\t\t\t\t\t\"domiciliationBankSelected\",\n\t\t\t\t\thandleDomiciliationBankSelected,\n\t\t\t\t);\n\t\t\t\ttapipayInstance.off(\n\t\t\t\t\t\"domiciliationFormCompleted\",\n\t\t\t\t\thandleDomiciliationFormCompleted,\n\t\t\t\t);\n\t\t\t\ttapipayInstance.off(\n\t\t\t\t\t\"domiciliationVerificationCompleted\",\n\t\t\t\t\thandleDomiciliationVerificationCompleted,\n\t\t\t\t);\n\t\t\t\ttapipayInstance.off(\n\t\t\t\t\t\"domiciliationConfirmed\",\n\t\t\t\t\thandleDomiciliationConfirmed,\n\t\t\t\t);\n\t\t\t\ttapipayInstance.destroy(container);\n\t\t\t}\n\t\t};\n\t\t// El widget se re-monta si cambian los parámetros de identificación o entorno\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [\n\t\torganization,\n\t\tcompanyCode,\n\t\tidentifier,\n\t\texternalRequestId,\n\t\tselectionStrategy,\n\t\tview,\n\t\tenvironment,\n\t]);\n\n\treturn <div ref={containerRef} className={className} style={style} />;\n}\n","import type {\n\tLoadTapipayOptions,\n\tTapipayEnvironment,\n\tTapipayInstance,\n} from \"./types\";\n\nconst SDK_URLS: Record<TapipayEnvironment, string> = {\n\tproduction: \"https://app.tapipay.la/embed.js\",\n\thomo: \"https://homo.tapipay.la/embed.js\",\n};\n\n// Idempotencia por entorno\nconst loadPromises = new Map<TapipayEnvironment, Promise<TapipayInstance>>();\n\n/**\n * Carga el SDK de TapiPay de forma asíncrona inyectando el script en el DOM.\n *\n * - Idempotente por entorno: múltiples llamadas con el mismo `environment` retornan la misma Promise.\n * - Si window.tapipay ya existe (script cargado sync), resuelve inmediatamente.\n * - Compatible con React Strict Mode (doble mount/unmount).\n *\n * @example\n * // Producción (default)\n * const tapipay = await loadTapipay();\n *\n * // Homologación\n * const tapipay = await loadTapipay({ environment: 'homo' });\n *\n * // Se requiere UNO de { organization, companyCode } (companyCode tiene prioridad).\n * tapipay.initialize({ container: \"#widget\", organization: \"acme\", identifier: \"CLI-001\" });\n * tapipay.initialize({ container: \"#widget\", companyCode: \"acme-mx\", identifier: \"CLI-001\" });\n */\nexport function loadTapipay(\n\toptions?: LoadTapipayOptions,\n): Promise<TapipayInstance> {\n\tconst env: TapipayEnvironment = options?.environment ?? \"production\";\n\tconst SDK_URL = SDK_URLS[env];\n\tconst SCRIPT_ID = `tapipay-embed-sdk-${env}`;\n\n\t// SSR guard\n\tif (typeof window === \"undefined\") {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\"[TapiPay] loadTapipay() requires a browser environment.\"),\n\t\t);\n\t}\n\n\t// Ya cargado de forma síncrona (script tag directo)\n\tif (window.tapipay && !window.tapipay._q) {\n\t\treturn Promise.resolve(window.tapipay);\n\t}\n\n\t// Reutilizar promise existente (idempotencia por entorno)\n\tconst existing = loadPromises.get(env);\n\tif (existing) return existing;\n\n\tconst promise = new Promise<TapipayInstance>((resolve, reject) => {\n\t\t// Si ya hay un script inyectado, esperar a que cargue\n\t\tconst existingScript = document.getElementById(\n\t\t\tSCRIPT_ID,\n\t\t) as HTMLScriptElement | null;\n\n\t\tconst onLoad = () => {\n\t\t\tif (window.tapipay) {\n\t\t\t\tresolve(window.tapipay);\n\t\t\t} else {\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\"[TapiPay] El script cargó pero window.tapipay no está definido.\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst onError = () => {\n\t\t\tloadPromises.delete(env);\n\t\t\treject(new Error(`[TapiPay] Error al cargar el SDK desde ${SDK_URL}`));\n\t\t};\n\n\t\tif (existingScript) {\n\t\t\texistingScript.addEventListener(\"load\", onLoad);\n\t\t\texistingScript.addEventListener(\"error\", onError);\n\t\t\treturn;\n\t\t}\n\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.id = SCRIPT_ID;\n\t\tscript.src = SDK_URL;\n\t\tscript.async = true;\n\t\tscript.addEventListener(\"load\", onLoad);\n\t\tscript.addEventListener(\"error\", onError);\n\t\tdocument.head.appendChild(script);\n\t});\n\n\tloadPromises.set(env, promise);\n\treturn promise;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;;;ACM5C,IAAM,WAA+C;AAAA,EACpD,YAAY;AAAA,EACZ,MAAM;AACP;AAGA,IAAM,eAAe,oBAAI,IAAkD;AAoBpE,SAAS,YACf,SAC2B;AAlC5B;AAmCC,QAAM,OAA0B,wCAAS,gBAAT,YAAwB;AACxD,QAAM,UAAU,SAAS,GAAG;AAC5B,QAAM,YAAY,qBAAqB,GAAG;AAG1C,MAAI,OAAO,WAAW,aAAa;AAClC,WAAO,QAAQ;AAAA,MACd,IAAI,MAAM,yDAAyD;AAAA,IACpE;AAAA,EACD;AAGA,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,IAAI;AACzC,WAAO,QAAQ,QAAQ,OAAO,OAAO;AAAA,EACtC;AAGA,QAAM,WAAW,aAAa,IAAI,GAAG;AACrC,MAAI,SAAU,QAAO;AAErB,QAAM,UAAU,IAAI,QAAyB,CAAC,SAAS,WAAW;AAEjE,UAAM,iBAAiB,SAAS;AAAA,MAC/B;AAAA,IACD;AAEA,UAAM,SAAS,MAAM;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AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC;AAED,SAAO,4CAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AACpE;","names":[]}
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { n as TapipayOptions, m as TapipayEnvironment, q as TapipayPaymentWindowOpenedEvent, p as TapipayPaymentSubmittedEvent, o as TapipayPaymentCancelledEvent, d as TapipayAutopayLoadedEvent, a as TapipayAutopayActivatedEvent, f as TapipayAutopayRemovedEvent, c as TapipayAutopayErrorEvent, h as TapipayDomiciliationBankSelectedEvent, j as TapipayDomiciliationFormCompletedEvent, k as TapipayDomiciliationVerificationCompletedEvent, i as TapipayDomiciliationConfirmedEvent, L as LoadTapipayOptions, T as TapipayInstance } from './types-CJRvC3_b.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Hook de bajo nivel que carga el SDK y retorna la instancia.
|
|
@@ -30,6 +30,14 @@ interface TapipayWidgetProps extends Omit<TapipayOptions, "container"> {
|
|
|
30
30
|
onAutopayRemoved?: (data: TapipayAutopayRemovedEvent) => void;
|
|
31
31
|
/** (Vista autopay) Callback ante un error de carga de adhesiones o de desadhesión. */
|
|
32
32
|
onAutopayError?: (data: TapipayAutopayErrorEvent) => void;
|
|
33
|
+
/** (Vista autopay) El usuario eligió su banco en el alta de domiciliación. Emite en cada cambio de selección. */
|
|
34
|
+
onDomiciliationBankSelected?: (data: TapipayDomiciliationBankSelectedEvent) => void;
|
|
35
|
+
/** (Vista autopay) Los datos de la cuenta pasaron la validación del backend. Ojo: dispara al confirmar el método de verificación, no al salir del formulario. */
|
|
36
|
+
onDomiciliationFormCompleted?: (data: TapipayDomiciliationFormCompletedEvent) => void;
|
|
37
|
+
/** (Vista autopay) La verificación llegó a un desenlace. Solo emite al outcome final: un intento fallido con reintentos disponibles NO dispara el evento. */
|
|
38
|
+
onDomiciliationVerificationCompleted?: (data: TapipayDomiciliationVerificationCompletedEvent) => void;
|
|
39
|
+
/** (Vista autopay) El usuario confirmó la domiciliación. NO significa que quedó registrada — la confirmación real llega por `onAutopayActivated`. */
|
|
40
|
+
onDomiciliationConfirmed?: (data: TapipayDomiciliationConfirmedEvent) => void;
|
|
33
41
|
/** Clases CSS adicionales para el contenedor del widget. */
|
|
34
42
|
className?: string;
|
|
35
43
|
/** Estilos inline adicionales para el contenedor del widget. */
|
|
@@ -41,6 +49,9 @@ interface TapipayWidgetProps extends Omit<TapipayOptions, "container"> {
|
|
|
41
49
|
* Maneja internamente la carga del SDK, el ciclo de vida del widget
|
|
42
50
|
* y el cleanup al desmontar. Compatible con React Strict Mode.
|
|
43
51
|
*
|
|
52
|
+
* Se requiere `identifier` + UNO de `{ organization, companyCode }`.
|
|
53
|
+
* Si se pasan ambos, `companyCode` tiene prioridad.
|
|
54
|
+
*
|
|
44
55
|
* @example
|
|
45
56
|
* // Vista de pagos (default)
|
|
46
57
|
* <TapipayWidget
|
|
@@ -52,6 +63,10 @@ interface TapipayWidgetProps extends Omit<TapipayOptions, "container"> {
|
|
|
52
63
|
* />
|
|
53
64
|
*
|
|
54
65
|
* @example
|
|
66
|
+
* // Usando companyCode en lugar de organization
|
|
67
|
+
* <TapipayWidget companyCode="acme-mx" identifier="CLI-001" />
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
55
70
|
* // Vista de gestión de adhesiones de autopay
|
|
56
71
|
* <TapipayWidget
|
|
57
72
|
* organization="acme"
|
|
@@ -60,8 +75,12 @@ interface TapipayWidgetProps extends Omit<TapipayOptions, "container"> {
|
|
|
60
75
|
* onAutopayLoaded={(data) => console.log("Adhesiones", data.count)}
|
|
61
76
|
* onAutopayActivated={(data) => console.log("Adhesión activada", data.id)}
|
|
62
77
|
* onAutopayRemoved={(data) => console.log("Adhesión eliminada", data.id)}
|
|
78
|
+
* onDomiciliationBankSelected={(data) => console.log("Banco", data.name)}
|
|
79
|
+
* onDomiciliationFormCompleted={(data) => console.log("Cuenta ****" + data.lastFour)}
|
|
80
|
+
* onDomiciliationVerificationCompleted={(data) => console.log("Verificación", data.outcome)}
|
|
81
|
+
* onDomiciliationConfirmed={() => console.log("Enviado — esperar onAutopayActivated")}
|
|
63
82
|
* />
|
|
64
83
|
*/
|
|
65
|
-
declare function TapipayWidget({ organization, identifier, externalRequestId, selectionStrategy, view, environment, onPaymentWindowOpened, onPaymentSubmitted, onCancelled, onAutopayLoaded, onAutopayActivated, onAutopayRemoved, onAutopayError, className, style, }: TapipayWidgetProps): react_jsx_runtime.JSX.Element;
|
|
84
|
+
declare function TapipayWidget({ organization, companyCode, identifier, externalRequestId, selectionStrategy, view, environment, onPaymentWindowOpened, onPaymentSubmitted, onCancelled, onAutopayLoaded, onAutopayActivated, onAutopayRemoved, onAutopayError, onDomiciliationBankSelected, onDomiciliationFormCompleted, onDomiciliationVerificationCompleted, onDomiciliationConfirmed, className, style, }: TapipayWidgetProps): react_jsx_runtime.JSX.Element;
|
|
66
85
|
|
|
67
86
|
export { TapipayWidget, type TapipayWidgetProps, useTapipay };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { n as TapipayOptions, m as TapipayEnvironment, q as TapipayPaymentWindowOpenedEvent, p as TapipayPaymentSubmittedEvent, o as TapipayPaymentCancelledEvent, d as TapipayAutopayLoadedEvent, a as TapipayAutopayActivatedEvent, f as TapipayAutopayRemovedEvent, c as TapipayAutopayErrorEvent, h as TapipayDomiciliationBankSelectedEvent, j as TapipayDomiciliationFormCompletedEvent, k as TapipayDomiciliationVerificationCompletedEvent, i as TapipayDomiciliationConfirmedEvent, L as LoadTapipayOptions, T as TapipayInstance } from './types-CJRvC3_b.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Hook de bajo nivel que carga el SDK y retorna la instancia.
|
|
@@ -30,6 +30,14 @@ interface TapipayWidgetProps extends Omit<TapipayOptions, "container"> {
|
|
|
30
30
|
onAutopayRemoved?: (data: TapipayAutopayRemovedEvent) => void;
|
|
31
31
|
/** (Vista autopay) Callback ante un error de carga de adhesiones o de desadhesión. */
|
|
32
32
|
onAutopayError?: (data: TapipayAutopayErrorEvent) => void;
|
|
33
|
+
/** (Vista autopay) El usuario eligió su banco en el alta de domiciliación. Emite en cada cambio de selección. */
|
|
34
|
+
onDomiciliationBankSelected?: (data: TapipayDomiciliationBankSelectedEvent) => void;
|
|
35
|
+
/** (Vista autopay) Los datos de la cuenta pasaron la validación del backend. Ojo: dispara al confirmar el método de verificación, no al salir del formulario. */
|
|
36
|
+
onDomiciliationFormCompleted?: (data: TapipayDomiciliationFormCompletedEvent) => void;
|
|
37
|
+
/** (Vista autopay) La verificación llegó a un desenlace. Solo emite al outcome final: un intento fallido con reintentos disponibles NO dispara el evento. */
|
|
38
|
+
onDomiciliationVerificationCompleted?: (data: TapipayDomiciliationVerificationCompletedEvent) => void;
|
|
39
|
+
/** (Vista autopay) El usuario confirmó la domiciliación. NO significa que quedó registrada — la confirmación real llega por `onAutopayActivated`. */
|
|
40
|
+
onDomiciliationConfirmed?: (data: TapipayDomiciliationConfirmedEvent) => void;
|
|
33
41
|
/** Clases CSS adicionales para el contenedor del widget. */
|
|
34
42
|
className?: string;
|
|
35
43
|
/** Estilos inline adicionales para el contenedor del widget. */
|
|
@@ -41,6 +49,9 @@ interface TapipayWidgetProps extends Omit<TapipayOptions, "container"> {
|
|
|
41
49
|
* Maneja internamente la carga del SDK, el ciclo de vida del widget
|
|
42
50
|
* y el cleanup al desmontar. Compatible con React Strict Mode.
|
|
43
51
|
*
|
|
52
|
+
* Se requiere `identifier` + UNO de `{ organization, companyCode }`.
|
|
53
|
+
* Si se pasan ambos, `companyCode` tiene prioridad.
|
|
54
|
+
*
|
|
44
55
|
* @example
|
|
45
56
|
* // Vista de pagos (default)
|
|
46
57
|
* <TapipayWidget
|
|
@@ -52,6 +63,10 @@ interface TapipayWidgetProps extends Omit<TapipayOptions, "container"> {
|
|
|
52
63
|
* />
|
|
53
64
|
*
|
|
54
65
|
* @example
|
|
66
|
+
* // Usando companyCode en lugar de organization
|
|
67
|
+
* <TapipayWidget companyCode="acme-mx" identifier="CLI-001" />
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
55
70
|
* // Vista de gestión de adhesiones de autopay
|
|
56
71
|
* <TapipayWidget
|
|
57
72
|
* organization="acme"
|
|
@@ -60,8 +75,12 @@ interface TapipayWidgetProps extends Omit<TapipayOptions, "container"> {
|
|
|
60
75
|
* onAutopayLoaded={(data) => console.log("Adhesiones", data.count)}
|
|
61
76
|
* onAutopayActivated={(data) => console.log("Adhesión activada", data.id)}
|
|
62
77
|
* onAutopayRemoved={(data) => console.log("Adhesión eliminada", data.id)}
|
|
78
|
+
* onDomiciliationBankSelected={(data) => console.log("Banco", data.name)}
|
|
79
|
+
* onDomiciliationFormCompleted={(data) => console.log("Cuenta ****" + data.lastFour)}
|
|
80
|
+
* onDomiciliationVerificationCompleted={(data) => console.log("Verificación", data.outcome)}
|
|
81
|
+
* onDomiciliationConfirmed={() => console.log("Enviado — esperar onAutopayActivated")}
|
|
63
82
|
* />
|
|
64
83
|
*/
|
|
65
|
-
declare function TapipayWidget({ organization, identifier, externalRequestId, selectionStrategy, view, environment, onPaymentWindowOpened, onPaymentSubmitted, onCancelled, onAutopayLoaded, onAutopayActivated, onAutopayRemoved, onAutopayError, className, style, }: TapipayWidgetProps): react_jsx_runtime.JSX.Element;
|
|
84
|
+
declare function TapipayWidget({ organization, companyCode, identifier, externalRequestId, selectionStrategy, view, environment, onPaymentWindowOpened, onPaymentSubmitted, onCancelled, onAutopayLoaded, onAutopayActivated, onAutopayRemoved, onAutopayError, onDomiciliationBankSelected, onDomiciliationFormCompleted, onDomiciliationVerificationCompleted, onDomiciliationConfirmed, className, style, }: TapipayWidgetProps): react_jsx_runtime.JSX.Element;
|
|
66
85
|
|
|
67
86
|
export { TapipayWidget, type TapipayWidgetProps, useTapipay };
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadTapipay
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IZQ3PVG6.js";
|
|
4
4
|
|
|
5
5
|
// src/react.tsx
|
|
6
6
|
import { useEffect, useRef, useState } from "react";
|
|
@@ -24,6 +24,7 @@ function useTapipay(options) {
|
|
|
24
24
|
}
|
|
25
25
|
function TapipayWidget({
|
|
26
26
|
organization,
|
|
27
|
+
companyCode,
|
|
27
28
|
identifier,
|
|
28
29
|
externalRequestId,
|
|
29
30
|
selectionStrategy,
|
|
@@ -36,6 +37,10 @@ function TapipayWidget({
|
|
|
36
37
|
onAutopayActivated,
|
|
37
38
|
onAutopayRemoved,
|
|
38
39
|
onAutopayError,
|
|
40
|
+
onDomiciliationBankSelected,
|
|
41
|
+
onDomiciliationFormCompleted,
|
|
42
|
+
onDomiciliationVerificationCompleted,
|
|
43
|
+
onDomiciliationConfirmed,
|
|
39
44
|
className,
|
|
40
45
|
style
|
|
41
46
|
}) {
|
|
@@ -47,6 +52,12 @@ function TapipayWidget({
|
|
|
47
52
|
const onAutopayActivatedRef = useRef(onAutopayActivated);
|
|
48
53
|
const onAutopayRemovedRef = useRef(onAutopayRemoved);
|
|
49
54
|
const onAutopayErrorRef = useRef(onAutopayError);
|
|
55
|
+
const onDomiciliationBankSelectedRef = useRef(onDomiciliationBankSelected);
|
|
56
|
+
const onDomiciliationFormCompletedRef = useRef(onDomiciliationFormCompleted);
|
|
57
|
+
const onDomiciliationVerificationCompletedRef = useRef(
|
|
58
|
+
onDomiciliationVerificationCompleted
|
|
59
|
+
);
|
|
60
|
+
const onDomiciliationConfirmedRef = useRef(onDomiciliationConfirmed);
|
|
50
61
|
useEffect(() => {
|
|
51
62
|
onPaymentWindowOpenedRef.current = onPaymentWindowOpened;
|
|
52
63
|
}, [onPaymentWindowOpened]);
|
|
@@ -68,6 +79,18 @@ function TapipayWidget({
|
|
|
68
79
|
useEffect(() => {
|
|
69
80
|
onAutopayErrorRef.current = onAutopayError;
|
|
70
81
|
}, [onAutopayError]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
onDomiciliationBankSelectedRef.current = onDomiciliationBankSelected;
|
|
84
|
+
}, [onDomiciliationBankSelected]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
onDomiciliationFormCompletedRef.current = onDomiciliationFormCompleted;
|
|
87
|
+
}, [onDomiciliationFormCompleted]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
onDomiciliationVerificationCompletedRef.current = onDomiciliationVerificationCompleted;
|
|
90
|
+
}, [onDomiciliationVerificationCompleted]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
onDomiciliationConfirmedRef.current = onDomiciliationConfirmed;
|
|
93
|
+
}, [onDomiciliationConfirmed]);
|
|
71
94
|
useEffect(() => {
|
|
72
95
|
if (!containerRef.current) return;
|
|
73
96
|
const container = containerRef.current;
|
|
@@ -101,6 +124,22 @@ function TapipayWidget({
|
|
|
101
124
|
var _a;
|
|
102
125
|
(_a = onAutopayErrorRef.current) == null ? void 0 : _a.call(onAutopayErrorRef, data);
|
|
103
126
|
};
|
|
127
|
+
const handleDomiciliationBankSelected = (data) => {
|
|
128
|
+
var _a;
|
|
129
|
+
(_a = onDomiciliationBankSelectedRef.current) == null ? void 0 : _a.call(onDomiciliationBankSelectedRef, data);
|
|
130
|
+
};
|
|
131
|
+
const handleDomiciliationFormCompleted = (data) => {
|
|
132
|
+
var _a;
|
|
133
|
+
(_a = onDomiciliationFormCompletedRef.current) == null ? void 0 : _a.call(onDomiciliationFormCompletedRef, data);
|
|
134
|
+
};
|
|
135
|
+
const handleDomiciliationVerificationCompleted = (data) => {
|
|
136
|
+
var _a;
|
|
137
|
+
(_a = onDomiciliationVerificationCompletedRef.current) == null ? void 0 : _a.call(onDomiciliationVerificationCompletedRef, data);
|
|
138
|
+
};
|
|
139
|
+
const handleDomiciliationConfirmed = (data) => {
|
|
140
|
+
var _a;
|
|
141
|
+
(_a = onDomiciliationConfirmedRef.current) == null ? void 0 : _a.call(onDomiciliationConfirmedRef, data);
|
|
142
|
+
};
|
|
104
143
|
loadTapipay({ environment }).then((instance) => {
|
|
105
144
|
if (cancelled) return;
|
|
106
145
|
tapipayInstance = instance;
|
|
@@ -111,9 +150,20 @@ function TapipayWidget({
|
|
|
111
150
|
instance.on("autopayActivated", handleAutopayActivated);
|
|
112
151
|
instance.on("autopayRemoved", handleAutopayRemoved);
|
|
113
152
|
instance.on("autopayError", handleAutopayError);
|
|
153
|
+
instance.on("domiciliationBankSelected", handleDomiciliationBankSelected);
|
|
154
|
+
instance.on(
|
|
155
|
+
"domiciliationFormCompleted",
|
|
156
|
+
handleDomiciliationFormCompleted
|
|
157
|
+
);
|
|
158
|
+
instance.on(
|
|
159
|
+
"domiciliationVerificationCompleted",
|
|
160
|
+
handleDomiciliationVerificationCompleted
|
|
161
|
+
);
|
|
162
|
+
instance.on("domiciliationConfirmed", handleDomiciliationConfirmed);
|
|
114
163
|
instance.initialize({
|
|
115
164
|
container,
|
|
116
165
|
organization,
|
|
166
|
+
companyCode,
|
|
117
167
|
identifier,
|
|
118
168
|
externalRequestId,
|
|
119
169
|
selectionStrategy,
|
|
@@ -130,11 +180,28 @@ function TapipayWidget({
|
|
|
130
180
|
tapipayInstance.off("autopayActivated", handleAutopayActivated);
|
|
131
181
|
tapipayInstance.off("autopayRemoved", handleAutopayRemoved);
|
|
132
182
|
tapipayInstance.off("autopayError", handleAutopayError);
|
|
183
|
+
tapipayInstance.off(
|
|
184
|
+
"domiciliationBankSelected",
|
|
185
|
+
handleDomiciliationBankSelected
|
|
186
|
+
);
|
|
187
|
+
tapipayInstance.off(
|
|
188
|
+
"domiciliationFormCompleted",
|
|
189
|
+
handleDomiciliationFormCompleted
|
|
190
|
+
);
|
|
191
|
+
tapipayInstance.off(
|
|
192
|
+
"domiciliationVerificationCompleted",
|
|
193
|
+
handleDomiciliationVerificationCompleted
|
|
194
|
+
);
|
|
195
|
+
tapipayInstance.off(
|
|
196
|
+
"domiciliationConfirmed",
|
|
197
|
+
handleDomiciliationConfirmed
|
|
198
|
+
);
|
|
133
199
|
tapipayInstance.destroy(container);
|
|
134
200
|
}
|
|
135
201
|
};
|
|
136
202
|
}, [
|
|
137
203
|
organization,
|
|
204
|
+
companyCode,
|
|
138
205
|
identifier,
|
|
139
206
|
externalRequestId,
|
|
140
207
|
selectionStrategy,
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { loadTapipay } from \"./loader\";\nimport type {\n\tLoadTapipayOptions,\n\tTapipayAutopayActivatedEvent,\n\tTapipayAutopayErrorEvent,\n\tTapipayAutopayLoadedEvent,\n\tTapipayAutopayRemovedEvent,\n\tTapipayEnvironment,\n\tTapipayInstance,\n\tTapipayOptions,\n\tTapipayPaymentCancelledEvent,\n\tTapipayPaymentSubmittedEvent,\n\tTapipayPaymentWindowOpenedEvent,\n} from \"./types\";\n\n// ─── useTapipay hook ──────────────────────────────────────────────────────────\n\n/**\n * Hook de bajo nivel que carga el SDK y retorna la instancia.\n * Útil cuando necesitas control manual sobre initialize/destroy.\n *\n * @example\n * const { tapipay, error } = useTapipay();\n * const { tapipay, error } = useTapipay({ environment: 'homo' });\n */\nexport function useTapipay(options?: LoadTapipayOptions): {\n\ttapipay: TapipayInstance | null;\n\terror: Error | null;\n} {\n\tconst [tapipay, setTapipay] = useState<TapipayInstance | null>(null);\n\tconst [error, setError] = useState<Error | null>(null);\n\tconst environment = options?.environment;\n\n\tuseEffect(() => {\n\t\tlet cancelled = false;\n\t\tloadTapipay({ environment })\n\t\t\t.then((instance) => {\n\t\t\t\tif (!cancelled) setTapipay(instance);\n\t\t\t})\n\t\t\t.catch((err: Error) => {\n\t\t\t\tif (!cancelled) setError(err);\n\t\t\t});\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [environment]);\n\n\treturn { tapipay, error };\n}\n\n// ─── TapipayWidget component ──────────────────────────────────────────────────\n\nexport interface TapipayWidgetProps extends Omit<TapipayOptions, \"container\"> {\n\t/** Entorno del SDK a cargar. Por defecto `'production'`. Usar `'homo'` para homologación. */\n\tenvironment?: TapipayEnvironment;\n\t/** Callback invocado cuando el popup de Yuno se abre exitosamente. */\n\tonPaymentWindowOpened?: (data: TapipayPaymentWindowOpenedEvent) => void;\n\t/** Callback invocado cuando el usuario completó el formulario de Yuno y fue redirigido al callback. */\n\tonPaymentSubmitted?: (data: TapipayPaymentSubmittedEvent) => void;\n\t/** Callback invocado cuando el usuario cierra el popup sin completar el pago. */\n\tonCancelled?: (data: TapipayPaymentCancelledEvent) => void;\n\t/** (Vista autopay) Callback con el conjunto de adhesiones activas; se reinvoca cuando la lista cambia. */\n\tonAutopayLoaded?: (data: TapipayAutopayLoadedEvent) => void;\n\t/** (Vista autopay) Callback cuando una nueva adhesión queda activa (una sola vez por adhesión nueva). */\n\tonAutopayActivated?: (data: TapipayAutopayActivatedEvent) => void;\n\t/** (Vista autopay) Callback cuando el usuario desadhiere un medio con éxito. */\n\tonAutopayRemoved?: (data: TapipayAutopayRemovedEvent) => void;\n\t/** (Vista autopay) Callback ante un error de carga de adhesiones o de desadhesión. */\n\tonAutopayError?: (data: TapipayAutopayErrorEvent) => void;\n\t/** Clases CSS adicionales para el contenedor del widget. */\n\tclassName?: string;\n\t/** Estilos inline adicionales para el contenedor del widget. */\n\tstyle?: React.CSSProperties;\n}\n\n/**\n * Componente React que encapsula el widget de pago TapiPay.\n *\n * Maneja internamente la carga del SDK, el ciclo de vida del widget\n * y el cleanup al desmontar. Compatible con React Strict Mode.\n *\n * @example\n * // Vista de pagos (default)\n * <TapipayWidget\n * organization=\"acme\"\n * identifier=\"CLI-001\"\n * externalRequestId=\"FAC-2024-001\"\n * onPaymentSubmitted={(data) => console.log(\"Pago enviado\", data)}\n * onCancelled={() => console.log(\"Pago cancelado por el usuario\")}\n * />\n *\n * @example\n * // Vista de gestión de adhesiones de autopay\n * <TapipayWidget\n * organization=\"acme\"\n * identifier=\"CLI-001\"\n * view=\"autopay\"\n * onAutopayLoaded={(data) => console.log(\"Adhesiones\", data.count)}\n * onAutopayActivated={(data) => console.log(\"Adhesión activada\", data.id)}\n * onAutopayRemoved={(data) => console.log(\"Adhesión eliminada\", data.id)}\n * />\n */\nexport function TapipayWidget({\n\torganization,\n\tidentifier,\n\texternalRequestId,\n\tselectionStrategy,\n\tview,\n\tenvironment,\n\tonPaymentWindowOpened,\n\tonPaymentSubmitted,\n\tonCancelled,\n\tonAutopayLoaded,\n\tonAutopayActivated,\n\tonAutopayRemoved,\n\tonAutopayError,\n\tclassName,\n\tstyle,\n}: TapipayWidgetProps) {\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\t// Refs para evitar re-renders innecesarios y closures estáticos en useEffect\n\tconst onPaymentWindowOpenedRef = useRef(onPaymentWindowOpened);\n\tconst onPaymentSubmittedRef = useRef(onPaymentSubmitted);\n\tconst onCancelledRef = useRef(onCancelled);\n\tconst onAutopayLoadedRef = useRef(onAutopayLoaded);\n\tconst onAutopayActivatedRef = useRef(onAutopayActivated);\n\tconst onAutopayRemovedRef = useRef(onAutopayRemoved);\n\tconst onAutopayErrorRef = useRef(onAutopayError);\n\n\tuseEffect(() => {\n\t\tonPaymentWindowOpenedRef.current = onPaymentWindowOpened;\n\t}, [onPaymentWindowOpened]);\n\n\tuseEffect(() => {\n\t\tonPaymentSubmittedRef.current = onPaymentSubmitted;\n\t}, [onPaymentSubmitted]);\n\n\tuseEffect(() => {\n\t\tonCancelledRef.current = onCancelled;\n\t}, [onCancelled]);\n\n\tuseEffect(() => {\n\t\tonAutopayLoadedRef.current = onAutopayLoaded;\n\t}, [onAutopayLoaded]);\n\n\tuseEffect(() => {\n\t\tonAutopayActivatedRef.current = onAutopayActivated;\n\t}, [onAutopayActivated]);\n\n\tuseEffect(() => {\n\t\tonAutopayRemovedRef.current = onAutopayRemoved;\n\t}, [onAutopayRemoved]);\n\n\tuseEffect(() => {\n\t\tonAutopayErrorRef.current = onAutopayError;\n\t}, [onAutopayError]);\n\n\tuseEffect(() => {\n\t\tif (!containerRef.current) return;\n\t\tconst container = containerRef.current;\n\n\t\tlet tapipayInstance: TapipayInstance | null = null;\n\t\tlet cancelled = false;\n\n\t\tconst handlePaymentWindowOpened = (\n\t\t\tdata: TapipayPaymentWindowOpenedEvent,\n\t\t) => {\n\t\t\tonPaymentWindowOpenedRef.current?.(data);\n\t\t};\n\t\tconst handlePaymentSubmitted = (data: TapipayPaymentSubmittedEvent) => {\n\t\t\tonPaymentSubmittedRef.current?.(data);\n\t\t};\n\t\tconst handleCancelled = (data: TapipayPaymentCancelledEvent) => {\n\t\t\tonCancelledRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayLoaded = (data: TapipayAutopayLoadedEvent) => {\n\t\t\tonAutopayLoadedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayActivated = (data: TapipayAutopayActivatedEvent) => {\n\t\t\tonAutopayActivatedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayRemoved = (data: TapipayAutopayRemovedEvent) => {\n\t\t\tonAutopayRemovedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayError = (data: TapipayAutopayErrorEvent) => {\n\t\t\tonAutopayErrorRef.current?.(data);\n\t\t};\n\n\t\tloadTapipay({ environment }).then((instance) => {\n\t\t\tif (cancelled) return;\n\t\t\ttapipayInstance = instance;\n\n\t\t\tinstance.on(\"paymentWindowOpened\", handlePaymentWindowOpened);\n\t\t\tinstance.on(\"paymentSubmitted\", handlePaymentSubmitted);\n\t\t\tinstance.on(\"paymentCancelled\", handleCancelled);\n\t\t\tinstance.on(\"autopayLoaded\", handleAutopayLoaded);\n\t\t\tinstance.on(\"autopayActivated\", handleAutopayActivated);\n\t\t\tinstance.on(\"autopayRemoved\", handleAutopayRemoved);\n\t\t\tinstance.on(\"autopayError\", handleAutopayError);\n\n\t\t\tinstance.initialize({\n\t\t\t\tcontainer,\n\t\t\t\torganization,\n\t\t\t\tidentifier,\n\t\t\t\texternalRequestId,\n\t\t\t\tselectionStrategy,\n\t\t\t\tview,\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t\tif (tapipayInstance) {\n\t\t\t\ttapipayInstance.off(\"paymentWindowOpened\", handlePaymentWindowOpened);\n\t\t\t\ttapipayInstance.off(\"paymentSubmitted\", handlePaymentSubmitted);\n\t\t\t\ttapipayInstance.off(\"paymentCancelled\", handleCancelled);\n\t\t\t\ttapipayInstance.off(\"autopayLoaded\", handleAutopayLoaded);\n\t\t\t\ttapipayInstance.off(\"autopayActivated\", handleAutopayActivated);\n\t\t\t\ttapipayInstance.off(\"autopayRemoved\", handleAutopayRemoved);\n\t\t\t\ttapipayInstance.off(\"autopayError\", handleAutopayError);\n\t\t\t\ttapipayInstance.destroy(container);\n\t\t\t}\n\t\t};\n\t\t// El widget se re-monta si cambian los parámetros de identificación o entorno\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [\n\t\torganization,\n\t\tidentifier,\n\t\texternalRequestId,\n\t\tselectionStrategy,\n\t\tview,\n\t\tenvironment,\n\t]);\n\n\treturn <div ref={containerRef} className={className} style={style} />;\n}\n"],"mappings":";;;;;AAAA,SAAS,WAAW,QAAQ,gBAAgB;AA2OpC;AAjND,SAAS,WAAW,SAGzB;AACD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAiC,IAAI;AACnE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AACrD,QAAM,cAAc,mCAAS;AAE7B,YAAU,MAAM;AACf,QAAI,YAAY;AAChB,gBAAY,EAAE,YAAY,CAAC,EACzB,KAAK,CAAC,aAAa;AACnB,UAAI,CAAC,UAAW,YAAW,QAAQ;AAAA,IACpC,CAAC,EACA,MAAM,CAAC,QAAe;AACtB,UAA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AAoB,eAAe;AACvD,wBAAgB,IAAI,iBAAiB,mBAAmB;AACxD,wBAAgB,IAAI,oBAAoB,sBAAsB;AAC9D,wBAAgB,IAAI,kBAAkB,oBAAoB;AAC1D,wBAAgB,IAAI,gBAAgB,kBAAkB;AACtD,wBAAgB,QAAQ,SAAS;AAAA,MAClC;AAAA,IACD;AAAA,EAGD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC;AAED,SAAO,oBAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AACpE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { loadTapipay } from \"./loader\";\nimport type {\n\tLoadTapipayOptions,\n\tTapipayAutopayActivatedEvent,\n\tTapipayAutopayErrorEvent,\n\tTapipayAutopayLoadedEvent,\n\tTapipayAutopayRemovedEvent,\n\tTapipayDomiciliationBankSelectedEvent,\n\tTapipayDomiciliationConfirmedEvent,\n\tTapipayDomiciliationFormCompletedEvent,\n\tTapipayDomiciliationVerificationCompletedEvent,\n\tTapipayEnvironment,\n\tTapipayInstance,\n\tTapipayOptions,\n\tTapipayPaymentCancelledEvent,\n\tTapipayPaymentSubmittedEvent,\n\tTapipayPaymentWindowOpenedEvent,\n} from \"./types\";\n\n// ─── useTapipay hook ──────────────────────────────────────────────────────────\n\n/**\n * Hook de bajo nivel que carga el SDK y retorna la instancia.\n * Útil cuando necesitas control manual sobre initialize/destroy.\n *\n * @example\n * const { tapipay, error } = useTapipay();\n * const { tapipay, error } = useTapipay({ environment: 'homo' });\n */\nexport function useTapipay(options?: LoadTapipayOptions): {\n\ttapipay: TapipayInstance | null;\n\terror: Error | null;\n} {\n\tconst [tapipay, setTapipay] = useState<TapipayInstance | null>(null);\n\tconst [error, setError] = useState<Error | null>(null);\n\tconst environment = options?.environment;\n\n\tuseEffect(() => {\n\t\tlet cancelled = false;\n\t\tloadTapipay({ environment })\n\t\t\t.then((instance) => {\n\t\t\t\tif (!cancelled) setTapipay(instance);\n\t\t\t})\n\t\t\t.catch((err: Error) => {\n\t\t\t\tif (!cancelled) setError(err);\n\t\t\t});\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [environment]);\n\n\treturn { tapipay, error };\n}\n\n// ─── TapipayWidget component ──────────────────────────────────────────────────\n\nexport interface TapipayWidgetProps extends Omit<TapipayOptions, \"container\"> {\n\t/** Entorno del SDK a cargar. Por defecto `'production'`. Usar `'homo'` para homologación. */\n\tenvironment?: TapipayEnvironment;\n\t/** Callback invocado cuando el popup de Yuno se abre exitosamente. */\n\tonPaymentWindowOpened?: (data: TapipayPaymentWindowOpenedEvent) => void;\n\t/** Callback invocado cuando el usuario completó el formulario de Yuno y fue redirigido al callback. */\n\tonPaymentSubmitted?: (data: TapipayPaymentSubmittedEvent) => void;\n\t/** Callback invocado cuando el usuario cierra el popup sin completar el pago. */\n\tonCancelled?: (data: TapipayPaymentCancelledEvent) => void;\n\t/** (Vista autopay) Callback con el conjunto de adhesiones activas; se reinvoca cuando la lista cambia. */\n\tonAutopayLoaded?: (data: TapipayAutopayLoadedEvent) => void;\n\t/** (Vista autopay) Callback cuando una nueva adhesión queda activa (una sola vez por adhesión nueva). */\n\tonAutopayActivated?: (data: TapipayAutopayActivatedEvent) => void;\n\t/** (Vista autopay) Callback cuando el usuario desadhiere un medio con éxito. */\n\tonAutopayRemoved?: (data: TapipayAutopayRemovedEvent) => void;\n\t/** (Vista autopay) Callback ante un error de carga de adhesiones o de desadhesión. */\n\tonAutopayError?: (data: TapipayAutopayErrorEvent) => void;\n\t/** (Vista autopay) El usuario eligió su banco en el alta de domiciliación. Emite en cada cambio de selección. */\n\tonDomiciliationBankSelected?: (\n\t\tdata: TapipayDomiciliationBankSelectedEvent,\n\t) => void;\n\t/** (Vista autopay) Los datos de la cuenta pasaron la validación del backend. Ojo: dispara al confirmar el método de verificación, no al salir del formulario. */\n\tonDomiciliationFormCompleted?: (\n\t\tdata: TapipayDomiciliationFormCompletedEvent,\n\t) => void;\n\t/** (Vista autopay) La verificación llegó a un desenlace. Solo emite al outcome final: un intento fallido con reintentos disponibles NO dispara el evento. */\n\tonDomiciliationVerificationCompleted?: (\n\t\tdata: TapipayDomiciliationVerificationCompletedEvent,\n\t) => void;\n\t/** (Vista autopay) El usuario confirmó la domiciliación. NO significa que quedó registrada — la confirmación real llega por `onAutopayActivated`. */\n\tonDomiciliationConfirmed?: (data: TapipayDomiciliationConfirmedEvent) => void;\n\t/** Clases CSS adicionales para el contenedor del widget. */\n\tclassName?: string;\n\t/** Estilos inline adicionales para el contenedor del widget. */\n\tstyle?: React.CSSProperties;\n}\n\n/**\n * Componente React que encapsula el widget de pago TapiPay.\n *\n * Maneja internamente la carga del SDK, el ciclo de vida del widget\n * y el cleanup al desmontar. Compatible con React Strict Mode.\n *\n * Se requiere `identifier` + UNO de `{ organization, companyCode }`.\n * Si se pasan ambos, `companyCode` tiene prioridad.\n *\n * @example\n * // Vista de pagos (default)\n * <TapipayWidget\n * organization=\"acme\"\n * identifier=\"CLI-001\"\n * externalRequestId=\"FAC-2024-001\"\n * onPaymentSubmitted={(data) => console.log(\"Pago enviado\", data)}\n * onCancelled={() => console.log(\"Pago cancelado por el usuario\")}\n * />\n *\n * @example\n * // Usando companyCode en lugar de organization\n * <TapipayWidget companyCode=\"acme-mx\" identifier=\"CLI-001\" />\n *\n * @example\n * // Vista de gestión de adhesiones de autopay\n * <TapipayWidget\n * organization=\"acme\"\n * identifier=\"CLI-001\"\n * view=\"autopay\"\n * onAutopayLoaded={(data) => console.log(\"Adhesiones\", data.count)}\n * onAutopayActivated={(data) => console.log(\"Adhesión activada\", data.id)}\n * onAutopayRemoved={(data) => console.log(\"Adhesión eliminada\", data.id)}\n * onDomiciliationBankSelected={(data) => console.log(\"Banco\", data.name)}\n * onDomiciliationFormCompleted={(data) => console.log(\"Cuenta ****\" + data.lastFour)}\n * onDomiciliationVerificationCompleted={(data) => console.log(\"Verificación\", data.outcome)}\n * onDomiciliationConfirmed={() => console.log(\"Enviado — esperar onAutopayActivated\")}\n * />\n */\nexport function TapipayWidget({\n\torganization,\n\tcompanyCode,\n\tidentifier,\n\texternalRequestId,\n\tselectionStrategy,\n\tview,\n\tenvironment,\n\tonPaymentWindowOpened,\n\tonPaymentSubmitted,\n\tonCancelled,\n\tonAutopayLoaded,\n\tonAutopayActivated,\n\tonAutopayRemoved,\n\tonAutopayError,\n\tonDomiciliationBankSelected,\n\tonDomiciliationFormCompleted,\n\tonDomiciliationVerificationCompleted,\n\tonDomiciliationConfirmed,\n\tclassName,\n\tstyle,\n}: TapipayWidgetProps) {\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\t// Refs para evitar re-renders innecesarios y closures estáticos en useEffect\n\tconst onPaymentWindowOpenedRef = useRef(onPaymentWindowOpened);\n\tconst onPaymentSubmittedRef = useRef(onPaymentSubmitted);\n\tconst onCancelledRef = useRef(onCancelled);\n\tconst onAutopayLoadedRef = useRef(onAutopayLoaded);\n\tconst onAutopayActivatedRef = useRef(onAutopayActivated);\n\tconst onAutopayRemovedRef = useRef(onAutopayRemoved);\n\tconst onAutopayErrorRef = useRef(onAutopayError);\n\tconst onDomiciliationBankSelectedRef = useRef(onDomiciliationBankSelected);\n\tconst onDomiciliationFormCompletedRef = useRef(onDomiciliationFormCompleted);\n\tconst onDomiciliationVerificationCompletedRef = useRef(\n\t\tonDomiciliationVerificationCompleted,\n\t);\n\tconst onDomiciliationConfirmedRef = useRef(onDomiciliationConfirmed);\n\n\tuseEffect(() => {\n\t\tonPaymentWindowOpenedRef.current = onPaymentWindowOpened;\n\t}, [onPaymentWindowOpened]);\n\n\tuseEffect(() => {\n\t\tonPaymentSubmittedRef.current = onPaymentSubmitted;\n\t}, [onPaymentSubmitted]);\n\n\tuseEffect(() => {\n\t\tonCancelledRef.current = onCancelled;\n\t}, [onCancelled]);\n\n\tuseEffect(() => {\n\t\tonAutopayLoadedRef.current = onAutopayLoaded;\n\t}, [onAutopayLoaded]);\n\n\tuseEffect(() => {\n\t\tonAutopayActivatedRef.current = onAutopayActivated;\n\t}, [onAutopayActivated]);\n\n\tuseEffect(() => {\n\t\tonAutopayRemovedRef.current = onAutopayRemoved;\n\t}, [onAutopayRemoved]);\n\n\tuseEffect(() => {\n\t\tonAutopayErrorRef.current = onAutopayError;\n\t}, [onAutopayError]);\n\n\tuseEffect(() => {\n\t\tonDomiciliationBankSelectedRef.current = onDomiciliationBankSelected;\n\t}, [onDomiciliationBankSelected]);\n\n\tuseEffect(() => {\n\t\tonDomiciliationFormCompletedRef.current = onDomiciliationFormCompleted;\n\t}, [onDomiciliationFormCompleted]);\n\n\tuseEffect(() => {\n\t\tonDomiciliationVerificationCompletedRef.current =\n\t\t\tonDomiciliationVerificationCompleted;\n\t}, [onDomiciliationVerificationCompleted]);\n\n\tuseEffect(() => {\n\t\tonDomiciliationConfirmedRef.current = onDomiciliationConfirmed;\n\t}, [onDomiciliationConfirmed]);\n\n\tuseEffect(() => {\n\t\tif (!containerRef.current) return;\n\t\tconst container = containerRef.current;\n\n\t\tlet tapipayInstance: TapipayInstance | null = null;\n\t\tlet cancelled = false;\n\n\t\tconst handlePaymentWindowOpened = (\n\t\t\tdata: TapipayPaymentWindowOpenedEvent,\n\t\t) => {\n\t\t\tonPaymentWindowOpenedRef.current?.(data);\n\t\t};\n\t\tconst handlePaymentSubmitted = (data: TapipayPaymentSubmittedEvent) => {\n\t\t\tonPaymentSubmittedRef.current?.(data);\n\t\t};\n\t\tconst handleCancelled = (data: TapipayPaymentCancelledEvent) => {\n\t\t\tonCancelledRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayLoaded = (data: TapipayAutopayLoadedEvent) => {\n\t\t\tonAutopayLoadedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayActivated = (data: TapipayAutopayActivatedEvent) => {\n\t\t\tonAutopayActivatedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayRemoved = (data: TapipayAutopayRemovedEvent) => {\n\t\t\tonAutopayRemovedRef.current?.(data);\n\t\t};\n\t\tconst handleAutopayError = (data: TapipayAutopayErrorEvent) => {\n\t\t\tonAutopayErrorRef.current?.(data);\n\t\t};\n\t\tconst handleDomiciliationBankSelected = (\n\t\t\tdata: TapipayDomiciliationBankSelectedEvent,\n\t\t) => {\n\t\t\tonDomiciliationBankSelectedRef.current?.(data);\n\t\t};\n\t\tconst handleDomiciliationFormCompleted = (\n\t\t\tdata: TapipayDomiciliationFormCompletedEvent,\n\t\t) => {\n\t\t\tonDomiciliationFormCompletedRef.current?.(data);\n\t\t};\n\t\tconst handleDomiciliationVerificationCompleted = (\n\t\t\tdata: TapipayDomiciliationVerificationCompletedEvent,\n\t\t) => {\n\t\t\tonDomiciliationVerificationCompletedRef.current?.(data);\n\t\t};\n\t\tconst handleDomiciliationConfirmed = (\n\t\t\tdata: TapipayDomiciliationConfirmedEvent,\n\t\t) => {\n\t\t\tonDomiciliationConfirmedRef.current?.(data);\n\t\t};\n\n\t\tloadTapipay({ environment }).then((instance) => {\n\t\t\tif (cancelled) return;\n\t\t\ttapipayInstance = instance;\n\n\t\t\tinstance.on(\"paymentWindowOpened\", handlePaymentWindowOpened);\n\t\t\tinstance.on(\"paymentSubmitted\", handlePaymentSubmitted);\n\t\t\tinstance.on(\"paymentCancelled\", handleCancelled);\n\t\t\tinstance.on(\"autopayLoaded\", handleAutopayLoaded);\n\t\t\tinstance.on(\"autopayActivated\", handleAutopayActivated);\n\t\t\tinstance.on(\"autopayRemoved\", handleAutopayRemoved);\n\t\t\tinstance.on(\"autopayError\", handleAutopayError);\n\t\t\tinstance.on(\"domiciliationBankSelected\", handleDomiciliationBankSelected);\n\t\t\tinstance.on(\n\t\t\t\t\"domiciliationFormCompleted\",\n\t\t\t\thandleDomiciliationFormCompleted,\n\t\t\t);\n\t\t\tinstance.on(\n\t\t\t\t\"domiciliationVerificationCompleted\",\n\t\t\t\thandleDomiciliationVerificationCompleted,\n\t\t\t);\n\t\t\tinstance.on(\"domiciliationConfirmed\", handleDomiciliationConfirmed);\n\n\t\t\tinstance.initialize({\n\t\t\t\tcontainer,\n\t\t\t\torganization,\n\t\t\t\tcompanyCode,\n\t\t\t\tidentifier,\n\t\t\t\texternalRequestId,\n\t\t\t\tselectionStrategy,\n\t\t\t\tview,\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t\tif (tapipayInstance) {\n\t\t\t\ttapipayInstance.off(\"paymentWindowOpened\", handlePaymentWindowOpened);\n\t\t\t\ttapipayInstance.off(\"paymentSubmitted\", handlePaymentSubmitted);\n\t\t\t\ttapipayInstance.off(\"paymentCancelled\", handleCancelled);\n\t\t\t\ttapipayInstance.off(\"autopayLoaded\", handleAutopayLoaded);\n\t\t\t\ttapipayInstance.off(\"autopayActivated\", handleAutopayActivated);\n\t\t\t\ttapipayInstance.off(\"autopayRemoved\", handleAutopayRemoved);\n\t\t\t\ttapipayInstance.off(\"autopayError\", handleAutopayError);\n\t\t\t\ttapipayInstance.off(\n\t\t\t\t\t\"domiciliationBankSelected\",\n\t\t\t\t\thandleDomiciliationBankSelected,\n\t\t\t\t);\n\t\t\t\ttapipayInstance.off(\n\t\t\t\t\t\"domiciliationFormCompleted\",\n\t\t\t\t\thandleDomiciliationFormCompleted,\n\t\t\t\t);\n\t\t\t\ttapipayInstance.off(\n\t\t\t\t\t\"domiciliationVerificationCompleted\",\n\t\t\t\t\thandleDomiciliationVerificationCompleted,\n\t\t\t\t);\n\t\t\t\ttapipayInstance.off(\n\t\t\t\t\t\"domiciliationConfirmed\",\n\t\t\t\t\thandleDomiciliationConfirmed,\n\t\t\t\t);\n\t\t\t\ttapipayInstance.destroy(container);\n\t\t\t}\n\t\t};\n\t\t// El widget se re-monta si cambian los parámetros de identificación o entorno\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [\n\t\torganization,\n\t\tcompanyCode,\n\t\tidentifier,\n\t\texternalRequestId,\n\t\tselectionStrategy,\n\t\tview,\n\t\tenvironment,\n\t]);\n\n\treturn <div ref={containerRef} className={className} style={style} />;\n}\n"],"mappings":";;;;;AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAoVpC;AAtTD,SAAS,WAAW,SAGzB;AACD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAiC,IAAI;AACnE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AACrD,QAAM,cAAc,mCAAS;AAE7B,YAAU,MAAM;AACf,QAAI,YAAY;AAChB,gBAAY,EAAE,YAAY,CAAC,EACzB,KAAK,CAAC,aAAa;AACnB,UAAI,CAAC,UAAW,YAAW,QAAQ;AAAA,IACpC,CAAC,EACA,MAAM,CAAC,QAAe;AACtB,UAAI,CAAC,UAAW,UAAS,GAAG;AAAA,IAC7B,CAAC;AACF,WAAO,MAAM;AACZ,kBAAY;AAAA,IACb;AAAA,EACD,GAAG,CAAC,WAAW,CAAC;AAEhB,SAAO,EAAE,SAAS,MAAM;AACzB;AA+EO,SAAS,cAAc;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAuB;AACtB,QAAM,eAAe,OAAuB,IAAI;AAEhD,QAAM,2BAA2B,OAAO,qBAAqB;AAC7D,QAAM,wBAAwB,OAAO,kBAAkB;AACvD,QAAM,iBAAiB,OAAO,WAAW;AACzC,QAAM,qBAAqB,OAAO,eAAe;AACjD,QAAM,wBAAwB,OAAO,kBAAkB;AACvD,QAAM,sBAAsB,OAAO,gBAAgB;AACnD,QAAM,oBAAoB,OAAO,cAAc;AAC/C,QAAM,iCAAiC,OAAO,2BAA2B;AACzE,QAAM,kCAAkC,OAAO,4BAA4B;AAC3E,QAAM,0CA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;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACZ,kBAAY;AACZ,UAAI,iBAAiB;AACpB,wBAAgB,IAAI,uBAAuB,yBAAyB;AACpE,wBAAgB,IAAI,oBAAoB,sBAAsB;AAC9D,wBAAgB,IAAI,oBAAoB,eAAe;AACvD,wBAAgB,IAAI,iBAAiB,mBAAmB;AACxD,wBAAgB,IAAI,oBAAoB,sBAAsB;AAC9D,wBAAgB,IAAI,kBAAkB,oBAAoB;AAC1D,wBAAgB,IAAI,gBAAgB,kBAAkB;AACtD,wBAAgB;AAAA,UACf;AAAA,UACA;AAAA,QACD;AACA,wBAAgB;AAAA,UACf;AAAA,UACA;AAAA,QACD;AACA,wBAAgB;AAAA,UACf;AAAA,UACA;AAAA,QACD;AACA,wBAAgB;AAAA,UACf;AAAA,UACA;AAAA,QACD;AACA,wBAAgB,QAAQ,SAAS;AAAA,MAClC;AAAA,IACD;AAAA,EAGD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC;AAED,SAAO,oBAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AACpE;","names":[]}
|
|
@@ -22,12 +22,23 @@ interface LoadTapipayOptions {
|
|
|
22
22
|
type TapipayView = "payments" | "autopay";
|
|
23
23
|
/**
|
|
24
24
|
* Opciones requeridas para montar el widget TapiPay.
|
|
25
|
+
*
|
|
26
|
+
* Se requiere `container` + `identifier` + UNO de `{ organization, companyCode }`.
|
|
27
|
+
* Si se pasan ambos, `companyCode` tiene prioridad.
|
|
25
28
|
*/
|
|
26
29
|
interface TapipayOptions {
|
|
27
30
|
/** Selector CSS o elemento DOM donde se montará el widget. */
|
|
28
31
|
container: string | HTMLElement;
|
|
29
|
-
/**
|
|
30
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Alias de la Organización configurado en el dashboard de TapiPay (ej. "acme"). Corresponde al campo "Alias" en Configuración → Organización.
|
|
34
|
+
* Se requiere `organization` O `companyCode`. Si se pasan ambos, `companyCode` tiene prioridad.
|
|
35
|
+
*/
|
|
36
|
+
organization?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Código de compañía de TapiPay (ej. "acme-mx"). Alternativa a `organization`.
|
|
39
|
+
* Se requiere `organization` O `companyCode`. Si se pasan ambos, `companyCode` tiene prioridad.
|
|
40
|
+
*/
|
|
41
|
+
companyCode?: string;
|
|
31
42
|
/** Identificador del cliente en el sistema del cliente (ej. "CLI-001"). */
|
|
32
43
|
identifier: string;
|
|
33
44
|
/** ID externo de la deuda a preseleccionar (ej. número de factura). Aplica a la vista de pagos. */
|
|
@@ -66,7 +77,7 @@ type TapipayPaymentCancelledEvent = Record<string, never>;
|
|
|
66
77
|
* Tipo de medio adherido expuesto al sitio cliente.
|
|
67
78
|
* Solo se expone el tipo lógico, nunca la marca ni el banco.
|
|
68
79
|
*/
|
|
69
|
-
type TapipayAutopayMediaType = "card" | "bank_account";
|
|
80
|
+
type TapipayAutopayMediaType = "card" | "bank_account" | "debit_card";
|
|
70
81
|
/**
|
|
71
82
|
* Resumen mínimo y seguro de una adhesión activa.
|
|
72
83
|
* Privacidad: solo tipo de medio + últimos 4 dígitos. El `id` es un hash opaco
|
|
@@ -129,6 +140,73 @@ interface TapipayAutopayErrorEvent {
|
|
|
129
140
|
/** Mensaje neutral para el host. */
|
|
130
141
|
message: string;
|
|
131
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Tipo de cuenta adherida, derivado de la longitud del identificador ingresado.
|
|
145
|
+
* 18 dígitos = CLABE, 16 = tarjeta de débito.
|
|
146
|
+
*/
|
|
147
|
+
type TapipayDomiciliationAccountType = "BANK_ACCOUNT" | "DEBIT_CARD";
|
|
148
|
+
/** Método con el que se verificó la cuenta en el alta de domiciliación. */
|
|
149
|
+
type TapipayDomiciliationVerificationMethod = "penny" | "kyc" | "transfer";
|
|
150
|
+
/**
|
|
151
|
+
* Payload del evento domiciliationBankSelected.
|
|
152
|
+
* El usuario eligió su banco en el alta de domiciliación. Emite en cada cambio
|
|
153
|
+
* de selección.
|
|
154
|
+
*/
|
|
155
|
+
interface TapipayDomiciliationBankSelectedEvent {
|
|
156
|
+
/** Id del banco en el catálogo de TapiPay. */
|
|
157
|
+
bankId: string;
|
|
158
|
+
/** Clave SPEI del banco. */
|
|
159
|
+
speiCode: string;
|
|
160
|
+
/** Nombre comercial del banco. */
|
|
161
|
+
name: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Payload del evento domiciliationFormCompleted.
|
|
165
|
+
*
|
|
166
|
+
* Los datos de la cuenta pasaron la validación del backend. Ojo con el timing:
|
|
167
|
+
* NO se dispara al salir de la pantalla del formulario, sino al confirmar el
|
|
168
|
+
* método de verificación — que es cuando la cuenta se registra contra el
|
|
169
|
+
* backend. Si los datos son inválidos, el evento no llega.
|
|
170
|
+
*
|
|
171
|
+
* Nunca incluye la CLABE ni el número de tarjeta completos.
|
|
172
|
+
*/
|
|
173
|
+
interface TapipayDomiciliationFormCompletedEvent {
|
|
174
|
+
bankId: string;
|
|
175
|
+
/** Tipo de cuenta derivado de la longitud del identificador. */
|
|
176
|
+
accountType: TapipayDomiciliationAccountType;
|
|
177
|
+
/** Últimos 4 dígitos de la CLABE o tarjeta. `null` si no está disponible. */
|
|
178
|
+
lastFour: string | null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Payload del evento domiciliationVerificationCompleted.
|
|
182
|
+
*
|
|
183
|
+
* La verificación de la cuenta llegó a un DESENLACE. Dos aclaraciones que
|
|
184
|
+
* importan para interpretarlo:
|
|
185
|
+
*
|
|
186
|
+
* 1. Solo emite al outcome final. Un intento de monto incorrecto que aún deja
|
|
187
|
+
* reintentos disponibles NO dispara el evento: `outcome: "failed"` llega
|
|
188
|
+
* recién cuando se agotan los intentos. Ausencia de evento NO significa que
|
|
189
|
+
* el usuario se frenó — puede estar reintentando.
|
|
190
|
+
* 2. Es method-agnostic y cubre el caso en que el paso de verificación no
|
|
191
|
+
* aparece en pantalla (banco que no la requiere, o método `kyc`/`transfer`):
|
|
192
|
+
* ahí también se emite, para que la secuencia no quede incompleta.
|
|
193
|
+
*/
|
|
194
|
+
interface TapipayDomiciliationVerificationCompletedEvent {
|
|
195
|
+
method: TapipayDomiciliationVerificationMethod;
|
|
196
|
+
outcome: "approved" | "failed";
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Payload del evento domiciliationConfirmed.
|
|
200
|
+
*
|
|
201
|
+
* El usuario confirmó la domiciliación. **No significa que quedó registrada:**
|
|
202
|
+
* se emite al click, sin esperar la respuesta del backend, que procesa el alta
|
|
203
|
+
* de forma asíncrona. La confirmación real llega por `autopayActivated`.
|
|
204
|
+
*/
|
|
205
|
+
interface TapipayDomiciliationConfirmedEvent {
|
|
206
|
+
/** True si adhirió todas las deudas en vez de una selección. */
|
|
207
|
+
enrollAllDebts: boolean;
|
|
208
|
+
selectedProductsCount: number;
|
|
209
|
+
}
|
|
132
210
|
/**
|
|
133
211
|
* Instancia del SDK TapiPay expuesta en window.tapipay y retornada por loadTapipay().
|
|
134
212
|
*/
|
|
@@ -142,6 +220,10 @@ interface TapipayInstance {
|
|
|
142
220
|
on(event: "autopayActivated", handler: (data: TapipayAutopayActivatedEvent) => void): void;
|
|
143
221
|
on(event: "autopayRemoved", handler: (data: TapipayAutopayRemovedEvent) => void): void;
|
|
144
222
|
on(event: "autopayError", handler: (data: TapipayAutopayErrorEvent) => void): void;
|
|
223
|
+
on(event: "domiciliationBankSelected", handler: (data: TapipayDomiciliationBankSelectedEvent) => void): void;
|
|
224
|
+
on(event: "domiciliationFormCompleted", handler: (data: TapipayDomiciliationFormCompletedEvent) => void): void;
|
|
225
|
+
on(event: "domiciliationVerificationCompleted", handler: (data: TapipayDomiciliationVerificationCompletedEvent) => void): void;
|
|
226
|
+
on(event: "domiciliationConfirmed", handler: (data: TapipayDomiciliationConfirmedEvent) => void): void;
|
|
145
227
|
off(event: "paymentWindowOpened", handler: (data: TapipayPaymentWindowOpenedEvent) => void): void;
|
|
146
228
|
off(event: "paymentSubmitted", handler: (data: TapipayPaymentSubmittedEvent) => void): void;
|
|
147
229
|
off(event: "paymentCancelled", handler: (data: TapipayPaymentCancelledEvent) => void): void;
|
|
@@ -149,6 +231,10 @@ interface TapipayInstance {
|
|
|
149
231
|
off(event: "autopayActivated", handler: (data: TapipayAutopayActivatedEvent) => void): void;
|
|
150
232
|
off(event: "autopayRemoved", handler: (data: TapipayAutopayRemovedEvent) => void): void;
|
|
151
233
|
off(event: "autopayError", handler: (data: TapipayAutopayErrorEvent) => void): void;
|
|
234
|
+
off(event: "domiciliationBankSelected", handler: (data: TapipayDomiciliationBankSelectedEvent) => void): void;
|
|
235
|
+
off(event: "domiciliationFormCompleted", handler: (data: TapipayDomiciliationFormCompletedEvent) => void): void;
|
|
236
|
+
off(event: "domiciliationVerificationCompleted", handler: (data: TapipayDomiciliationVerificationCompletedEvent) => void): void;
|
|
237
|
+
off(event: "domiciliationConfirmed", handler: (data: TapipayDomiciliationConfirmedEvent) => void): void;
|
|
152
238
|
off(event: string, handler: (...args: unknown[]) => unknown): void;
|
|
153
239
|
/** Cola interna usada por el stub antes de que cargue el SDK real. */
|
|
154
240
|
_q?: [string, unknown[]][];
|
|
@@ -159,4 +245,4 @@ declare global {
|
|
|
159
245
|
}
|
|
160
246
|
}
|
|
161
247
|
|
|
162
|
-
export type { LoadTapipayOptions as L, TapipayInstance as T, TapipayAutopayActivatedEvent as a, TapipayAutopayAdhesionSummary as b, TapipayAutopayErrorEvent as c, TapipayAutopayLoadedEvent as d, TapipayAutopayMediaType as e, TapipayAutopayRemovedEvent as f,
|
|
248
|
+
export type { LoadTapipayOptions as L, TapipayInstance as T, TapipayAutopayActivatedEvent as a, TapipayAutopayAdhesionSummary as b, TapipayAutopayErrorEvent as c, TapipayAutopayLoadedEvent as d, TapipayAutopayMediaType as e, TapipayAutopayRemovedEvent as f, TapipayDomiciliationAccountType as g, TapipayDomiciliationBankSelectedEvent as h, TapipayDomiciliationConfirmedEvent as i, TapipayDomiciliationFormCompletedEvent as j, TapipayDomiciliationVerificationCompletedEvent as k, TapipayDomiciliationVerificationMethod as l, TapipayEnvironment as m, TapipayOptions as n, TapipayPaymentCancelledEvent as o, TapipayPaymentSubmittedEvent as p, TapipayPaymentWindowOpenedEvent as q, TapipayView as r };
|
|
@@ -22,12 +22,23 @@ interface LoadTapipayOptions {
|
|
|
22
22
|
type TapipayView = "payments" | "autopay";
|
|
23
23
|
/**
|
|
24
24
|
* Opciones requeridas para montar el widget TapiPay.
|
|
25
|
+
*
|
|
26
|
+
* Se requiere `container` + `identifier` + UNO de `{ organization, companyCode }`.
|
|
27
|
+
* Si se pasan ambos, `companyCode` tiene prioridad.
|
|
25
28
|
*/
|
|
26
29
|
interface TapipayOptions {
|
|
27
30
|
/** Selector CSS o elemento DOM donde se montará el widget. */
|
|
28
31
|
container: string | HTMLElement;
|
|
29
|
-
/**
|
|
30
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Alias de la Organización configurado en el dashboard de TapiPay (ej. "acme"). Corresponde al campo "Alias" en Configuración → Organización.
|
|
34
|
+
* Se requiere `organization` O `companyCode`. Si se pasan ambos, `companyCode` tiene prioridad.
|
|
35
|
+
*/
|
|
36
|
+
organization?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Código de compañía de TapiPay (ej. "acme-mx"). Alternativa a `organization`.
|
|
39
|
+
* Se requiere `organization` O `companyCode`. Si se pasan ambos, `companyCode` tiene prioridad.
|
|
40
|
+
*/
|
|
41
|
+
companyCode?: string;
|
|
31
42
|
/** Identificador del cliente en el sistema del cliente (ej. "CLI-001"). */
|
|
32
43
|
identifier: string;
|
|
33
44
|
/** ID externo de la deuda a preseleccionar (ej. número de factura). Aplica a la vista de pagos. */
|
|
@@ -66,7 +77,7 @@ type TapipayPaymentCancelledEvent = Record<string, never>;
|
|
|
66
77
|
* Tipo de medio adherido expuesto al sitio cliente.
|
|
67
78
|
* Solo se expone el tipo lógico, nunca la marca ni el banco.
|
|
68
79
|
*/
|
|
69
|
-
type TapipayAutopayMediaType = "card" | "bank_account";
|
|
80
|
+
type TapipayAutopayMediaType = "card" | "bank_account" | "debit_card";
|
|
70
81
|
/**
|
|
71
82
|
* Resumen mínimo y seguro de una adhesión activa.
|
|
72
83
|
* Privacidad: solo tipo de medio + últimos 4 dígitos. El `id` es un hash opaco
|
|
@@ -129,6 +140,73 @@ interface TapipayAutopayErrorEvent {
|
|
|
129
140
|
/** Mensaje neutral para el host. */
|
|
130
141
|
message: string;
|
|
131
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Tipo de cuenta adherida, derivado de la longitud del identificador ingresado.
|
|
145
|
+
* 18 dígitos = CLABE, 16 = tarjeta de débito.
|
|
146
|
+
*/
|
|
147
|
+
type TapipayDomiciliationAccountType = "BANK_ACCOUNT" | "DEBIT_CARD";
|
|
148
|
+
/** Método con el que se verificó la cuenta en el alta de domiciliación. */
|
|
149
|
+
type TapipayDomiciliationVerificationMethod = "penny" | "kyc" | "transfer";
|
|
150
|
+
/**
|
|
151
|
+
* Payload del evento domiciliationBankSelected.
|
|
152
|
+
* El usuario eligió su banco en el alta de domiciliación. Emite en cada cambio
|
|
153
|
+
* de selección.
|
|
154
|
+
*/
|
|
155
|
+
interface TapipayDomiciliationBankSelectedEvent {
|
|
156
|
+
/** Id del banco en el catálogo de TapiPay. */
|
|
157
|
+
bankId: string;
|
|
158
|
+
/** Clave SPEI del banco. */
|
|
159
|
+
speiCode: string;
|
|
160
|
+
/** Nombre comercial del banco. */
|
|
161
|
+
name: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Payload del evento domiciliationFormCompleted.
|
|
165
|
+
*
|
|
166
|
+
* Los datos de la cuenta pasaron la validación del backend. Ojo con el timing:
|
|
167
|
+
* NO se dispara al salir de la pantalla del formulario, sino al confirmar el
|
|
168
|
+
* método de verificación — que es cuando la cuenta se registra contra el
|
|
169
|
+
* backend. Si los datos son inválidos, el evento no llega.
|
|
170
|
+
*
|
|
171
|
+
* Nunca incluye la CLABE ni el número de tarjeta completos.
|
|
172
|
+
*/
|
|
173
|
+
interface TapipayDomiciliationFormCompletedEvent {
|
|
174
|
+
bankId: string;
|
|
175
|
+
/** Tipo de cuenta derivado de la longitud del identificador. */
|
|
176
|
+
accountType: TapipayDomiciliationAccountType;
|
|
177
|
+
/** Últimos 4 dígitos de la CLABE o tarjeta. `null` si no está disponible. */
|
|
178
|
+
lastFour: string | null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Payload del evento domiciliationVerificationCompleted.
|
|
182
|
+
*
|
|
183
|
+
* La verificación de la cuenta llegó a un DESENLACE. Dos aclaraciones que
|
|
184
|
+
* importan para interpretarlo:
|
|
185
|
+
*
|
|
186
|
+
* 1. Solo emite al outcome final. Un intento de monto incorrecto que aún deja
|
|
187
|
+
* reintentos disponibles NO dispara el evento: `outcome: "failed"` llega
|
|
188
|
+
* recién cuando se agotan los intentos. Ausencia de evento NO significa que
|
|
189
|
+
* el usuario se frenó — puede estar reintentando.
|
|
190
|
+
* 2. Es method-agnostic y cubre el caso en que el paso de verificación no
|
|
191
|
+
* aparece en pantalla (banco que no la requiere, o método `kyc`/`transfer`):
|
|
192
|
+
* ahí también se emite, para que la secuencia no quede incompleta.
|
|
193
|
+
*/
|
|
194
|
+
interface TapipayDomiciliationVerificationCompletedEvent {
|
|
195
|
+
method: TapipayDomiciliationVerificationMethod;
|
|
196
|
+
outcome: "approved" | "failed";
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Payload del evento domiciliationConfirmed.
|
|
200
|
+
*
|
|
201
|
+
* El usuario confirmó la domiciliación. **No significa que quedó registrada:**
|
|
202
|
+
* se emite al click, sin esperar la respuesta del backend, que procesa el alta
|
|
203
|
+
* de forma asíncrona. La confirmación real llega por `autopayActivated`.
|
|
204
|
+
*/
|
|
205
|
+
interface TapipayDomiciliationConfirmedEvent {
|
|
206
|
+
/** True si adhirió todas las deudas en vez de una selección. */
|
|
207
|
+
enrollAllDebts: boolean;
|
|
208
|
+
selectedProductsCount: number;
|
|
209
|
+
}
|
|
132
210
|
/**
|
|
133
211
|
* Instancia del SDK TapiPay expuesta en window.tapipay y retornada por loadTapipay().
|
|
134
212
|
*/
|
|
@@ -142,6 +220,10 @@ interface TapipayInstance {
|
|
|
142
220
|
on(event: "autopayActivated", handler: (data: TapipayAutopayActivatedEvent) => void): void;
|
|
143
221
|
on(event: "autopayRemoved", handler: (data: TapipayAutopayRemovedEvent) => void): void;
|
|
144
222
|
on(event: "autopayError", handler: (data: TapipayAutopayErrorEvent) => void): void;
|
|
223
|
+
on(event: "domiciliationBankSelected", handler: (data: TapipayDomiciliationBankSelectedEvent) => void): void;
|
|
224
|
+
on(event: "domiciliationFormCompleted", handler: (data: TapipayDomiciliationFormCompletedEvent) => void): void;
|
|
225
|
+
on(event: "domiciliationVerificationCompleted", handler: (data: TapipayDomiciliationVerificationCompletedEvent) => void): void;
|
|
226
|
+
on(event: "domiciliationConfirmed", handler: (data: TapipayDomiciliationConfirmedEvent) => void): void;
|
|
145
227
|
off(event: "paymentWindowOpened", handler: (data: TapipayPaymentWindowOpenedEvent) => void): void;
|
|
146
228
|
off(event: "paymentSubmitted", handler: (data: TapipayPaymentSubmittedEvent) => void): void;
|
|
147
229
|
off(event: "paymentCancelled", handler: (data: TapipayPaymentCancelledEvent) => void): void;
|
|
@@ -149,6 +231,10 @@ interface TapipayInstance {
|
|
|
149
231
|
off(event: "autopayActivated", handler: (data: TapipayAutopayActivatedEvent) => void): void;
|
|
150
232
|
off(event: "autopayRemoved", handler: (data: TapipayAutopayRemovedEvent) => void): void;
|
|
151
233
|
off(event: "autopayError", handler: (data: TapipayAutopayErrorEvent) => void): void;
|
|
234
|
+
off(event: "domiciliationBankSelected", handler: (data: TapipayDomiciliationBankSelectedEvent) => void): void;
|
|
235
|
+
off(event: "domiciliationFormCompleted", handler: (data: TapipayDomiciliationFormCompletedEvent) => void): void;
|
|
236
|
+
off(event: "domiciliationVerificationCompleted", handler: (data: TapipayDomiciliationVerificationCompletedEvent) => void): void;
|
|
237
|
+
off(event: "domiciliationConfirmed", handler: (data: TapipayDomiciliationConfirmedEvent) => void): void;
|
|
152
238
|
off(event: string, handler: (...args: unknown[]) => unknown): void;
|
|
153
239
|
/** Cola interna usada por el stub antes de que cargue el SDK real. */
|
|
154
240
|
_q?: [string, unknown[]][];
|
|
@@ -159,4 +245,4 @@ declare global {
|
|
|
159
245
|
}
|
|
160
246
|
}
|
|
161
247
|
|
|
162
|
-
export type { LoadTapipayOptions as L, TapipayInstance as T, TapipayAutopayActivatedEvent as a, TapipayAutopayAdhesionSummary as b, TapipayAutopayErrorEvent as c, TapipayAutopayLoadedEvent as d, TapipayAutopayMediaType as e, TapipayAutopayRemovedEvent as f,
|
|
248
|
+
export type { LoadTapipayOptions as L, TapipayInstance as T, TapipayAutopayActivatedEvent as a, TapipayAutopayAdhesionSummary as b, TapipayAutopayErrorEvent as c, TapipayAutopayLoadedEvent as d, TapipayAutopayMediaType as e, TapipayAutopayRemovedEvent as f, TapipayDomiciliationAccountType as g, TapipayDomiciliationBankSelectedEvent as h, TapipayDomiciliationConfirmedEvent as i, TapipayDomiciliationFormCompletedEvent as j, TapipayDomiciliationVerificationCompletedEvent as k, TapipayDomiciliationVerificationMethod as l, TapipayEnvironment as m, TapipayOptions as n, TapipayPaymentCancelledEvent as o, TapipayPaymentSubmittedEvent as p, TapipayPaymentWindowOpenedEvent as q, TapipayView as r };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/loader.ts"],"sourcesContent":["import type {\n\tLoadTapipayOptions,\n\tTapipayEnvironment,\n\tTapipayInstance,\n} from \"./types\";\n\nconst SDK_URLS: Record<TapipayEnvironment, string> = {\n\tproduction: \"https://app.tapipay.la/embed.js\",\n\thomo: \"https://homo.tapipay.la/embed.js\",\n};\n\n// Idempotencia por entorno\nconst loadPromises = new Map<TapipayEnvironment, Promise<TapipayInstance>>();\n\n/**\n * Carga el SDK de TapiPay de forma asíncrona inyectando el script en el DOM.\n *\n * - Idempotente por entorno: múltiples llamadas con el mismo `environment` retornan la misma Promise.\n * - Si window.tapipay ya existe (script cargado sync), resuelve inmediatamente.\n * - Compatible con React Strict Mode (doble mount/unmount).\n *\n * @example\n * // Producción (default)\n * const tapipay = await loadTapipay();\n *\n * // Homologación\n * const tapipay = await loadTapipay({ environment: 'homo' });\n *\n * tapipay.initialize({ container: \"#widget\", organization: \"acme\", identifier: \"CLI-001\" });\n */\nexport function loadTapipay(\n\toptions?: LoadTapipayOptions,\n): Promise<TapipayInstance> {\n\tconst env: TapipayEnvironment = options?.environment ?? \"production\";\n\tconst SDK_URL = SDK_URLS[env];\n\tconst SCRIPT_ID = `tapipay-embed-sdk-${env}`;\n\n\t// SSR guard\n\tif (typeof window === \"undefined\") {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\"[TapiPay] loadTapipay() requires a browser environment.\"),\n\t\t);\n\t}\n\n\t// Ya cargado de forma síncrona (script tag directo)\n\tif (window.tapipay && !window.tapipay._q) {\n\t\treturn Promise.resolve(window.tapipay);\n\t}\n\n\t// Reutilizar promise existente (idempotencia por entorno)\n\tconst existing = loadPromises.get(env);\n\tif (existing) return existing;\n\n\tconst promise = new Promise<TapipayInstance>((resolve, reject) => {\n\t\t// Si ya hay un script inyectado, esperar a que cargue\n\t\tconst existingScript = document.getElementById(\n\t\t\tSCRIPT_ID,\n\t\t) as HTMLScriptElement | null;\n\n\t\tconst onLoad = () => {\n\t\t\tif (window.tapipay) {\n\t\t\t\tresolve(window.tapipay);\n\t\t\t} else {\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\"[TapiPay] El script cargó pero window.tapipay no está definido.\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst onError = () => {\n\t\t\tloadPromises.delete(env);\n\t\t\treject(new Error(`[TapiPay] Error al cargar el SDK desde ${SDK_URL}`));\n\t\t};\n\n\t\tif (existingScript) {\n\t\t\texistingScript.addEventListener(\"load\", onLoad);\n\t\t\texistingScript.addEventListener(\"error\", onError);\n\t\t\treturn;\n\t\t}\n\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.id = SCRIPT_ID;\n\t\tscript.src = SDK_URL;\n\t\tscript.async = true;\n\t\tscript.addEventListener(\"load\", onLoad);\n\t\tscript.addEventListener(\"error\", onError);\n\t\tdocument.head.appendChild(script);\n\t});\n\n\tloadPromises.set(env, promise);\n\treturn promise;\n}\n"],"mappings":";AAMA,IAAM,WAA+C;AAAA,EACpD,YAAY;AAAA,EACZ,MAAM;AACP;AAGA,IAAM,eAAe,oBAAI,IAAkD;AAkBpE,SAAS,YACf,SAC2B;AAhC5B;AAiCC,QAAM,OAA0B,wCAAS,gBAAT,YAAwB;AACxD,QAAM,UAAU,SAAS,GAAG;AAC5B,QAAM,YAAY,qBAAqB,GAAG;AAG1C,MAAI,OAAO,WAAW,aAAa;AAClC,WAAO,QAAQ;AAAA,MACd,IAAI,MAAM,yDAAyD;AAAA,IACpE;AAAA,EACD;AAGA,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,IAAI;AACzC,WAAO,QAAQ,QAAQ,OAAO,OAAO;AAAA,EACtC;AAGA,QAAM,WAAW,aAAa,IAAI,GAAG;AACrC,MAAI,SAAU,QAAO;AAErB,QAAM,UAAU,IAAI,QAAyB,CAAC,SAAS,WAAW;AAEjE,UAAM,iBAAiB,SAAS;AAAA,MAC/B;AAAA,IACD;AAEA,UAAM,SAAS,MAAM;AACpB,UAAI,OAAO,SAAS;AACnB,gBAAQ,OAAO,OAAO;AAAA,MACvB,OAAO;AACN;AAAA,UACC,IAAI;AAAA,YACH;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,UAAU,MAAM;AACrB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