@achyutlabsau/vue-payment-gateway 0.14.0 → 0.15.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.
@@ -4,7 +4,22 @@ import { Dialog as f, QCard as p, QCardSection as m, QDialog as h, useDialogPlug
4
4
  //#region src/core/types.ts
5
5
  var _ = /* @__PURE__ */ function(e) {
6
6
  return e.Approved = "approved", e.Declined = "declined", e.Cancelled = "cancelled", e.Failed = "failed", e.Timeout = "timeout", e;
7
- }({}), v = { class: "text-center text-lg font-semibold text-gray-500 uppercase" }, y = { class: "text-center text-lg font-semibold text-gray-500 uppercase" }, b = { class: "text-center text-lg font-semibold text-gray-500 uppercase" }, x = /* @__PURE__ */ a({
7
+ }({});
8
+ function v(e) {
9
+ return {
10
+ transactionId: null,
11
+ amount: null,
12
+ tipAmount: null,
13
+ surchargeAmount: null,
14
+ receipts: {},
15
+ raw: null,
16
+ ...e,
17
+ success: e.status === "approved"
18
+ };
19
+ }
20
+ //#endregion
21
+ //#region src/components/TransactionDialog.vue?vue&type=script&setup=true&lang.ts
22
+ var y = { class: "text-center text-lg font-semibold text-gray-500 uppercase" }, b = { class: "text-center text-lg font-semibold text-gray-500 uppercase" }, x = { class: "text-center text-lg font-semibold text-gray-500 uppercase" }, S = /* @__PURE__ */ a({
8
23
  __name: "TransactionDialog",
9
24
  props: {
10
25
  message: {},
@@ -14,7 +29,7 @@ var _ = /* @__PURE__ */ function(e) {
14
29
  emits: [...g.emits],
15
30
  setup(a) {
16
31
  let { dialogRef: f, onDialogHide: _ } = g();
17
- return (g, x) => {
32
+ return (g, v) => {
18
33
  let S = s("close-popup");
19
34
  return o(), t(l(h), {
20
35
  ref_key: "dialogRef",
@@ -24,7 +39,7 @@ var _ = /* @__PURE__ */ function(e) {
24
39
  }, {
25
40
  default: u(() => [i(l(p), { class: "q-dialog-plugin px-6 py-3" }, {
26
41
  default: u(() => [a.title === "INPROGRESS" ? (o(), t(l(m), { key: 0 }, {
27
- default: u(() => [r("div", v, c(a.message), 1), i(e, {
42
+ default: u(() => [r("div", y, c(a.message), 1), i(e, {
28
43
  label: "Cancel",
29
44
  onClick: a.cancelTxn,
30
45
  color: "primary",
@@ -33,7 +48,7 @@ var _ = /* @__PURE__ */ function(e) {
33
48
  }, null, 8, ["onClick"])]),
34
49
  _: 1
35
50
  })) : a.title === "SUCCESS" ? (o(), t(l(m), { key: 1 }, {
36
- default: u(() => [r("div", y, c(a.message), 1), d(i(e, {
51
+ default: u(() => [r("div", b, c(a.message), 1), d(i(e, {
37
52
  label: "OK",
38
53
  color: "primary",
39
54
  outline: "",
@@ -41,7 +56,7 @@ var _ = /* @__PURE__ */ function(e) {
41
56
  }, null, 512), [[S]])]),
42
57
  _: 1
43
58
  })) : a.title === "FAILED" ? (o(), t(l(m), { key: 2 }, {
44
- default: u(() => [r("div", b, c(a.message), 1), d(i(e, {
59
+ default: u(() => [r("div", x, c(a.message), 1), d(i(e, {
45
60
  label: "OK",
46
61
  color: "primary",
47
62
  outline: "",
@@ -58,9 +73,9 @@ var _ = /* @__PURE__ */ function(e) {
58
73
  });
59
74
  //#endregion
60
75
  //#region src/core/dialog.ts
61
- function S(e) {
76
+ function C(e) {
62
77
  let t = e.successHideDelay ?? 1e3, n = f.create({
63
- component: x,
78
+ component: S,
64
79
  componentProps: {
65
80
  title: "INPROGRESS",
66
81
  message: e.message,
@@ -89,4 +104,4 @@ function S(e) {
89
104
  };
90
105
  }
91
106
  //#endregion
92
- export { S as t };
107
+ export { _ as n, v as r, C as t };
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@ import { i as a, t as o } from "./tyro-CfOu7q7t.js";
3
3
  import { f as s, m as c } from "./mx51-Df356gl0.js";
4
4
  import { a as l, i as u, r as d } from "./worldline-CEiMow5_.js";
5
5
  import { n as f } from "./utils-LqvcWjKL.js";
6
- import { t as p } from "./linkly-Bd7pRZfC.js";
6
+ import { t as p } from "./linkly-yernhu9V.js";
7
7
  import { t as m } from "./smartpay-BSvt0cIh.js";
8
- import { t as h } from "./till-payment-CRvW9BhY.js";
9
- import { t as g } from "./valpay-DVhZ6XFw.js";
8
+ import { t as h } from "./till-payment-DSScmuag.js";
9
+ import { t as g } from "./valpay--SOqhe0M.js";
10
10
  import { createBlock as _, createCommentVNode as v, createElementBlock as y, defineComponent as b, openBlock as x, unref as S } from "vue";
11
11
  import { useEventListener as C, useScriptTag as w } from "@vueuse/core";
12
12
  //#region src/plugin/types.ts
@@ -1,7 +1,7 @@
1
1
  import { a as e, h as t, i as n, o as r, r as i, t as a, u as o } from "./PairInstructions-BxzivULm.js";
2
2
  import { i as s, n as c, r as l, t as u } from "./utils-LqvcWjKL.js";
3
3
  import { t as d } from "./utils-BPFf60Ai.js";
4
- import { t as f } from "./core-Cl5IrG_Z.js";
4
+ import { t as f } from "./core-nvcK0Nr9.js";
5
5
  import { createBlock as p, createElementBlock as m, createElementVNode as h, createTextVNode as g, createVNode as _, defineComponent as v, onMounted as ee, openBlock as y, ref as b, renderSlot as x, resolveDirective as S, toDisplayString as te, unref as C, useModel as w, withCtx as T, withDirectives as E } from "vue";
6
6
  import { Dialog as D, Loading as O, Notify as k, QBtn as A, QCard as j, QCardActions as ne, QCardSection as re, QDialog as ie, QForm as ae, QIcon as M, QInput as N, QToolbar as P, QToolbarTitle as F } from "quasar";
7
7
  import { useLocalStorage as oe } from "@vueuse/core";
package/dist/linkly.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./linkly-Bd7pRZfC.js";
1
+ import { a as e, c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./linkly-yernhu9V.js";
2
2
  export { a as CurrencyCodes, n as LinklyKeyType, s as PairLinkly, e as ReceiptAutoPrint, i as ResponseCodes, o as TransactionOutcome, t as TransactionTypes, r as useLinkly };
@@ -1,33 +1,33 @@
1
1
  import { a as e, h as t, i as n, o as r, r as i, t as a } from "./PairInstructions-BxzivULm.js";
2
2
  import { t as o } from "./utils-LqvcWjKL.js";
3
- import { t as s } from "./core-Cl5IrG_Z.js";
4
- import { createBlock as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, onMounted as m, openBlock as h, ref as g, renderSlot as _, resolveDirective as v, toDisplayString as y, unref as b, useModel as x, withCtx as S, withDirectives as C } from "vue";
5
- import { Dialog as w, Loading as T, Notify as E, QBtn as D, QCard as O, QCardActions as k, QCardSection as A, QDialog as j, QForm as M, QIcon as N, QInput as P, QSelect as F, QToolbar as I, QToolbarTitle as L } from "quasar";
6
- import { useLocalStorage as R } from "@vueuse/core";
7
- import { validate as z } from "uuid";
8
- import B from "dayjs";
9
- import V, { HttpStatusCode as H, isAxiosError as U } from "axios";
3
+ import { n as s, r as c, t as l } from "./core-nvcK0Nr9.js";
4
+ import { createBlock as u, createElementBlock as d, createElementVNode as f, createTextVNode as p, createVNode as m, defineComponent as h, onMounted as g, openBlock as _, ref as v, renderSlot as y, resolveDirective as b, toDisplayString as x, unref as S, useModel as C, withCtx as w, withDirectives as T } from "vue";
5
+ import { Dialog as E, Loading as D, Notify as O, QBtn as k, QCard as A, QCardActions as j, QCardSection as M, QDialog as N, QForm as P, QIcon as F, QInput as I, QSelect as L, QToolbar as R, QToolbarTitle as z } from "quasar";
6
+ import { useLocalStorage as B } from "@vueuse/core";
7
+ import { validate as V } from "uuid";
8
+ import H from "dayjs";
9
+ import U, { HttpStatusCode as W, isAxiosError as ee } from "axios";
10
10
  //#region src/library/till-payment/tillPayment.enums.ts
11
- var W = /* @__PURE__ */ function(e) {
11
+ var te = /* @__PURE__ */ function(e) {
12
12
  return e.SETTLEMENT = "SETTLEMENT", e.PRE_SETTLEMENT = "PRE_SETTLEMENT", e.LAST_SETTLEMENT = "LAST_SETTLEMENT", e;
13
13
  }({}), G = /* @__PURE__ */ function(e) {
14
14
  return e.REPRINT_RECEIPT = "REPRINT_RECEIPT", e.PAYMENT = "PAYMENT", e.REFUND = "REFUND", e.REVERSAL = "REVERSAL", e.PREAUTH = "PREAUTH", e.PREAUTH_CANCEL = "PREAUTH_CANCEL", e.PREAUTH_CAPTURE = "PREAUTH_CAPTURE", e;
15
15
  }({}), K = /* @__PURE__ */ function(e) {
16
16
  return e.Accepted = "accepted", e.Declined = "declined", e.Cancelled = "cancelled", e.Timeout = "timeout", e.Failed = "failed", e;
17
17
  }({}), q = (e) => {
18
- if (console.error(e), U(e)) {
18
+ if (console.error(e), ee(e)) {
19
19
  let t = e.response?.data, n = t?.statusCode, r = e.code === "ERR_NETWORK";
20
20
  return {
21
21
  error: !0,
22
- message: n === H.Forbidden ? "Invalid merchantId or apiKey" : r ? "Connection to terminal lost(404).Check internet connection." : t?.message ?? "Something went wrong!",
22
+ message: n === W.Forbidden ? "Invalid merchantId or apiKey" : r ? "Connection to terminal lost(404).Check internet connection." : t?.message ?? "Something went wrong!",
23
23
  code: r ? "ERR_NETWORK" : t?.code,
24
- statusCode: n ?? H.BadRequest
24
+ statusCode: n ?? W.BadRequest
25
25
  };
26
26
  }
27
27
  return {
28
28
  error: !0,
29
29
  message: e instanceof Error ? e.message : "something went wrong!",
30
- statusCode: H.BadRequest
30
+ statusCode: W.BadRequest
31
31
  };
32
32
  }, J = (e) => (e / 100).toFixed(2), Y = (e, t) => {
33
33
  try {
@@ -57,7 +57,7 @@ Auth Code: ${n.authCode}
57
57
  Response: ${o} ${s}
58
58
  ${n.tvr ? `TVR: ${n.tvr}\n` : ""}Transaction Ref: ${n.externalReferenceId}
59
59
  Terminal ID: ${i}
60
- ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
60
+ ${H(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
61
61
 
62
62
  ${n.authorizationMethod === "NONE" ? "APPROVED" : `${n.authorizationMethod} APPROVED`}
63
63
  `
@@ -79,7 +79,7 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
79
79
  environment: "SANDBOX",
80
80
  ...t
81
81
  }, !t.apiKey || !t.merchantId) throw Error("Please provide 'merchantId' & 'apiKey'.");
82
- this.api = V.create({
82
+ this.api = U.create({
83
83
  baseURL: `${e.URLS[this.config.environment]}/merchant/${this.config.merchantId}`,
84
84
  timeout: this.config.timeout,
85
85
  headers: {
@@ -172,7 +172,7 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
172
172
  try {
173
173
  return (await this.api.post(`/intent/${t}/process`, { tid: e })).status === 201;
174
174
  } catch (e) {
175
- throw V.isAxiosError(e), e;
175
+ throw U.isAxiosError(e), e;
176
176
  }
177
177
  }
178
178
  async processTransaction(e, t) {
@@ -244,75 +244,90 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
244
244
  statusCode: 0
245
245
  };
246
246
  }
247
- }, Z = () => {
247
+ };
248
+ //#endregion
249
+ //#region src/library/till-payment/tillPayment.mapper.ts
250
+ function Z(e) {
251
+ switch (e) {
252
+ case K.Accepted: return s.Approved;
253
+ case K.Declined: return s.Declined;
254
+ case K.Cancelled: return s.Cancelled;
255
+ case K.Timeout: return s.Timeout;
256
+ default: return s.Failed;
257
+ }
258
+ }
259
+ function ne(e) {
260
+ if ("error" in e) return c({
261
+ status: s.Failed,
262
+ message: e.message,
263
+ raw: e
264
+ });
265
+ let t = Z(e.transactionOutcome), n = e.data?.transactionDetails, r = {};
266
+ return e.data?.merchantReceipt && (r.merchant = e.data.merchantReceipt), e.data?.customerReceipt && (r.customer = e.data.customerReceipt), c({
267
+ status: t,
268
+ transactionId: e.data?.intentId ?? null,
269
+ amount: n?.paymentAmount ?? null,
270
+ tipAmount: n?.amount.tip || null,
271
+ surchargeAmount: n ? n.amount.surcharge : null,
272
+ receipts: r,
273
+ message: e.message ?? (t === s.Approved ? "Transaction Accepted!" : `Transaction ${e.transactionOutcome}!`),
274
+ raw: e.data ?? null
275
+ });
276
+ }
277
+ //#endregion
278
+ //#region src/library/till-payment/useTillPayment.ts
279
+ var re = () => !!localStorage.getItem("till.tid"), Q = () => {
248
280
  let e = new X({
249
281
  apiKey: t.tillPaymentApiKey,
250
282
  merchantId: t.tillPaymentMerchantId,
251
283
  environment: "SANDBOX"
252
- });
284
+ }), n = async ({ tid: t }) => {
285
+ let n = await e.pairTerminal(t);
286
+ return "error" in n ? {
287
+ success: !1,
288
+ message: n.message,
289
+ raw: n
290
+ } : {
291
+ success: !0,
292
+ message: "Terminal paired successfully",
293
+ raw: n
294
+ };
295
+ }, r = () => {
296
+ e.unpair();
297
+ }, i = async (t, n, r) => {
298
+ let i = r?.tipAmount, a = l({
299
+ message: `${t} of $${n / 100}${i === void 0 ? "" : ` (+ $${i / 100} tip)`} in progress...`,
300
+ onCancel: () => {
301
+ a.progress("Trying to cancel transaction..."), e.cancelIntent();
302
+ }
303
+ }), o = ne(t === "Purchase" ? await e.initiatePurchase({
304
+ subTotal: n,
305
+ tip: i
306
+ }) : await e.initiateRefund({ amount: n }));
307
+ return a.settle(o.status, o.message), o;
308
+ };
253
309
  return {
254
- initiateTillPurchase: async (t) => {
255
- let n = s({
256
- message: `Purchase of $${t / 100} in progress...`,
257
- onCancel: () => {
258
- n.progress("Trying to cancel transaction..."), e.cancelIntent();
259
- }
260
- }), r = await e.initiatePurchase({ subTotal: t });
261
- return "error" in r ? (n.failed(r.message), {
262
- success: !1,
263
- transactionId: null,
264
- customerReceipt: null,
265
- merchantReceipt: null,
266
- surchargeAmount: 0,
267
- tipAmount: null
268
- }) : (r.transactionOutcome === K.Accepted ? n.success("Transaction Accepted!") : n.failed(`Transaction ${r.transactionOutcome}!`), {
269
- success: r.transactionOutcome === K.Accepted,
270
- transactionId: r.data.intentId,
271
- customerReceipt: r.data?.customerReceipt,
272
- merchantReceipt: r.data?.merchantReceipt,
273
- surchargeAmount: r.data?.transactionDetails?.amount?.surcharge ?? 0,
274
- tipAmount: r.data?.transactionDetails?.amount?.tip ?? null
275
- });
276
- },
277
- initiateTillRefund: async (t) => {
278
- let n = s({
279
- message: `Refund of $${t / 100} in progress...`,
280
- onCancel: () => {
281
- n.progress("Trying to cancel transaction..."), e.cancelIntent();
282
- }
283
- }), r = await e.initiateRefund({ amount: t });
284
- return "error" in r ? (n.failed(r.message), {
285
- success: !1,
286
- transactionId: null,
287
- customerReceipt: null,
288
- merchantReceipt: null,
289
- surchargeAmount: 0,
290
- tipAmount: null
291
- }) : (r.transactionOutcome === K.Accepted ? n.success("Transaction Accepted") : n.failed(`Transaction ${r.transactionOutcome}!`), {
292
- success: r.transactionOutcome === K.Accepted,
293
- transactionId: r.data.intentId,
294
- customerReceipt: r.data?.customerReceipt,
295
- merchantReceipt: r.data?.merchantReceipt,
296
- surchargeAmount: r.data?.transactionDetails?.amount?.surcharge ?? 0,
297
- tipAmount: r.data?.transactionDetails?.amount?.tip ?? null
298
- });
299
- },
310
+ pair: n,
311
+ unpair: r,
312
+ isPaired: re,
313
+ purchase: (e, t) => i("Purchase", e, t),
314
+ refund: (e) => i("Refund", e),
300
315
  reprintReceipt: async (t) => {
301
316
  try {
302
- T.show();
303
- let n = await e.reprintReceipt(t);
304
- return T.hide(), n;
317
+ return D.show(), await e.reprintReceipt(t);
305
318
  } catch (e) {
306
319
  return console.error(e), {
307
320
  error: !0,
308
321
  message: "Failed to reprint receipt",
309
322
  statusCode: 400
310
323
  };
324
+ } finally {
325
+ D.hide();
311
326
  }
312
327
  },
313
- tillPayment: e
328
+ raw: e
314
329
  };
315
- }, Q = { class: "" }, $ = /* @__PURE__ */ p({
330
+ }, ie = { class: "" }, ae = /* @__PURE__ */ h({
316
331
  __name: "ReprintReceiptDialog",
317
332
  props: {
318
333
  modelValue: { type: Boolean },
@@ -320,38 +335,38 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
320
335
  },
321
336
  emits: ["update:modelValue"],
322
337
  setup(e) {
323
- let t = Z(), n = x(e, "modelValue"), r = g(""), i = async () => {
338
+ let t = Q(), n = C(e, "modelValue"), r = v(""), i = async () => {
324
339
  try {
325
- T.show({ group: "reprintReceipt" });
340
+ D.show({ group: "reprintReceipt" });
326
341
  let e = await t.reprintReceipt(r.value);
327
- e.error ? E.create({
342
+ e.error ? O.create({
328
343
  type: "negative",
329
344
  message: e.message
330
- }) : (n.value = !1, E.create("Receipt printed successfully"));
345
+ }) : (n.value = !1, O.create("Receipt printed successfully"));
331
346
  } catch (e) {
332
347
  let t = e instanceof Error ? e.message : "Failed to print receipts";
333
- E.create({
348
+ O.create({
334
349
  type: "negative",
335
350
  message: t
336
351
  });
337
352
  } finally {
338
- T.hide("reprintReceipt");
353
+ D.hide("reprintReceipt");
339
354
  }
340
355
  };
341
356
  return (e, t) => {
342
- let a = v("close-popup");
343
- return h(), c(b(j), {
357
+ let a = b("close-popup");
358
+ return _(), u(S(N), {
344
359
  modelValue: n.value,
345
360
  "onUpdate:modelValue": t[1] ||= (e) => n.value = e
346
361
  }, {
347
- default: S(() => [f(b(O), { class: "w-full" }, {
348
- default: S(() => [f(b(M), { onSubmit: i }, {
349
- default: S(() => [
350
- f(b(I), { class: "bg-primary text-white" }, {
351
- default: S(() => [f(b(L), null, {
352
- default: S(() => [_(e.$slots, "title", {}, () => [t[2] ||= d("Reprint Receipt", -1)])]),
362
+ default: w(() => [m(S(A), { class: "w-full" }, {
363
+ default: w(() => [m(S(P), { onSubmit: i }, {
364
+ default: w(() => [
365
+ m(S(R), { class: "bg-primary text-white" }, {
366
+ default: w(() => [m(S(z), null, {
367
+ default: w(() => [y(e.$slots, "title", {}, () => [t[2] ||= p("Reprint Receipt", -1)])]),
353
368
  _: 3
354
- }), C(f(b(N), {
369
+ }), T(m(S(F), {
355
370
  class: "float-right cursor-pointer rounded p-2 transition-colors",
356
371
  color: "gray",
357
372
  name: "close",
@@ -359,11 +374,11 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
359
374
  }, null, 512), [[a]])]),
360
375
  _: 3
361
376
  }),
362
- f(b(A), null, {
363
- default: S(() => [u("div", Q, [t[3] ||= d(" Txn Number: ", -1), f(b(P), {
377
+ m(S(M), null, {
378
+ default: w(() => [f("div", ie, [t[3] ||= p(" Txn Number: ", -1), m(S(I), {
364
379
  modelValue: r.value,
365
380
  "onUpdate:modelValue": t[0] ||= (e) => r.value = e,
366
- rules: [(e) => !!e || "Transaction Id is required", (e) => b(z)(e) || "Invalid Transaction Id"],
381
+ rules: [(e) => !!e || "Transaction Id is required", (e) => S(V)(e) || "Invalid Transaction Id"],
367
382
  class: "q-mb-sm",
368
383
  type: "text",
369
384
  outlined: "",
@@ -373,16 +388,16 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
373
388
  }, null, 8, ["modelValue", "rules"])])]),
374
389
  _: 1
375
390
  }),
376
- f(b(k), {
391
+ m(S(j), {
377
392
  class: "!p-4",
378
393
  align: "right"
379
394
  }, {
380
- default: S(() => [C(f(b(D), {
395
+ default: w(() => [T(m(S(k), {
381
396
  label: "Cancel",
382
397
  "no-caps": "",
383
398
  unelevated: "",
384
399
  flat: ""
385
- }, null, 512), [[a]]), f(b(D), {
400
+ }, null, 512), [[a]]), m(S(k), {
386
401
  label: "Re-print Receipt",
387
402
  "no-caps": "",
388
403
  unelevated: "",
@@ -400,110 +415,110 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
400
415
  }, 8, ["modelValue"]);
401
416
  };
402
417
  }
403
- }), ee = { class: "text-center" }, te = { class: "mb-6" }, ne = { class: "!mb-2 text-sm text-gray-500 dark:text-gray-300" }, re = { class: "mb-6 text-sm text-gray-500 dark:text-gray-300" }, ie = { class: "!space-x-3" }, ae = { key: 1 }, oe = { class: "flex items-center justify-end gap-3" }, se = /* @__PURE__ */ p({
418
+ }), oe = { class: "text-center" }, $ = { class: "mb-6" }, se = { class: "!mb-2 text-sm text-gray-500 dark:text-gray-300" }, ce = { class: "mb-6 text-sm text-gray-500 dark:text-gray-300" }, le = { class: "!space-x-3" }, ue = { key: 1 }, de = { class: "flex items-center justify-end gap-3" }, fe = /* @__PURE__ */ h({
404
419
  __name: "PairTillPayment",
405
420
  setup(t) {
406
421
  let o = [
407
422
  "Plug in the PIN pad and connect it to the internet via cable or Wi-Fi, depending on the EFTPOS hardware.",
408
423
  "Once connected, the PIN pad will display as online.",
409
424
  "Select the terminal on the next screen and click 'Pair Device'."
410
- ], { tillPayment: s } = Z(), p = R("till.pairConfig", {
425
+ ], { raw: s, pair: c, unpair: l } = Q(), h = B("till.pairConfig", {
411
426
  isPaired: !1,
412
427
  lastPairedDate: "",
413
428
  terminalId: ""
414
- }), _ = g([]), v = g(null), x = g(!p.value.isPaired), C = g(!1), k = () => {
415
- x.value = !1;
416
- }, j = () => {
417
- p.value.isPaired = !1, s.unpair();
418
- }, P = async () => {
429
+ }), y = v([]), b = v(null), C = v(!h.value.isPaired), T = v(!1), j = () => {
430
+ C.value = !1;
431
+ }, N = () => {
432
+ h.value.isPaired = !1, l();
433
+ }, I = async () => {
419
434
  try {
420
- T.show();
421
- let e = await s.pairTerminal(v.value);
422
- if ("error" in e) {
423
- w.create({
435
+ D.show();
436
+ let e = await c({ tid: b.value });
437
+ if (!e.success) {
438
+ E.create({
424
439
  title: "Pairing Failed!",
425
440
  message: e.message ?? "Failed To pair terminal."
426
441
  });
427
442
  return;
428
443
  }
429
- p.value.isPaired = !0, p.value.lastPairedDate = /* @__PURE__ */ new Date(), p.value.terminalId = v.value;
444
+ h.value.isPaired = !0, h.value.lastPairedDate = /* @__PURE__ */ new Date(), h.value.terminalId = b.value;
430
445
  } catch (e) {
431
- w.create({
446
+ E.create({
432
447
  title: "Pairing Failed!",
433
448
  message: e instanceof Error ? e.message : "Failed To pair terminal."
434
449
  });
435
450
  } finally {
436
- T.hide();
451
+ D.hide();
437
452
  }
438
- }, I = async () => {
453
+ }, R = async () => {
439
454
  let e = await s.getTerminals();
440
455
  if ("error" in e) {
441
- E.create({
456
+ O.create({
442
457
  type: "negative",
443
458
  message: "failed to fetch terminals"
444
459
  });
445
460
  return;
446
461
  }
447
- _.value = e;
462
+ y.value = e;
448
463
  };
449
- return m(async () => {
450
- await I();
451
- }), (t, s) => (h(), l("div", null, [b(p).isPaired ? (h(), c(b(O), {
464
+ return g(async () => {
465
+ await R();
466
+ }), (t, s) => (_(), d("div", null, [S(h).isPaired ? (_(), u(S(A), {
452
467
  key: "paired",
453
468
  class: "flex items-center justify-center rounded-lg p-8",
454
469
  flat: "",
455
470
  bordered: ""
456
471
  }, {
457
- default: S(() => [u("div", ee, [
458
- u("div", te, [f(b(N), {
459
- name: b(i),
472
+ default: w(() => [f("div", oe, [
473
+ f("div", $, [m(S(F), {
474
+ name: S(i),
460
475
  size: "4rem",
461
476
  class: "text-green-500"
462
477
  }, null, 8, ["name"])]),
463
- s[6] ||= u("h2", { class: "mb-4 text-3xl font-bold" }, "Terminal Connected", -1),
464
- u("p", ne, [s[4] ||= d(" Terminal ID: ", -1), u("b", null, y(b(p).terminalId), 1)]),
465
- u("p", re, [s[5] ||= d(" Last paired: ", -1), u("b", null, y(new Date(b(p).lastPairedDate).toLocaleString()), 1)]),
466
- u("div", ie, [f(b(D), {
478
+ s[6] ||= f("h2", { class: "mb-4 text-3xl font-bold" }, "Terminal Connected", -1),
479
+ f("p", se, [s[4] ||= p(" Terminal ID: ", -1), f("b", null, x(S(h).terminalId), 1)]),
480
+ f("p", ce, [s[5] ||= p(" Last paired: ", -1), f("b", null, x(new Date(S(h).lastPairedDate).toLocaleString()), 1)]),
481
+ f("div", le, [m(S(k), {
467
482
  color: "green",
468
483
  "no-caps": "",
469
484
  outline: "",
470
485
  unelevated: "",
471
486
  label: "Reprint Receipt",
472
- "icon-left": b(n),
473
- onClick: s[0] ||= (e) => C.value = !0
474
- }, null, 8, ["icon-left"]), f(b(D), {
487
+ "icon-left": S(n),
488
+ onClick: s[0] ||= (e) => T.value = !0
489
+ }, null, 8, ["icon-left"]), m(S(k), {
475
490
  color: "primary",
476
491
  unelevated: "",
477
492
  "no-caps": "",
478
- "icon-left": b(r),
493
+ "icon-left": S(r),
479
494
  label: "Re-pair Terminal",
480
- onClick: j
495
+ onClick: N
481
496
  }, null, 8, ["icon-left"])])
482
- ]), f($, {
483
- modelValue: C.value,
484
- "onUpdate:modelValue": s[1] ||= (e) => C.value = e
497
+ ]), m(ae, {
498
+ modelValue: T.value,
499
+ "onUpdate:modelValue": s[1] ||= (e) => T.value = e
485
500
  }, null, 8, ["modelValue"])]),
486
501
  _: 1
487
- })) : (h(), l("div", ae, [x.value ? (h(), c(a, {
502
+ })) : (_(), d("div", ue, [C.value ? (_(), u(a, {
488
503
  key: 0,
489
- onNext: k,
504
+ onNext: j,
490
505
  steps: o
491
- })) : (h(), c(b(O), {
506
+ })) : (_(), u(S(A), {
492
507
  key: 1,
493
508
  flat: "",
494
509
  bordered: ""
495
510
  }, {
496
- default: S(() => [f(b(A), null, {
497
- default: S(() => [s[7] ||= u("h3", { class: "mb-3 !text-xl font-semibold" }, "Pairing configuration", -1), f(b(M), { onSubmit: P }, {
498
- default: S(() => [f(b(F), {
511
+ default: w(() => [m(S(M), null, {
512
+ default: w(() => [s[7] ||= f("h3", { class: "mb-3 !text-xl font-semibold" }, "Pairing configuration", -1), m(S(P), { onSubmit: I }, {
513
+ default: w(() => [m(S(L), {
499
514
  label: "Select Terminal",
500
515
  dense: "",
501
516
  outlined: "",
502
- modelValue: v.value,
503
- "onUpdate:modelValue": s[2] ||= (e) => v.value = e,
517
+ modelValue: b.value,
518
+ "onUpdate:modelValue": s[2] ||= (e) => b.value = e,
504
519
  "option-disable": (e) => e.status.connectivity !== "AVAILABLE",
505
520
  "option-label": ({ name: e, terminalId: t }) => e ? `${e} (${t})` : "",
506
- options: _.value,
521
+ options: y.value,
507
522
  rules: [(e) => !!e || "Please select terminal."],
508
523
  "option-value": "terminalId",
509
524
  "outer-label": "Select Terminal",
@@ -516,18 +531,18 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
516
531
  "option-label",
517
532
  "options",
518
533
  "rules"
519
- ]), u("div", oe, [f(b(D), {
534
+ ]), f("div", de, [m(S(k), {
520
535
  flat: "",
521
536
  "no-caps": "",
522
537
  label: "Back",
523
- "icon-left": b(n),
524
- onClick: s[3] ||= (e) => x.value = !0
525
- }, null, 8, ["icon-left"]), f(b(D), {
538
+ "icon-left": S(n),
539
+ onClick: s[3] ||= (e) => C.value = !0
540
+ }, null, 8, ["icon-left"]), m(S(k), {
526
541
  type: "submit",
527
542
  color: "primary",
528
543
  unelevated: "",
529
544
  "no-caps": "",
530
- "icon-right": b(e),
545
+ "icon-right": S(e),
531
546
  label: "Pair Device"
532
547
  }, null, 8, ["icon-right"])])]),
533
548
  _: 1
@@ -539,4 +554,4 @@ ${B(n.dateTime).format("DD MMM YYYY [at] hh:mm A")}
539
554
  }
540
555
  });
541
556
  //#endregion
542
- export { K as a, W as i, Z as n, G as o, X as r, se as t };
557
+ export { K as a, te as i, Q as n, G as o, X as r, fe as t };