@tineon/t9n 0.1.8 → 0.1.9

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -185,6 +185,7 @@ export class T9nCheckout {
185
185
  }
186
186
  async confirmPayment() {
187
187
  this.hasAttemptedConfirm = true;
188
+ console.log("[T9N] confirmPayment: start", { sessionId: this.sessionId });
188
189
  this.modal?.setConfirmPending(true);
189
190
  try {
190
191
  const res = await this.fetchWithTimeout(`${this.getApiBaseUrl()}/api/merchant/checkout/sessions/${this.sessionId}/confirm-payment`, {
@@ -196,6 +197,7 @@ export class T9nCheckout {
196
197
  body: "{}",
197
198
  });
198
199
  if (!res.ok) {
200
+ console.log("[T9N] confirmPayment: non-ok response", { status: res.status, sessionId: this.sessionId });
199
201
  this.modal?.setConfirmPending(false);
200
202
  this.modal?.showResult("failed", "Verification failed. Please try again.");
201
203
  this.lastResultFailed = true;
@@ -207,8 +209,10 @@ export class T9nCheckout {
207
209
  let payload = {};
208
210
  try {
209
211
  payload = (await res.json());
212
+ console.log("[T9N] confirmPayment: response payload", { payload, sessionId: this.sessionId });
210
213
  }
211
214
  catch (_) {
215
+ console.log("[T9N] confirmPayment: invalid json response", { sessionId: this.sessionId });
212
216
  this.modal?.setConfirmPending(false);
213
217
  this.modal?.showResult("failed", "Verification failed. Please try again.");
214
218
  this.lastResultFailed = true;
@@ -219,8 +223,10 @@ export class T9nCheckout {
219
223
  }
220
224
  this.modal?.setConfirmPending(false);
221
225
  const normalized = this.normalizeStatus(payload.status || "");
226
+ console.log("[T9N] confirmPayment: normalized status", { status: payload.status, normalized, sessionId: this.sessionId });
222
227
  this.emitStatus(normalized);
223
228
  if (normalized === "settled") {
229
+ console.log("[T9N] confirmPayment: showing success", { sessionId: this.sessionId });
224
230
  this.modal?.setConfirmLabel("I have made the payment");
225
231
  this.modal?.showResult("success", "Payment received successfully.");
226
232
  this.lastResultFailed = false;
@@ -228,6 +234,7 @@ export class T9nCheckout {
228
234
  return;
229
235
  }
230
236
  if (normalized === "expired") {
237
+ console.log("[T9N] confirmPayment: showing expired", { sessionId: this.sessionId });
231
238
  this.modal?.showResult("failed", "This session has expired.");
232
239
  this.lastResultFailed = false;
233
240
  this.emitFailOnce({ sessionId: this.sessionId, error: "checkout expired" });
@@ -235,6 +242,7 @@ export class T9nCheckout {
235
242
  return;
236
243
  }
237
244
  if (normalized === "failed") {
245
+ console.log("[T9N] confirmPayment: showing failed", { sessionId: this.sessionId });
238
246
  this.modal?.showResult("failed", "Payment failed. Please try again.");
239
247
  this.lastResultFailed = true;
240
248
  this.modal?.setConfirmLabel("Retry check");
@@ -242,18 +250,21 @@ export class T9nCheckout {
242
250
  return;
243
251
  }
244
252
  if (normalized === "closed") {
253
+ console.log("[T9N] confirmPayment: showing closed", { sessionId: this.sessionId });
245
254
  this.modal?.showResult("failed", "Checkout was closed. Please try again.");
246
255
  this.lastResultFailed = true;
247
256
  this.modal?.setConfirmLabel("Retry check");
248
257
  this.emitFailOnce({ sessionId: this.sessionId || undefined, error: "checkout closed" });
249
258
  return;
250
259
  }
260
+ console.log("[T9N] confirmPayment: showing no-funds retry", { sessionId: this.sessionId });
251
261
  this.modal?.showResult("failed", "No payment detected yet. Please try again.");
252
262
  this.lastResultFailed = true;
253
263
  this.modal?.setConfirmLabel("Retry check");
254
264
  this.emitFailOnce({ sessionId: this.sessionId || undefined, error: "payment not detected" });
255
265
  }
256
266
  catch (err) {
267
+ console.log("[T9N] confirmPayment: error", { error: err?.message || err, sessionId: this.sessionId });
257
268
  this.modal?.setConfirmPending(false);
258
269
  this.modal?.showResult("failed", "Verification failed. Please try again.");
259
270
  this.lastResultFailed = true;
@@ -305,8 +316,10 @@ export class T9nCheckout {
305
316
  const payload = (await res.json());
306
317
  if (payload.status) {
307
318
  const normalized = this.normalizeStatus(payload.status);
319
+ console.log("[T9N] poll: status", { status: payload.status, normalized, sessionId: this.sessionId });
308
320
  this.emitStatus(normalized);
309
321
  if (normalized === "settled") {
322
+ console.log("[T9N] poll: showing success", { sessionId: this.sessionId });
310
323
  this.modal?.showResult("success", "Payment received successfully.");
311
324
  this.lastResultFailed = false;
312
325
  if (this.intervalId)
@@ -317,6 +330,7 @@ export class T9nCheckout {
317
330
  }
318
331
  if (normalized === "failed") {
319
332
  if (this.hasAttemptedConfirm) {
333
+ console.log("[T9N] poll: showing failed", { sessionId: this.sessionId });
320
334
  this.modal?.showResult("failed", "No payment detected yet. Please try again.");
321
335
  this.lastResultFailed = true;
322
336
  this.emitFailOnce({ sessionId: this.sessionId, error: "checkout failed" });
@@ -324,6 +338,7 @@ export class T9nCheckout {
324
338
  }
325
339
  if (normalized === "pending_confirmation" || normalized === "awaiting_payment") {
326
340
  if (this.hasAttemptedConfirm) {
341
+ console.log("[T9N] poll: showing pending no-funds", { sessionId: this.sessionId });
327
342
  this.modal?.showResult("failed", "No payment detected yet. Please try again.");
328
343
  this.lastResultFailed = true;
329
344
  this.emitFailOnce({ sessionId: this.sessionId || undefined, error: "payment not detected" });
@@ -331,6 +346,7 @@ export class T9nCheckout {
331
346
  }
332
347
  }
333
348
  if (payload.status === "expired") {
349
+ console.log("[T9N] poll: showing expired", { sessionId: this.sessionId });
334
350
  this.modal?.showResult("failed", "This session has expired.");
335
351
  this.lastResultFailed = false;
336
352
  if (this.intervalId)
@@ -517,12 +533,14 @@ export class T9nCheckout {
517
533
  if (this.successNotified)
518
534
  return;
519
535
  this.successNotified = true;
536
+ console.log("[T9N] onSuccess", payload);
520
537
  this.cfg.hooks?.onSuccess?.(payload);
521
538
  }
522
539
  emitFailOnce(payload) {
523
540
  if (this.successNotified || this.failureNotified)
524
541
  return;
525
542
  this.failureNotified = true;
543
+ console.log("[T9N] onFail", payload);
526
544
  this.cfg.hooks?.onFail?.(payload);
527
545
  }
528
546
  getApiBaseUrl() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tineon/t9n",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",