@apolopay-sdk/core 1.1.0 → 1.2.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/dist/index.d.mts +60 -10
- package/dist/index.d.ts +60 -10
- package/dist/index.js +254 -177
- package/dist/index.mjs +253 -177
- package/package.json +5 -1
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,201 @@ var ApoloPayClient = class {
|
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
// src/i18n/es.ts
|
|
12
|
+
var es = {
|
|
13
|
+
trigger: {
|
|
14
|
+
loading: "Cargando..."
|
|
15
|
+
},
|
|
16
|
+
modal: {
|
|
17
|
+
titles: {
|
|
18
|
+
selectAsset: 'Selecciona el <span class="highlight">stablecoin</span>',
|
|
19
|
+
selectNetwork: 'Selecciona la <span class="highlight">red</span>',
|
|
20
|
+
scanQr: 'Dep\xF3sito <span class="highlight">{symbol}</span>',
|
|
21
|
+
success: '\xA1Gracias por <span class="highlight">tu compra!</span>',
|
|
22
|
+
error: "Error en el Pago",
|
|
23
|
+
idle: "Estado inesperado",
|
|
24
|
+
processing: '\xA1Procesando <span class="highlight">tu pago!</span>'
|
|
25
|
+
},
|
|
26
|
+
subtitles: {
|
|
27
|
+
selectAsset: "Selecciona la stablecoin con la que deseas pagar",
|
|
28
|
+
selectNetwork: "Selecciona la red de tu preferencia",
|
|
29
|
+
idle: "Ocurrio un error inesperado"
|
|
30
|
+
},
|
|
31
|
+
actions: {
|
|
32
|
+
back: "Volver",
|
|
33
|
+
close: "Cerrar",
|
|
34
|
+
support: "Soporte",
|
|
35
|
+
scanApp: 'Escanea con tu celular y continua desde la app de <span style="color: var(--apolo-accent)">Apolo Pay</span>',
|
|
36
|
+
copy: "Copiar",
|
|
37
|
+
copied: "\xA1Copiado!",
|
|
38
|
+
payFromDevice: "Pagar desde este dispositivo"
|
|
39
|
+
},
|
|
40
|
+
labels: {
|
|
41
|
+
network: "Red",
|
|
42
|
+
address: "Direcci\xF3n de dep\xF3sito",
|
|
43
|
+
amount: "Monto",
|
|
44
|
+
product: "Producto o Servicio",
|
|
45
|
+
minutes: "min",
|
|
46
|
+
seconds: "seg",
|
|
47
|
+
amountSent: "Monto Enviado",
|
|
48
|
+
paid: "Pagado",
|
|
49
|
+
remainingToPay: "Restante por pagar"
|
|
50
|
+
},
|
|
51
|
+
info: {
|
|
52
|
+
noReloadPageTitle: '\xA1Por favor no <span style="color: var(--apolo-accent)">recargues la p\xE1gina!</span>',
|
|
53
|
+
noReloadPageSubTitle: "La pantalla se actualizara cuando confirmes tu pago",
|
|
54
|
+
selectNetworkLater: "Luego podr\xE1s seleccionar la red de tu preferencia"
|
|
55
|
+
},
|
|
56
|
+
warnings: {
|
|
57
|
+
networkMatch: "Aseg\xFArate de que la <strong>red de tu wallet coincida</strong> con la red de destino.",
|
|
58
|
+
noNFT: "No env\xEDes NFTs a esta wallet.",
|
|
59
|
+
onlyToken: "Solo se aceptan <strong>dep\xF3sitos en {symbol}</strong>. El env\xEDo de otro tipo de token podr\xEDa resultar en su p\xE9rdida.",
|
|
60
|
+
timer: "Realiza el pago dentro del tiempo indicado. <strong>{time}</strong> De lo contrario, el c\xF3digo QR se vencer\xE1."
|
|
61
|
+
},
|
|
62
|
+
success: {
|
|
63
|
+
message: "Tu pago fue exitoso y en breve recibir\xE1s un correo",
|
|
64
|
+
message2: "con los detalles.",
|
|
65
|
+
details: "Detalles de la compra",
|
|
66
|
+
support: "Cualquier duda o inquietud puedes comunicarte con soporte"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
successes: {
|
|
70
|
+
success: "\xC9xito"
|
|
71
|
+
},
|
|
72
|
+
errors: {
|
|
73
|
+
generic: "Ocurri\xF3 un error inesperado.",
|
|
74
|
+
publicKeyMissing: "Falta la Public Key",
|
|
75
|
+
config: "Error de Configuraci\xF3n",
|
|
76
|
+
timeout: "El tiempo para realizar el pago ha expirado. Por favor genera una nueva orden.",
|
|
77
|
+
paymentFailed: "El pago ha fallado. Por favor genera una nueva orden.",
|
|
78
|
+
connectError: "Error de conexi\xF3n.",
|
|
79
|
+
socketConnectionError: "Error de conexi\xF3n en el socket.",
|
|
80
|
+
dataLoadError: "No se pudo cargar los datos de pago.",
|
|
81
|
+
qrFetchError: "Fallo al obtener los detalles del c\xF3digo QR.",
|
|
82
|
+
paymentProcessNotAvailable: "El proceso de pago no est\xE1 disponible.",
|
|
83
|
+
getAssetsError: "Error al obtener los activos.",
|
|
84
|
+
unknownError: "Ocurri\xF3 un error inesperado."
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/i18n/en.ts
|
|
89
|
+
var en = {
|
|
90
|
+
trigger: {
|
|
91
|
+
loading: "Loading..."
|
|
92
|
+
},
|
|
93
|
+
modal: {
|
|
94
|
+
titles: {
|
|
95
|
+
selectAsset: 'Select <span class="highlight">stablecoin</span>',
|
|
96
|
+
selectNetwork: 'Select <span class="highlight">network</span>',
|
|
97
|
+
scanQr: 'Deposit <span class="highlight">{symbol}</span>',
|
|
98
|
+
success: 'Thanks for <span class="highlight">your purchase!</span>',
|
|
99
|
+
error: "Payment Error",
|
|
100
|
+
idle: "Unexpected state",
|
|
101
|
+
processing: 'Processing <span class="highlight">your payment!</span>'
|
|
102
|
+
},
|
|
103
|
+
subtitles: {
|
|
104
|
+
selectAsset: "Select the stablecoin you want to pay with",
|
|
105
|
+
selectNetwork: "Select your preferred network",
|
|
106
|
+
idle: "An Unexpected error occurred"
|
|
107
|
+
},
|
|
108
|
+
actions: {
|
|
109
|
+
back: "Back",
|
|
110
|
+
close: "Close",
|
|
111
|
+
support: "Support",
|
|
112
|
+
scanApp: 'Scan with your phone and continue from <br><span style="color: var(--apolo-accent)">Apolo Pay</span> app',
|
|
113
|
+
copy: "Copy",
|
|
114
|
+
copied: "Copied!",
|
|
115
|
+
payFromDevice: "Pay from this device"
|
|
116
|
+
},
|
|
117
|
+
labels: {
|
|
118
|
+
network: "Network",
|
|
119
|
+
address: "Deposit Address",
|
|
120
|
+
amount: "Amount",
|
|
121
|
+
product: "Product or Service",
|
|
122
|
+
minutes: "min",
|
|
123
|
+
seconds: "sec",
|
|
124
|
+
amountSent: "Amount sent",
|
|
125
|
+
paid: "Paid",
|
|
126
|
+
remainingToPay: "Remaining balance to pay"
|
|
127
|
+
},
|
|
128
|
+
info: {
|
|
129
|
+
noReloadPageTitle: 'Please do not <span style="color: var(--apolo-accent)">reload the page!</span>',
|
|
130
|
+
noReloadPageSubTitle: "The screen will update when you confirm your payment",
|
|
131
|
+
selectNetworkLater: "You will be able to select your preferred network later"
|
|
132
|
+
},
|
|
133
|
+
warnings: {
|
|
134
|
+
networkMatch: "Ensure your <strong>wallet network matches</strong> the destination network.",
|
|
135
|
+
noNFT: "Do not send NFTs to this wallet.",
|
|
136
|
+
onlyToken: "Only <strong>{symbol} deposits</strong> are accepted. Sending other tokens may result in loss.",
|
|
137
|
+
timer: "Complete payment within <strong>{time}</strong>. Otherwise, the QR code will expire."
|
|
138
|
+
},
|
|
139
|
+
success: {
|
|
140
|
+
message: "Your payment was successful. You will receive an email",
|
|
141
|
+
message2: "shortly.",
|
|
142
|
+
details: "Purchase Details",
|
|
143
|
+
support: "Any doubt or inquiry you can contact support"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
successes: {
|
|
147
|
+
success: "Success"
|
|
148
|
+
},
|
|
149
|
+
errors: {
|
|
150
|
+
generic: "An unexpected error occurred.",
|
|
151
|
+
publicKeyMissing: "Public Key is missing",
|
|
152
|
+
config: "Config Error",
|
|
153
|
+
timeout: "The payment time has expired. Please generate a new order.",
|
|
154
|
+
paymentFailed: "The payment has failed. Please generate a new order.",
|
|
155
|
+
connectError: "Connection error in real time.",
|
|
156
|
+
socketConnectionError: "Connection error in socket.",
|
|
157
|
+
dataLoadError: "Could not load payment options.",
|
|
158
|
+
qrFetchError: "Failed to get payment details.",
|
|
159
|
+
paymentProcessNotAvailable: "The payment process is not available.",
|
|
160
|
+
getAssetsError: "Failed to get assets.",
|
|
161
|
+
unknownError: "An unexpected error occurred."
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/i18n/index.ts
|
|
166
|
+
var I18nService = class {
|
|
167
|
+
// Cambiar idioma
|
|
168
|
+
static setLocale(locale) {
|
|
169
|
+
this._currentLocale = locale;
|
|
170
|
+
this._dictionary = locale === "en" ? en : es;
|
|
171
|
+
}
|
|
172
|
+
static get current() {
|
|
173
|
+
return this._currentLocale;
|
|
174
|
+
}
|
|
175
|
+
// Función para obtener texto (Tipado seguro para claves anidadas sería complejo,
|
|
176
|
+
// así que usaremos acceso directo o un getter helper si lo prefieres)
|
|
177
|
+
static get t() {
|
|
178
|
+
return this._dictionary;
|
|
179
|
+
}
|
|
180
|
+
// Helper para interpolar variables: "Hola {name}" -> "Hola Mundo"
|
|
181
|
+
static interpolate(text, params) {
|
|
182
|
+
return text.replace(/{(\w+)}/g, (match, key) => {
|
|
183
|
+
return typeof params[key] !== "undefined" ? String(params[key]) : match;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
I18nService._currentLocale = "es";
|
|
188
|
+
I18nService._dictionary = es;
|
|
189
|
+
|
|
11
190
|
// src/types/client-response.ts
|
|
191
|
+
var ClientCode = /* @__PURE__ */ ((ClientCode2) => {
|
|
192
|
+
ClientCode2["success"] = "success";
|
|
193
|
+
ClientCode2["payment_success"] = "payment_success";
|
|
194
|
+
ClientCode2["payment_failed"] = "payment_failed";
|
|
195
|
+
ClientCode2["payment_partial"] = "payment_partial";
|
|
196
|
+
ClientCode2["payment_timeout"] = "payment_timeout";
|
|
197
|
+
ClientCode2["connect_error"] = "connect_error";
|
|
198
|
+
ClientCode2["socket_connection_error"] = "socket_connection_error";
|
|
199
|
+
ClientCode2["data_load_error"] = "data_load_error";
|
|
200
|
+
ClientCode2["qr_fetch_error"] = "qr_fetch_error";
|
|
201
|
+
ClientCode2["paymentProcessNotAvailable"] = "payment_process_not_available";
|
|
202
|
+
ClientCode2["get_assets_error"] = "get_assets_error";
|
|
203
|
+
ClientCode2["unknown_error"] = "unknown_error";
|
|
204
|
+
return ClientCode2;
|
|
205
|
+
})(ClientCode || {});
|
|
12
206
|
var ClientResponseBase = class {
|
|
13
207
|
constructor({ code, message }) {
|
|
14
208
|
this.code = code;
|
|
@@ -21,8 +215,8 @@ var ClientResponse = class _ClientResponse extends ClientResponseBase {
|
|
|
21
215
|
this.result = result;
|
|
22
216
|
}
|
|
23
217
|
static fromJson(json, { code, message, result } = {}) {
|
|
24
|
-
const successCode = json.status || code || "success"
|
|
25
|
-
const successMessage = json.message || message ||
|
|
218
|
+
const successCode = json.status || code || "success" /* success */;
|
|
219
|
+
const successMessage = json.message || message || I18nService.t.successes.success;
|
|
26
220
|
const successResult = result?.(json.result) || json.result || json;
|
|
27
221
|
return new _ClientResponse({ code: successCode, message: successMessage, result: successResult });
|
|
28
222
|
}
|
|
@@ -33,18 +227,24 @@ var ClientError = class _ClientError extends ClientResponseBase {
|
|
|
33
227
|
this.error = error;
|
|
34
228
|
}
|
|
35
229
|
static fromError(error, { code, message } = {}) {
|
|
36
|
-
|
|
37
|
-
const
|
|
230
|
+
if (error instanceof _ClientError) return error;
|
|
231
|
+
const errCode = code || error.statusCode || "unknown_error" /* unknown_error */;
|
|
232
|
+
const errMessage = message || error.message || I18nService.t.errors.unknownError;
|
|
38
233
|
const err = error.error || error;
|
|
39
234
|
return new _ClientError({ code: errCode, message: errMessage, error: err });
|
|
40
235
|
}
|
|
41
236
|
};
|
|
42
237
|
|
|
238
|
+
// src/utils/variables.ts
|
|
239
|
+
var appURL = "https://p2p.apolopay.app";
|
|
240
|
+
var apiURL = "https://pb-api.apolopay.app";
|
|
241
|
+
var socketURL = "https://pb-ws.apolopay.app";
|
|
242
|
+
|
|
43
243
|
// src/services/repository.ts
|
|
44
244
|
var Repository = class {
|
|
45
245
|
static async getAssets() {
|
|
46
246
|
try {
|
|
47
|
-
const response = await fetch(`${
|
|
247
|
+
const response = await fetch(`${apiURL}/payment-button/assets`, {
|
|
48
248
|
method: "GET",
|
|
49
249
|
headers: this.headers()
|
|
50
250
|
});
|
|
@@ -52,8 +252,8 @@ var Repository = class {
|
|
|
52
252
|
return ClientResponse.fromJson(data);
|
|
53
253
|
} catch (error) {
|
|
54
254
|
throw ClientError.fromError(error, {
|
|
55
|
-
code: "get_assets_error"
|
|
56
|
-
message:
|
|
255
|
+
code: "get_assets_error" /* get_assets_error */,
|
|
256
|
+
message: I18nService.t.errors.getAssetsError
|
|
57
257
|
});
|
|
58
258
|
}
|
|
59
259
|
}
|
|
@@ -64,7 +264,7 @@ var Repository = class {
|
|
|
64
264
|
publicKey
|
|
65
265
|
}) {
|
|
66
266
|
try {
|
|
67
|
-
const response = await fetch(`${
|
|
267
|
+
const response = await fetch(`${apiURL}/payment-button/process/confirm`, {
|
|
68
268
|
method: "POST",
|
|
69
269
|
headers: this.headers(publicKey),
|
|
70
270
|
body: JSON.stringify({
|
|
@@ -75,42 +275,55 @@ var Repository = class {
|
|
|
75
275
|
}), data = await response.json();
|
|
76
276
|
if (!data.result) {
|
|
77
277
|
throw new ClientError({
|
|
78
|
-
code:
|
|
79
|
-
message:
|
|
278
|
+
code: "payment_process_not_available" /* paymentProcessNotAvailable */,
|
|
279
|
+
message: I18nService.t.errors.paymentProcessNotAvailable
|
|
80
280
|
});
|
|
81
281
|
}
|
|
82
282
|
const wallet = data.result.wallet;
|
|
83
283
|
const network = data.result.network;
|
|
84
|
-
const address = network === "apolopay" ?
|
|
284
|
+
const address = network === "apolopay" ? `${appURL}/payment-process/${processId}` : wallet;
|
|
85
285
|
return ClientResponse.fromJson(data, {
|
|
86
286
|
result: (json) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
287
|
+
const now = Date.now();
|
|
288
|
+
const defaultMilliseconds = now + 10 * 60 * 1e3;
|
|
289
|
+
let rawVal = json.expiresAtMs ?? json.expiresAt;
|
|
290
|
+
const calculateExpiration = (val) => {
|
|
291
|
+
if (!val) return defaultMilliseconds;
|
|
292
|
+
let ms = 0;
|
|
293
|
+
if (!isNaN(Number(val))) {
|
|
294
|
+
ms = Number(val);
|
|
295
|
+
} else if (typeof val === "string") {
|
|
296
|
+
const parsed = new Date(val).getTime();
|
|
297
|
+
if (!isNaN(parsed)) ms = parsed;
|
|
298
|
+
}
|
|
299
|
+
if (ms === 0) return defaultMilliseconds;
|
|
300
|
+
if (ms < 1e10) {
|
|
301
|
+
ms *= 1e3;
|
|
302
|
+
} else if (ms > 1e13) {
|
|
303
|
+
while (ms > 2e13) {
|
|
304
|
+
ms = Math.floor(ms / 1e3);
|
|
305
|
+
}
|
|
94
306
|
}
|
|
95
|
-
|
|
307
|
+
return ms;
|
|
308
|
+
};
|
|
309
|
+
const expiresAtMs = calculateExpiration(rawVal);
|
|
96
310
|
return {
|
|
97
311
|
...json,
|
|
98
312
|
address,
|
|
99
313
|
qrCodeUrl: `https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${address}&ecc=H`,
|
|
100
314
|
paymentUrl: address.startsWith("http") ? address : void 0,
|
|
101
|
-
expiresAtMs
|
|
315
|
+
expiresAtMs
|
|
102
316
|
};
|
|
103
317
|
}
|
|
104
318
|
});
|
|
105
319
|
} catch (error) {
|
|
106
320
|
throw ClientError.fromError(error, {
|
|
107
|
-
code: "
|
|
108
|
-
message:
|
|
321
|
+
code: "qr_fetch_error" /* qr_fetch_error */,
|
|
322
|
+
message: I18nService.t.errors.qrFetchError
|
|
109
323
|
});
|
|
110
324
|
}
|
|
111
325
|
}
|
|
112
326
|
};
|
|
113
|
-
Repository.apiUrl = "https://pb-test-api.apolopay.app";
|
|
114
327
|
Repository.headers = (publicKey) => {
|
|
115
328
|
const options = {
|
|
116
329
|
"Content-Type": "application/json"
|
|
@@ -121,7 +334,7 @@ Repository.headers = (publicKey) => {
|
|
|
121
334
|
|
|
122
335
|
// src/services/socket-service.ts
|
|
123
336
|
import { io } from "socket.io-client";
|
|
124
|
-
var
|
|
337
|
+
var SocketService = class {
|
|
125
338
|
constructor(client) {
|
|
126
339
|
this.sessionOptions = null;
|
|
127
340
|
this.socket = null;
|
|
@@ -131,11 +344,11 @@ var _SocketService = class _SocketService {
|
|
|
131
344
|
if (typeof window === "undefined") return;
|
|
132
345
|
this.sessionOptions = session;
|
|
133
346
|
if (this.socket && this.socket.connected) return this.disconnect();
|
|
134
|
-
this.socket = io(
|
|
347
|
+
this.socket = io(socketURL, {
|
|
135
348
|
extraHeaders: {
|
|
136
349
|
"x-public-key": this.client.getPublicKey()
|
|
137
350
|
},
|
|
138
|
-
transports: ["polling"]
|
|
351
|
+
transports: ["websocket", "polling"]
|
|
139
352
|
});
|
|
140
353
|
const { processId } = session;
|
|
141
354
|
this.socket.on("connect", () => this.socket?.emit("process:connect", { processId }));
|
|
@@ -143,7 +356,7 @@ var _SocketService = class _SocketService {
|
|
|
143
356
|
this.socket.on("process:message", (response) => this.handleWebSocketMessage(response));
|
|
144
357
|
this.socket.on("connect_error", (error) => {
|
|
145
358
|
console.error("Error en conexi\xF3n Socket.io:", error);
|
|
146
|
-
this.sessionOptions?.onError({ code: "connect_error"
|
|
359
|
+
this.sessionOptions?.onError?.({ code: "connect_error" /* connect_error */, message: I18nService.t.errors.connectError, error });
|
|
147
360
|
this.disconnect();
|
|
148
361
|
});
|
|
149
362
|
this.socket.on("disconnect", (reason) => {
|
|
@@ -152,17 +365,23 @@ var _SocketService = class _SocketService {
|
|
|
152
365
|
});
|
|
153
366
|
}
|
|
154
367
|
handleWebSocketMessage(response) {
|
|
155
|
-
console.log(response);
|
|
156
368
|
if (!response.success) {
|
|
157
|
-
return this.sessionOptions?.onError({
|
|
158
|
-
code: "payment_failed"
|
|
369
|
+
return this.sessionOptions?.onError?.({
|
|
370
|
+
code: "payment_failed" /* payment_failed */,
|
|
159
371
|
message: response.message,
|
|
160
372
|
error: response.result
|
|
161
373
|
});
|
|
162
374
|
}
|
|
163
|
-
if (response.
|
|
164
|
-
return this.sessionOptions?.
|
|
165
|
-
code: "
|
|
375
|
+
if (response.event === "partial_payment") {
|
|
376
|
+
return this.sessionOptions?.onPartialPayment?.({
|
|
377
|
+
code: "payment_partial" /* payment_partial */,
|
|
378
|
+
message: response.message,
|
|
379
|
+
result: response.result
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
if (response.event === "funds_received") {
|
|
383
|
+
return this.sessionOptions?.onSuccess?.({
|
|
384
|
+
code: "payment_success" /* payment_success */,
|
|
166
385
|
message: response.message,
|
|
167
386
|
result: response.result
|
|
168
387
|
});
|
|
@@ -175,8 +394,6 @@ var _SocketService = class _SocketService {
|
|
|
175
394
|
}
|
|
176
395
|
}
|
|
177
396
|
};
|
|
178
|
-
_SocketService.wsUrl = "https://pb-test-ws.apolopay.app";
|
|
179
|
-
var SocketService = _SocketService;
|
|
180
397
|
|
|
181
398
|
// src/services/payment-service.ts
|
|
182
399
|
var PaymentService = class {
|
|
@@ -199,7 +416,6 @@ var PaymentService = class {
|
|
|
199
416
|
processId: session.processId,
|
|
200
417
|
publicKey: this.client.getPublicKey()
|
|
201
418
|
});
|
|
202
|
-
console.log("qrData", qrData);
|
|
203
419
|
this.socket.connect(session);
|
|
204
420
|
return qrData.result;
|
|
205
421
|
}
|
|
@@ -216,149 +432,9 @@ var ModalStep = /* @__PURE__ */ ((ModalStep2) => {
|
|
|
216
432
|
ModalStep2[ModalStep2["RESULT"] = 3] = "RESULT";
|
|
217
433
|
return ModalStep2;
|
|
218
434
|
})(ModalStep || {});
|
|
219
|
-
|
|
220
|
-
// src/i18n/es.ts
|
|
221
|
-
var es = {
|
|
222
|
-
trigger: {
|
|
223
|
-
loading: "Cargando..."
|
|
224
|
-
},
|
|
225
|
-
modal: {
|
|
226
|
-
titles: {
|
|
227
|
-
selectAsset: 'Selecciona el <span class="highlight">stablecoin</span>',
|
|
228
|
-
selectNetwork: 'Selecciona la <span class="highlight">red</span>',
|
|
229
|
-
scanQr: 'Dep\xF3sito <span class="highlight">{symbol}</span>',
|
|
230
|
-
success: '\xA1Gracias por <span class="highlight">tu compra!</span>',
|
|
231
|
-
error: "Error en el Pago",
|
|
232
|
-
idle: "Estado inesperado"
|
|
233
|
-
},
|
|
234
|
-
subtitles: {
|
|
235
|
-
selectAsset: "Selecciona la stablecoin con la que deseas pagar",
|
|
236
|
-
selectNetwork: "Selecciona la red de tu preferencia",
|
|
237
|
-
idle: "Ocurrio un error inesperado"
|
|
238
|
-
},
|
|
239
|
-
actions: {
|
|
240
|
-
back: "Volver",
|
|
241
|
-
close: "Cerrar",
|
|
242
|
-
support: "Soporte",
|
|
243
|
-
scanApp: 'Escanea con tu celular y continua desde la app de <span style="color: var(--apolo-accent)">Apolo Pay</span>',
|
|
244
|
-
copy: "Copiar",
|
|
245
|
-
copied: "\xA1Copiado!",
|
|
246
|
-
payFromDevice: "Pagar desde este dispositivo"
|
|
247
|
-
},
|
|
248
|
-
labels: {
|
|
249
|
-
network: "Red",
|
|
250
|
-
address: "Direcci\xF3n de dep\xF3sito",
|
|
251
|
-
amount: "Monto",
|
|
252
|
-
product: "Producto o Servicio",
|
|
253
|
-
minutes: "min",
|
|
254
|
-
seconds: "seg"
|
|
255
|
-
},
|
|
256
|
-
warnings: {
|
|
257
|
-
networkMatch: "Aseg\xFArate de que la <strong>red de tu wallet coincida</strong> con la red de destino.",
|
|
258
|
-
noNFT: "No env\xEDes NFTs a esta wallet.",
|
|
259
|
-
onlyToken: "Solo se aceptan <strong>dep\xF3sitos en {symbol}</strong>. El env\xEDo de otro tipo de token podr\xEDa resultar en su p\xE9rdida.",
|
|
260
|
-
timer: "Realiza el pago dentro del tiempo indicado. <strong>{time}</strong> De lo contrario, el c\xF3digo QR se vencer\xE1.",
|
|
261
|
-
selectNetworkLater: "Luego podr\xE1s seleccionar la red de tu preferencia"
|
|
262
|
-
},
|
|
263
|
-
success: {
|
|
264
|
-
message: "Tu pago fue exitoso y en breve recibir\xE1s un correo",
|
|
265
|
-
message2: "con los detalles.",
|
|
266
|
-
details: "Detalles de la compra",
|
|
267
|
-
support: "Cualquier duda o inquietud puedes comunicarte con soporte"
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
errors: {
|
|
271
|
-
generic: "Ocurri\xF3 un error inesperado.",
|
|
272
|
-
publicKeyMissing: "Falta la Public Key",
|
|
273
|
-
config: "Error de Configuraci\xF3n",
|
|
274
|
-
timeout: "El tiempo para realizar el pago ha expirado. Por favor genera una nueva orden."
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// src/i18n/en.ts
|
|
279
|
-
var en = {
|
|
280
|
-
trigger: {
|
|
281
|
-
loading: "Loading..."
|
|
282
|
-
},
|
|
283
|
-
modal: {
|
|
284
|
-
titles: {
|
|
285
|
-
selectAsset: 'Select <span class="highlight">stablecoin</span>',
|
|
286
|
-
selectNetwork: 'Select <span class="highlight">network</span>',
|
|
287
|
-
scanQr: 'Deposit <span class="highlight">{symbol}</span>',
|
|
288
|
-
success: 'Thanks for <span class="highlight">your purchase!</span>',
|
|
289
|
-
error: "Payment Error",
|
|
290
|
-
idle: "Unexpected state"
|
|
291
|
-
},
|
|
292
|
-
subtitles: {
|
|
293
|
-
selectAsset: "Select the stablecoin you want to pay with",
|
|
294
|
-
selectNetwork: "Select your preferred network",
|
|
295
|
-
idle: "An Unexpected error occurred"
|
|
296
|
-
},
|
|
297
|
-
actions: {
|
|
298
|
-
back: "Back",
|
|
299
|
-
close: "Close",
|
|
300
|
-
support: "Support",
|
|
301
|
-
scanApp: 'Scan with your phone and continue from <br><span style="color: var(--apolo-accent)">Apolo Pay</span> app',
|
|
302
|
-
copy: "Copy",
|
|
303
|
-
copied: "Copied!",
|
|
304
|
-
payFromDevice: "Pay from this device"
|
|
305
|
-
},
|
|
306
|
-
labels: {
|
|
307
|
-
network: "Network",
|
|
308
|
-
address: "Deposit Address",
|
|
309
|
-
amount: "Amount",
|
|
310
|
-
product: "Product or Service",
|
|
311
|
-
minutes: "min",
|
|
312
|
-
seconds: "sec"
|
|
313
|
-
},
|
|
314
|
-
warnings: {
|
|
315
|
-
networkMatch: "Ensure your <strong>wallet network matches</strong> the destination network.",
|
|
316
|
-
noNFT: "Do not send NFTs to this wallet.",
|
|
317
|
-
onlyToken: "Only <strong>{symbol} deposits</strong> are accepted. Sending other tokens may result in loss.",
|
|
318
|
-
timer: "Complete payment within <strong>{time}</strong>. Otherwise, the QR code will expire.",
|
|
319
|
-
selectNetworkLater: "You will be able to select your preferred network later"
|
|
320
|
-
},
|
|
321
|
-
success: {
|
|
322
|
-
message: "Your payment was successful. You will receive an email",
|
|
323
|
-
message2: "shortly.",
|
|
324
|
-
details: "Purchase Details",
|
|
325
|
-
support: "Any doubt or inquiry you can contact support"
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
errors: {
|
|
329
|
-
generic: "An unexpected error occurred.",
|
|
330
|
-
publicKeyMissing: "Public Key is missing",
|
|
331
|
-
config: "Config Error",
|
|
332
|
-
timeout: "The payment time has expired. Please generate a new order."
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
// src/i18n/index.ts
|
|
337
|
-
var I18nService = class {
|
|
338
|
-
// Cambiar idioma
|
|
339
|
-
static setLocale(locale) {
|
|
340
|
-
this._currentLocale = locale;
|
|
341
|
-
this._dictionary = locale === "en" ? en : es;
|
|
342
|
-
}
|
|
343
|
-
static get current() {
|
|
344
|
-
return this._currentLocale;
|
|
345
|
-
}
|
|
346
|
-
// Función para obtener texto (Tipado seguro para claves anidadas sería complejo,
|
|
347
|
-
// así que usaremos acceso directo o un getter helper si lo prefieres)
|
|
348
|
-
static get t() {
|
|
349
|
-
return this._dictionary;
|
|
350
|
-
}
|
|
351
|
-
// Helper para interpolar variables: "Hola {name}" -> "Hola Mundo"
|
|
352
|
-
static interpolate(text, params) {
|
|
353
|
-
return text.replace(/{(\w+)}/g, (match, key) => {
|
|
354
|
-
return typeof params[key] !== "undefined" ? String(params[key]) : match;
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
I18nService._currentLocale = "es";
|
|
359
|
-
I18nService._dictionary = es;
|
|
360
435
|
export {
|
|
361
436
|
ApoloPayClient,
|
|
437
|
+
ClientCode,
|
|
362
438
|
ClientError,
|
|
363
439
|
ClientResponse,
|
|
364
440
|
ClientResponseBase,
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolopay-sdk/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Core SDK for Apolo Pay",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ApoloPay/payment-button-sdk.git"
|
|
10
|
+
},
|
|
7
11
|
"main": "./dist/index.js",
|
|
8
12
|
"module": "./dist/index.mjs",
|
|
9
13
|
"types": "./dist/index.d.ts",
|