@achyutlabsau/vue-payment-gateway 0.3.5 → 0.3.7

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 (30) hide show
  1. package/dist/{PairInstructions.vue_vue_type_script_setup_true_lang-CLCmTRYn.js → PairInstructions.vue_vue_type_script_setup_true_lang-BkPzOduD.js} +55 -6
  2. package/dist/{PairLinkly.vue_vue_type_script_setup_true_lang-BmGTzekg.js → PairLinkly.vue_vue_type_script_setup_true_lang-DM33Q34t.js} +1 -2
  3. package/dist/{PairMX51.vue_vue_type_script_setup_true_lang-HNeIHZA_.js → PairMX51.vue_vue_type_script_setup_true_lang-4wjsUvaJ.js} +126 -5
  4. package/dist/{PairSmartPay.vue_vue_type_script_setup_true_lang-BD4TrPcQ.js → PairSmartPay.vue_vue_type_script_setup_true_lang-CLQRpw0i.js} +1 -2
  5. package/dist/{PairTillPayment.vue_vue_type_script_setup_true_lang-oQDsDv8x.js → PairTillPayment.vue_vue_type_script_setup_true_lang-D5zLdkh3.js} +2 -3
  6. package/dist/{PairTyro.vue_vue_type_script_setup_true_lang-BCSY7FFj.js → PairTyro.vue_vue_type_script_setup_true_lang-JrzRlXk_.js} +25 -3
  7. package/dist/index.d.ts +4 -2
  8. package/dist/index.js +107 -40
  9. package/dist/linkly.d.ts +1 -1
  10. package/dist/linkly.js +1 -1
  11. package/dist/mx51.d.ts +1 -1
  12. package/dist/mx51.js +2 -3
  13. package/dist/smartpay.d.ts +1 -1
  14. package/dist/smartpay.js +1 -1
  15. package/dist/till-payment.d.ts +1 -1
  16. package/dist/till-payment.js +1 -1
  17. package/dist/tyro.d.ts +1 -1
  18. package/dist/tyro.js +2 -3
  19. package/dist/worldline.d.ts +1 -1
  20. package/dist/worldline.js +4 -3112
  21. package/package.json +12 -12
  22. package/dist/PairingInterface-CrRaOUdg.js +0 -49
  23. package/dist/dayjs.min-DGv2T_Zf.js +0 -294
  24. package/dist/event-CqCgKhQE.js +0 -128
  25. package/dist/state-Bwi0Em_K.js +0 -52
  26. package/dist/timApi.d.ts +0 -457
  27. package/dist/timFunctions.d.ts +0 -10
  28. package/dist/timapi.js +0 -1
  29. package/dist/timapi.wasm +0 -0
  30. package/dist/tyro.enums-OZuKaM2C.js +0 -26
@@ -1,5 +1,47 @@
1
- import { defineComponent, createElementBlock, openBlock, createElementVNode, createVNode, unref, Fragment, renderList, toDisplayString } from "vue";
1
+ import { reactive, ref, defineComponent, createElementBlock, openBlock, createElementVNode, createVNode, unref, Fragment, renderList, toDisplayString } from "vue";
2
2
  import { QIcon, QBtn } from "quasar";
3
+ var PaymentGateways = /* @__PURE__ */ ((PaymentGateways2) => {
4
+ PaymentGateways2["Tyro"] = "tyro";
5
+ PaymentGateways2["TillPayment"] = "till-instore";
6
+ PaymentGateways2["MX51"] = "mx51-spi";
7
+ PaymentGateways2["Linkly"] = "linkly";
8
+ PaymentGateways2["SmartPay"] = "smartpay";
9
+ PaymentGateways2["ANZ"] = "anz-instore";
10
+ return PaymentGateways2;
11
+ })(PaymentGateways || {});
12
+ const state = reactive({
13
+ productName: "",
14
+ productVersion: "",
15
+ productVendorName: "",
16
+ posId: "",
17
+ posRegisterId: "",
18
+ posRegisterName: "",
19
+ posBusinessName: "",
20
+ tyroApiKey: "",
21
+ tillPaymentApiKey: "",
22
+ tillPaymentMerchantId: "",
23
+ mx51DeviceApiKey: ""
24
+ });
25
+ const environment = ref("production");
26
+ const isPluginInitialized = ref(false);
27
+ const setState = (options) => {
28
+ options.productName && (state.productName = options.productName);
29
+ options.productVersion && (state.productVersion = options.productVersion);
30
+ options.productVendorName && (state.productVendorName = options.productVendorName);
31
+ options.posId && (state.posId = options.posId);
32
+ options.posRegisterId && (state.posRegisterId = options.posRegisterId);
33
+ options.posRegisterName && (state.posRegisterName = options.posRegisterName);
34
+ options.posBusinessName && (state.posBusinessName = options.posBusinessName);
35
+ options.tyroApiKey && (state.tyroApiKey = options.tyroApiKey);
36
+ options.tillPaymentApiKey && (state.tillPaymentApiKey = options.tillPaymentApiKey);
37
+ options.tillPaymentMerchantId && (state.tillPaymentMerchantId = options.tillPaymentMerchantId);
38
+ options.mx51DeviceApiKey && (state.mx51DeviceApiKey = options.mx51DeviceApiKey);
39
+ };
40
+ const setEnvironment = (env) => environment.value = env;
41
+ const checkPluginInitialized = () => {
42
+ if (isPluginInitialized.value) return true;
43
+ throw new Error("[Vue Payment Gateway] Plugin is not initialized.");
44
+ };
3
45
  const mdiBarcode = "M2,6H4V18H2V6M5,6H6V18H5V6M7,6H10V18H7V6M11,6H12V18H11V6M14,6H16V18H14V6M17,6H20V18H17V6M21,6H22V18H21V6Z";
4
46
  const mdiCheckCircle = "M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41 10.59L10 14.17L17.59 6.58L19 8L10 17Z";
5
47
  const mdiChevronLeft = "M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z";
@@ -73,10 +115,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
73
115
  }
74
116
  });
75
117
  export {
118
+ PaymentGateways as P,
76
119
  _sfc_main as _,
77
- mdiRefresh as a,
78
- mdiChevronLeft as b,
79
- mdiLink as c,
80
- mdiBarcode as d,
81
- mdiCheckCircle as m
120
+ setEnvironment as a,
121
+ state as b,
122
+ mdiRefresh as c,
123
+ mdiChevronLeft as d,
124
+ environment as e,
125
+ mdiLink as f,
126
+ checkPluginInitialized as g,
127
+ mdiBarcode as h,
128
+ isPluginInitialized as i,
129
+ mdiCheckCircle as m,
130
+ setState as s
82
131
  };
@@ -7,8 +7,7 @@ import { i as isNetworkError, a as isServerError, d as delay, g as generateTrans
7
7
  import axios, { isAxiosError, HttpStatusCode } from "axios";
8
8
  import { v7 } from "uuid";
9
9
  import { R as ReceiptAutoPrint, T as TransactionTypes, d as dialogDefaultOpts, C as CurrencyCodes, a as ResponseCodes, u as updateDialog, b as TransactionOutcome } from "./utils-Bp5B61Zb.js";
10
- import { e as environment, s as state } from "./state-Bwi0Em_K.js";
11
- import { m as mdiCheckCircle, b as mdiChevronLeft, a as mdiRefresh, _ as _sfc_main$2, c as mdiLink } from "./PairInstructions.vue_vue_type_script_setup_true_lang-CLCmTRYn.js";
10
+ import { e as environment, b as state, m as mdiCheckCircle, d as mdiChevronLeft, c as mdiRefresh, _ as _sfc_main$2, f as mdiLink } from "./PairInstructions.vue_vue_type_script_setup_true_lang-BkPzOduD.js";
12
11
  import { useLocalStorage } from "@vueuse/core";
13
12
  const LINKLY_CONSTANTS = {
14
13
  PATHS: {
@@ -1,10 +1,128 @@
1
1
  import { defineComponent, ref, computed, onMounted, watch, resolveDirective, createElementBlock, openBlock, createBlock, unref, withCtx, createElementVNode, createVNode, createCommentVNode, toDisplayString, withDirectives } from "vue";
2
2
  import { QCard, QForm, QSelect, QInput, QIcon, QBtn, QDialog, QCardSection, Dialog } from "quasar";
3
- import { l as log, s as spi, g as getPairingData, a as getTenants } from "./event-CqCgKhQE.js";
3
+ import { Spi, TransactionOptions, SuccessState, TransactionType, SpiStatus } from "@mx51/spi-client-js";
4
4
  import { useEventListener } from "@vueuse/core";
5
- import { SpiStatus } from "@mx51/spi-client-js";
6
- import { s as state } from "./state-Bwi0Em_K.js";
7
- import { _ as _sfc_main$1 } from "./PairInstructions.vue_vue_type_script_setup_true_lang-CLCmTRYn.js";
5
+ import { b as state, _ as _sfc_main$1 } from "./PairInstructions.vue_vue_type_script_setup_true_lang-BkPzOduD.js";
6
+ const spiSettings = {
7
+ secureWebSockets: true,
8
+ // checks for HTTPs
9
+ printMerchantCopyOnEftpos: false,
10
+ // prints merchant receipt from terminal instead of POS
11
+ promptForCustomerCopyOnEftpos: false,
12
+ // prints customer receipt from terminal instead of POS
13
+ signatureFlowOnEftpos: false
14
+ // signature flow and receipts on terminal instead of POS
15
+ };
16
+ const getTenants = async (vendorId, deviceApiKey) => {
17
+ try {
18
+ const res = await Spi.GetAvailableTenants(vendorId, deviceApiKey, "AU");
19
+ return res.Data;
20
+ } catch (error) {
21
+ console.warn(error);
22
+ return [];
23
+ }
24
+ };
25
+ const getPairingData = () => {
26
+ try {
27
+ return JSON.parse(localStorage.getItem("pairingData") ?? "{}");
28
+ } catch (error) {
29
+ return {};
30
+ }
31
+ };
32
+ const getSecrets = () => {
33
+ try {
34
+ const secrets = localStorage.getItem("secrets");
35
+ return secrets ? JSON.parse(secrets) : null;
36
+ } catch (error) {
37
+ return null;
38
+ }
39
+ };
40
+ const pairingData = getPairingData();
41
+ const spi = new Spi(
42
+ pairingData.posId ?? "",
43
+ pairingData.serialNumber ?? "",
44
+ localStorage.getItem("eftposAddress") ?? "",
45
+ getSecrets()
46
+ );
47
+ spi.SetTenantCode(pairingData.tenantCode ?? "gko");
48
+ spi.SetSecureWebSockets(spiSettings.secureWebSockets);
49
+ spi.Config.PrintMerchantCopy = spiSettings.printMerchantCopyOnEftpos;
50
+ spi.Config.PromptForCustomerCopyOnEftpos = spiSettings.promptForCustomerCopyOnEftpos;
51
+ spi.Config.SignatureFlowOnEftpos = spiSettings.signatureFlowOnEftpos;
52
+ const receiptOptions = new TransactionOptions();
53
+ const spiEvents = {
54
+ spiPairingFlowStateChanged: "PairingFlowStateChanged",
55
+ spiTxFlowStateChanged: "TxFlowStateChanged"
56
+ };
57
+ function log(message, event) {
58
+ if (event) {
59
+ spi._log.info(`${message} -> `, event);
60
+ } else {
61
+ spi._log.info(message);
62
+ }
63
+ }
64
+ document.addEventListener("StatusChanged", (e) => {
65
+ log("Status changed", e.detail);
66
+ if ((e == null ? void 0 : e.detail) === "PairedConnected") ;
67
+ });
68
+ document.addEventListener("SecretsChanged", (e) => {
69
+ log("Secrets changed", e);
70
+ if (e == null ? void 0 : e.detail) {
71
+ window.localStorage.setItem("secrets", JSON.stringify(e.detail));
72
+ }
73
+ });
74
+ document.addEventListener(spiEvents.spiPairingFlowStateChanged, (e) => {
75
+ var _a, _b, _c, _d, _e, _f, _g;
76
+ log("Pairing flow state changed", e);
77
+ log(
78
+ ((_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.AwaitingCheckFromEftpos) && ((_b = e == null ? void 0 : e.detail) == null ? void 0 : _b.AwaitingCheckFromPos) ? `${(_c = e == null ? void 0 : e.detail) == null ? void 0 : _c.Message}: ${(_d = e == null ? void 0 : e.detail) == null ? void 0 : _d.ConfirmationCode}` : (_e = e == null ? void 0 : e.detail) == null ? void 0 : _e.Message
79
+ );
80
+ if (((_f = e == null ? void 0 : e.detail) == null ? void 0 : _f.Successful) && ((_g = e == null ? void 0 : e.detail) == null ? void 0 : _g.Finished)) {
81
+ spi.AckFlowEndedAndBackToIdle();
82
+ }
83
+ });
84
+ document.addEventListener(spiEvents.spiTxFlowStateChanged, (e) => {
85
+ log("Transaction flow state changed", e);
86
+ if (e.detail.AwaitingSignatureCheck) ;
87
+ else if (e.detail.AwaitingPhoneForAuth) ;
88
+ else if (e.detail.Finished) {
89
+ switch (e.detail.Success) {
90
+ case SuccessState.Success:
91
+ switch (e.detail.Type) {
92
+ case TransactionType.Purchase:
93
+ break;
94
+ case TransactionType.Refund:
95
+ break;
96
+ }
97
+ break;
98
+ case SuccessState.Failed:
99
+ break;
100
+ case SuccessState.Unknown:
101
+ break;
102
+ }
103
+ }
104
+ });
105
+ document.addEventListener("DeviceAddressChanged", (e) => {
106
+ log("Device address changed", e);
107
+ if (e == null ? void 0 : e.detail.ip) {
108
+ window.localStorage.setItem("eftposAddress", e.detail.ip);
109
+ } else if (e == null ? void 0 : e.detail.fqdn) {
110
+ window.localStorage.setItem("eftposAddress", e.detail.fqdn);
111
+ }
112
+ });
113
+ spi.TerminalConfigurationResponse = (e) => {
114
+ log("Terminal configuration response", e);
115
+ spi.GetTerminalStatus();
116
+ };
117
+ spi.TerminalStatusResponse = (e) => {
118
+ log("Terminal status response", e);
119
+ };
120
+ spi.TransactionUpdateMessage = (e) => {
121
+ log("Transaction update", e);
122
+ };
123
+ spi.BatteryLevelChanged = (e) => {
124
+ log("Battery level changed", e);
125
+ };
8
126
  async function pair(pairingInput) {
9
127
  spi.SetTenantCode(pairingInput.tenantCode);
10
128
  spi.SetEftposAddress(pairingInput.eftposAddress);
@@ -416,5 +534,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
416
534
  }
417
535
  });
418
536
  export {
419
- _sfc_main as _
537
+ _sfc_main as _,
538
+ log as l,
539
+ receiptOptions as r,
540
+ spi as s
420
541
  };
@@ -4,11 +4,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
  import { defineComponent, ref, createElementBlock, unref, openBlock, createElementVNode, createVNode, createTextVNode, toDisplayString, createBlock, withModifiers } from "vue";
5
5
  import { useLocalStorage } from "@vueuse/core";
6
6
  import { Dialog, QIcon, QBtn, QInput } from "quasar";
7
- import { m as mdiCheckCircle, a as mdiRefresh, _ as _sfc_main$1, b as mdiChevronLeft, c as mdiLink } from "./PairInstructions.vue_vue_type_script_setup_true_lang-CLCmTRYn.js";
7
+ import { b as state, e as environment, m as mdiCheckCircle, c as mdiRefresh, _ as _sfc_main$1, d as mdiChevronLeft, f as mdiLink } from "./PairInstructions.vue_vue_type_script_setup_true_lang-BkPzOduD.js";
8
8
  import axios, { HttpStatusCode, isAxiosError } from "axios";
9
9
  import { d as delay } from "./index-e4lpzJsL.js";
10
10
  import { d as dialogDefaultOpts } from "./utils-Bp5B61Zb.js";
11
- import { s as state, e as environment } from "./state-Bwi0Em_K.js";
12
11
  var TransactionOutcome = /* @__PURE__ */ ((TransactionOutcome2) => {
13
12
  TransactionOutcome2[TransactionOutcome2["Accepted"] = 1] = "Accepted";
14
13
  TransactionOutcome2[TransactionOutcome2["Declined"] = 2] = "Declined";
@@ -4,12 +4,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
  import { defineComponent, resolveDirective, createBlock, openBlock, unref, withCtx, createVNode, createCommentVNode, createElementVNode, toDisplayString, withDirectives, useModel, ref, renderSlot, createTextVNode, onMounted, createElementBlock } from "vue";
5
5
  import { useLocalStorage } from "@vueuse/core";
6
6
  import axios, { isAxiosError, HttpStatusCode } from "axios";
7
- import { d as dayjs } from "./dayjs.min-DGv2T_Zf.js";
7
+ import dayjs from "dayjs";
8
8
  import { useDialogPluginComponent, QDialog, QCard, QCardSection, QBtn, Loading, Dialog, QForm, QToolbar, QToolbarTitle, QIcon, QInput, QCardActions, Notify, QSelect } from "quasar";
9
9
  import { d as delay } from "./index-e4lpzJsL.js";
10
- import { s as state } from "./state-Bwi0Em_K.js";
10
+ import { b as state, m as mdiCheckCircle, d as mdiChevronLeft, c as mdiRefresh, _ as _sfc_main$3, f as mdiLink } from "./PairInstructions.vue_vue_type_script_setup_true_lang-BkPzOduD.js";
11
11
  import { validate } from "uuid";
12
- import { m as mdiCheckCircle, b as mdiChevronLeft, a as mdiRefresh, _ as _sfc_main$3, c as mdiLink } from "./PairInstructions.vue_vue_type_script_setup_true_lang-CLCmTRYn.js";
13
12
  var SettlementTypes = /* @__PURE__ */ ((SettlementTypes2) => {
14
13
  SettlementTypes2["SETTLEMENT"] = "SETTLEMENT";
15
14
  SettlementTypes2["PRE_SETTLEMENT"] = "PRE_SETTLEMENT";
@@ -1,9 +1,7 @@
1
1
  import { defineComponent, useModel, resolveDirective, createBlock, openBlock, unref, withCtx, createVNode, createElementVNode, withDirectives, createTextVNode, ref, createElementBlock, toDisplayString, withModifiers } from "vue";
2
2
  import { useLocalStorage } from "@vueuse/core";
3
3
  import { QSpinnerHourglass, Dialog, QDialog, QCard, QToolbar, QToolbarTitle, QIcon, QBtn, QInput } from "quasar";
4
- import { c as checkPluginInitialized, e as environment, s as state } from "./state-Bwi0Em_K.js";
5
- import { T as TYRO_CONSTANTS } from "./tyro.enums-OZuKaM2C.js";
6
- import { m as mdiCheckCircle, a as mdiRefresh, _ as _sfc_main$2, d as mdiBarcode, b as mdiChevronLeft, c as mdiLink } from "./PairInstructions.vue_vue_type_script_setup_true_lang-CLCmTRYn.js";
4
+ import { g as checkPluginInitialized, e as environment, b as state, m as mdiCheckCircle, c as mdiRefresh, _ as _sfc_main$2, h as mdiBarcode, d as mdiChevronLeft, f as mdiLink } from "./PairInstructions.vue_vue_type_script_setup_true_lang-BkPzOduD.js";
7
5
  const dialogDefaultOpts = {
8
6
  message: "Pairing in progress...",
9
7
  class: "text-lg",
@@ -44,6 +42,28 @@ const responseReceivedCallbackImp = (dialog, response) => {
44
42
  message: `<div class="text-gray-800 text-base">${response.message}</div>`
45
43
  });
46
44
  };
45
+ const TYRO_CONSTANTS = {
46
+ URLS: {
47
+ DEVELOPMENT: {
48
+ SDK_URL: "https://iclientsimulator.test.tyro.com/iclient-with-ui-v1.js",
49
+ IFRAME_URL: "https://iclientsimulator.test.tyro.com/logs.html#"
50
+ },
51
+ PRODUCTION: {
52
+ SDK_URL: "https://iclient.tyro.com/iclient-with-ui-v1.js",
53
+ IFRAME_URL: "https://iclient.tyro.com/logs.html#"
54
+ }
55
+ }
56
+ };
57
+ var TyroTransactionStatus = /* @__PURE__ */ ((TyroTransactionStatus2) => {
58
+ TyroTransactionStatus2["APPROVED"] = "APPROVED";
59
+ TyroTransactionStatus2["CANCELLED"] = "CANCELLED";
60
+ TyroTransactionStatus2["REVERSED"] = "REVERSED";
61
+ TyroTransactionStatus2["DECLINED"] = "DECLINED";
62
+ TyroTransactionStatus2["NOT_STARTED"] = "NOT STARTED";
63
+ TyroTransactionStatus2["SYSTEM_ERROR"] = "SYSTEM ERROR";
64
+ TyroTransactionStatus2["UNKNOWN"] = "UNKNOWN";
65
+ return TyroTransactionStatus2;
66
+ })(TyroTransactionStatus || {});
47
67
  const useTyro = () => {
48
68
  checkPluginInitialized();
49
69
  const { IFRAME_URL } = environment.value === "production" ? TYRO_CONSTANTS.URLS.PRODUCTION : TYRO_CONSTANTS.URLS.DEVELOPMENT;
@@ -298,7 +318,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
298
318
  }
299
319
  });
300
320
  export {
321
+ TYRO_CONSTANTS as T,
301
322
  _sfc_main as _,
302
323
  _sfc_main$1 as a,
324
+ TyroTransactionStatus as b,
303
325
  useTyro as u
304
326
  };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ declare const _default: {
5
5
  };
6
6
  export default _default;
7
7
 
8
+ declare type Environment = "development" | "production";
9
+
8
10
  /**
9
11
  * Generates a numeric transaction ID with a maximum length of 16 characters.
10
12
  * The ID is composed of the current timestamp and a 4-digit random component.
@@ -18,7 +20,7 @@ export default _default;
18
20
  export declare const generateTransactionId: () => string;
19
21
 
20
22
  declare interface InstallOptions extends POSConfig {
21
- environment?: "development" | "production";
23
+ environment?: Environment;
22
24
  /**
23
25
  *
24
26
  * @param receipt - receipt string
@@ -52,6 +54,6 @@ export { }
52
54
 
53
55
  declare module "vue" {
54
56
  interface GlobalComponents {
55
- PairingInterface: (typeof import("./PairingInterface.vue"))["default"];
57
+ PairingInterface: typeof PairingInterface;
56
58
  }
57
59
  }
package/dist/index.js CHANGED
@@ -1,12 +1,17 @@
1
- import { defineAsyncComponent } from "vue";
2
- import { a as setState, b as setEnvironment, i as isPluginInitialized } from "./state-Bwi0Em_K.js";
1
+ import { P as PaymentGateways, i as isPluginInitialized, s as setState, a as setEnvironment } from "./PairInstructions.vue_vue_type_script_setup_true_lang-BkPzOduD.js";
3
2
  import "quasar";
4
- import { T as TYRO_CONSTANTS } from "./tyro.enums-OZuKaM2C.js";
3
+ import { _ as _sfc_main$1, T as TYRO_CONSTANTS } from "./PairTyro.vue_vue_type_script_setup_true_lang-JrzRlXk_.js";
4
+ import { defineComponent, createElementBlock, openBlock, createBlock, createCommentVNode, unref } from "vue";
5
5
  import { useEventListener, useScriptTag } from "@vueuse/core";
6
- import { s as spi } from "./event-CqCgKhQE.js";
6
+ import { _ as _sfc_main$2, s as spi } from "./PairMX51.vue_vue_type_script_setup_true_lang-4wjsUvaJ.js";
7
7
  import "@mx51/spi-client-js";
8
8
  import "uuid";
9
- import { TimApiEvents, timApi } from "./worldline.js";
9
+ import { PairTimapi as _sfc_main$4, TimApiEvents, timApi } from "./worldline.js";
10
+ import "axios";
11
+ import { _ as _sfc_main$3 } from "./PairLinkly.vue_vue_type_script_setup_true_lang-DM33Q34t.js";
12
+ import { _ as _sfc_main$6 } from "./PairSmartPay.vue_vue_type_script_setup_true_lang-CLQRpw0i.js";
13
+ import "dayjs";
14
+ import { _ as _sfc_main$5 } from "./PairTillPayment.vue_vue_type_script_setup_true_lang-D5zLdkh3.js";
10
15
  import { g } from "./index-e4lpzJsL.js";
11
16
  var ReceiptTypes = /* @__PURE__ */ ((ReceiptTypes2) => {
12
17
  ReceiptTypes2["MERCHANT_COPY"] = "MERCHANT_COPY";
@@ -14,65 +19,127 @@ var ReceiptTypes = /* @__PURE__ */ ((ReceiptTypes2) => {
14
19
  ReceiptTypes2["SIGNATURE_RECEIPT"] = "SIGNATURE_RECEIPT";
15
20
  return ReceiptTypes2;
16
21
  })(ReceiptTypes || {});
22
+ const _hoisted_1 = { class: "" };
23
+ const _sfc_main = /* @__PURE__ */ defineComponent({
24
+ __name: "PairingInterface",
25
+ props: {
26
+ gateway: {},
27
+ merchantId: {}
28
+ },
29
+ emits: ["pairing-success", "pairing-failure"],
30
+ setup(__props, { emit: __emit }) {
31
+ const emit = __emit;
32
+ const onPairingSuccess = (data, gateway) => {
33
+ emit("pairing-success", data, gateway);
34
+ };
35
+ return (_ctx, _cache) => {
36
+ return openBlock(), createElementBlock("div", _hoisted_1, [
37
+ _ctx.gateway === unref(PaymentGateways).Tyro ? (openBlock(), createBlock(unref(_sfc_main$1), {
38
+ key: 0,
39
+ "merchant-id": _ctx.merchantId
40
+ }, null, 8, ["merchant-id"])) : createCommentVNode("", true),
41
+ _ctx.gateway === unref(PaymentGateways).MX51 ? (openBlock(), createBlock(unref(_sfc_main$2), { key: 1 })) : createCommentVNode("", true),
42
+ _ctx.gateway === unref(PaymentGateways).Linkly ? (openBlock(), createBlock(unref(_sfc_main$3), {
43
+ key: 2,
44
+ onPairingSuccess: _cache[0] || (_cache[0] = ($event) => onPairingSuccess($event, unref(PaymentGateways).Linkly))
45
+ })) : createCommentVNode("", true),
46
+ _ctx.gateway === unref(PaymentGateways).ANZ ? (openBlock(), createBlock(_sfc_main$4, { key: 3 })) : createCommentVNode("", true),
47
+ _ctx.gateway === unref(PaymentGateways).TillPayment ? (openBlock(), createBlock(unref(_sfc_main$5), { key: 4 })) : createCommentVNode("", true),
48
+ _ctx.gateway === unref(PaymentGateways).SmartPay ? (openBlock(), createBlock(unref(_sfc_main$6), { key: 5 })) : createCommentVNode("", true)
49
+ ]);
50
+ };
51
+ }
52
+ });
17
53
  const install = (app, options) => {
18
- app.component(
19
- "PairingInterface",
20
- defineAsyncComponent(() => import("./PairingInterface-CrRaOUdg.js"))
21
- );
54
+ if (!options) {
55
+ throw new Error("Payment terminal plugin requires options");
56
+ }
57
+ app.component("PairingInterface", _sfc_main);
58
+ setupEventHandlers(options);
59
+ initializeConfigurations(options);
60
+ isPluginInitialized.value = true;
61
+ };
62
+ function setupEventHandlers(options) {
22
63
  const printEftPosReceipt = (receipt, type) => {
23
64
  if (options.onReceiptPrint) {
24
65
  options.onReceiptPrint(receipt, type);
25
66
  }
26
67
  };
27
- useEventListener(document, "TxFlowStateChanged", (e) => {
28
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
29
- if (e.detail.AwaitingSignatureCheck) {
30
- printEftPosReceipt(e.detail.SignatureRequiredMessage._receiptToSign, ReceiptTypes.SIGNATURE_RECEIPT);
31
- } else if (e.detail.Finished) {
32
- if (((_c = (_b = (_a = e.detail) == null ? void 0 : _a.Response) == null ? void 0 : _b.Data) == null ? void 0 : _c.merchant_receipt) && !((_f = (_e = (_d = e.detail) == null ? void 0 : _d.Response) == null ? void 0 : _e.Data) == null ? void 0 : _f.merchant_receipt_printed)) {
33
- printEftPosReceipt(e.detail.Response.Data.merchant_receipt, ReceiptTypes.MERCHANT_COPY);
68
+ const spiEventHandler = (e) => {
69
+ var _a;
70
+ const detail = e.detail;
71
+ if (detail.AwaitingSignatureCheck) {
72
+ printEftPosReceipt(detail.SignatureRequiredMessage._receiptToSign, ReceiptTypes.SIGNATURE_RECEIPT);
73
+ } else if (detail.Finished) {
74
+ const responseData = (_a = detail == null ? void 0 : detail.Response) == null ? void 0 : _a.Data;
75
+ if ((responseData == null ? void 0 : responseData.merchant_receipt) && !(responseData == null ? void 0 : responseData.merchant_receipt_printed)) {
76
+ printEftPosReceipt(responseData.merchant_receipt, ReceiptTypes.MERCHANT_COPY);
34
77
  }
35
- if (((_i = (_h = (_g = e.detail) == null ? void 0 : _g.Response) == null ? void 0 : _h.Data) == null ? void 0 : _i.customer_receipt) && !((_l = (_k = (_j = e.detail) == null ? void 0 : _j.Response) == null ? void 0 : _k.Data) == null ? void 0 : _l.customer_receipt_printed)) {
36
- printEftPosReceipt(e.detail.Response.Data.customer_receipt, ReceiptTypes.CUSTOMER_COPY);
78
+ if ((responseData == null ? void 0 : responseData.customer_receipt) && !(responseData == null ? void 0 : responseData.customer_receipt_printed)) {
79
+ printEftPosReceipt(responseData.customer_receipt, ReceiptTypes.CUSTOMER_COPY);
37
80
  }
38
81
  }
39
- });
40
- useEventListener(document, TimApiEvents.TxnCompleted, (ev) => {
82
+ };
83
+ const worldlineReceiptHandler = (ev) => {
41
84
  var _a;
42
85
  const { data, event } = ev.detail;
43
86
  if (event.exception) {
87
+ console.error("Worldline TimApi receipt error:", event.exception);
44
88
  return;
45
89
  }
46
90
  if (((_a = data == null ? void 0 : data.printData) == null ? void 0 : _a.receipts) && Array.isArray(data.printData.receipts)) {
47
91
  data.printData.receipts.forEach((receipt) => {
48
- const mappedData = {
49
- // @ts-expect-error - this is a workaround for the TS error
92
+ const recipientMapping = {
93
+ // @ts-expect-error - Using constants from external library
50
94
  [timapi.constants.Recipient.cardholder]: ReceiptTypes.CUSTOMER_COPY,
51
- // @ts-expect-error - this is a workaround for the TS error
95
+ // @ts-expect-error - Using constants from external library
52
96
  [timapi.constants.Recipient.merchant]: ReceiptTypes.MERCHANT_COPY
53
97
  };
54
- const receiptType = mappedData[receipt.recipient] || ReceiptTypes.CUSTOMER_COPY;
98
+ const receiptType = recipientMapping[receipt.recipient] || ReceiptTypes.CUSTOMER_COPY;
55
99
  printEftPosReceipt(receipt.value, receiptType);
56
100
  });
57
101
  }
58
- });
102
+ };
103
+ useEventListener(document, "TxFlowStateChanged", spiEventHandler);
104
+ useEventListener(document, TimApiEvents.TxnCompleted, worldlineReceiptHandler);
105
+ useEventListener(document, TimApiEvents.BalanceCompleted, worldlineReceiptHandler);
106
+ }
107
+ function initializeConfigurations(options) {
59
108
  setState(options);
60
- options.environment && setEnvironment(options.environment);
61
- const tyroConfig = options.environment === "production" ? TYRO_CONSTANTS.URLS.PRODUCTION : TYRO_CONSTANTS.URLS.DEVELOPMENT;
109
+ if (options.environment) {
110
+ setEnvironment(options.environment);
111
+ }
112
+ const tyroConfig = getTyroConfig(options.environment);
62
113
  useScriptTag(tyroConfig.SDK_URL);
63
- spi.SetPosInfo(options.productVendorName, options.productVersion);
64
- spi.SetDeviceApiKey(options.mx51DeviceApiKey);
65
- spi.Start();
66
- timApi.setInfo({
67
- posId: options.posId,
68
- posName: options.productName,
69
- posVendorName: options.productVendorName,
70
- posVersion: options.productVersion,
71
- integratorId: "3F507ED1-98C5-4CBF-A595-BFA5C34BC76C"
72
- });
73
- timApi.Start();
74
- isPluginInitialized.value = true;
75
- };
114
+ initializeSpi(options);
115
+ initializeTimApi(options);
116
+ }
117
+ function getTyroConfig(environment) {
118
+ return environment === "production" ? TYRO_CONSTANTS.URLS.PRODUCTION : TYRO_CONSTANTS.URLS.DEVELOPMENT;
119
+ }
120
+ function initializeSpi(options) {
121
+ try {
122
+ spi.SetPosInfo(options.productVendorName, options.productVersion);
123
+ spi.SetDeviceApiKey(options.mx51DeviceApiKey);
124
+ spi.Start();
125
+ } catch (error) {
126
+ console.error("Failed to initialize MX51 SPI:", error);
127
+ }
128
+ }
129
+ function initializeTimApi(options) {
130
+ try {
131
+ timApi.setInfo({
132
+ posId: options.posId,
133
+ posName: options.productName,
134
+ posVendorName: options.productVendorName,
135
+ posVersion: options.productVersion,
136
+ integratorId: "3F507ED1-98C5-4CBF-A595-BFA5C34BC76C"
137
+ });
138
+ timApi.Start();
139
+ } catch (error) {
140
+ console.error("Failed to initialize Worldline TimApi:", error);
141
+ }
142
+ }
76
143
  const VuePaymentGateway = { install };
77
144
  export {
78
145
  VuePaymentGateway as default,
package/dist/linkly.d.ts CHANGED
@@ -464,6 +464,6 @@ export { }
464
464
 
465
465
  declare module "vue" {
466
466
  interface GlobalComponents {
467
- PairingInterface: (typeof import("./PairingInterface.vue"))["default"];
467
+ PairingInterface: typeof PairingInterface;
468
468
  }
469
469
  }
package/dist/linkly.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _, u } from "./PairLinkly.vue_vue_type_script_setup_true_lang-BmGTzekg.js";
1
+ import { _, u } from "./PairLinkly.vue_vue_type_script_setup_true_lang-DM33Q34t.js";
2
2
  import { C, R, a, b, T } from "./utils-Bp5B61Zb.js";
3
3
  export {
4
4
  C as CurrencyCodes,
package/dist/mx51.d.ts CHANGED
@@ -122,6 +122,6 @@ export { }
122
122
 
123
123
  declare module "vue" {
124
124
  interface GlobalComponents {
125
- PairingInterface: (typeof import("./PairingInterface.vue"))["default"];
125
+ PairingInterface: typeof PairingInterface;
126
126
  }
127
127
  }
package/dist/mx51.js CHANGED
@@ -1,6 +1,5 @@
1
- import { s as spi, r as receiptOptions } from "./event-CqCgKhQE.js";
2
- import { l } from "./event-CqCgKhQE.js";
3
- import { _ } from "./PairMX51.vue_vue_type_script_setup_true_lang-HNeIHZA_.js";
1
+ import { s as spi, r as receiptOptions } from "./PairMX51.vue_vue_type_script_setup_true_lang-4wjsUvaJ.js";
2
+ import { _, l } from "./PairMX51.vue_vue_type_script_setup_true_lang-4wjsUvaJ.js";
4
3
  import { defineComponent, ref, onMounted, resolveDirective, createBlock, openBlock, unref, withCtx, createVNode, createCommentVNode, createElementVNode, toDisplayString, withDirectives } from "vue";
5
4
  import { SuccessState, TransactionType } from "@mx51/spi-client-js";
6
5
  import { v4 } from "uuid";
@@ -159,6 +159,6 @@ export { }
159
159
 
160
160
  declare module "vue" {
161
161
  interface GlobalComponents {
162
- PairingInterface: (typeof import("./PairingInterface.vue"))["default"];
162
+ PairingInterface: typeof PairingInterface;
163
163
  }
164
164
  }
package/dist/smartpay.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, P, _, R, S, T, b, a, c, u } from "./PairSmartPay.vue_vue_type_script_setup_true_lang-BD4TrPcQ.js";
1
+ import { D, P, _, R, S, T, b, a, c, u } from "./PairSmartPay.vue_vue_type_script_setup_true_lang-CLQRpw0i.js";
2
2
  export {
3
3
  D as DEV_SMARTPAY_API_URL,
4
4
  P as PROD_SMARTPAY_API_URL,
@@ -359,6 +359,6 @@ export { }
359
359
 
360
360
  declare module "vue" {
361
361
  interface GlobalComponents {
362
- PairingInterface: (typeof import("./PairingInterface.vue"))["default"];
362
+ PairingInterface: typeof PairingInterface;
363
363
  }
364
364
  }
@@ -1,4 +1,4 @@
1
- import { _, S, T, b, a, u } from "./PairTillPayment.vue_vue_type_script_setup_true_lang-oQDsDv8x.js";
1
+ import { _, S, T, b, a, u } from "./PairTillPayment.vue_vue_type_script_setup_true_lang-D5zLdkh3.js";
2
2
  export {
3
3
  _ as PairTillPayment,
4
4
  S as SettlementTypes,
package/dist/tyro.d.ts CHANGED
@@ -176,6 +176,6 @@ export { }
176
176
 
177
177
  declare module "vue" {
178
178
  interface GlobalComponents {
179
- PairingInterface: (typeof import("./PairingInterface.vue"))["default"];
179
+ PairingInterface: typeof PairingInterface;
180
180
  }
181
181
  }
package/dist/tyro.js CHANGED
@@ -1,9 +1,8 @@
1
- import { a, _, u } from "./PairTyro.vue_vue_type_script_setup_true_lang-BCSY7FFj.js";
2
- import { T, a as a2 } from "./tyro.enums-OZuKaM2C.js";
1
+ import { a, _, T, b, u } from "./PairTyro.vue_vue_type_script_setup_true_lang-JrzRlXk_.js";
3
2
  export {
4
3
  a as ClientLogsDialog,
5
4
  _ as PairTyro,
6
5
  T as TYRO_CONSTANTS,
7
- a2 as TyroTransactionStatus,
6
+ b as TyroTransactionStatus,
8
7
  u as useTyro
9
8
  };
@@ -95,6 +95,6 @@ export { }
95
95
 
96
96
  declare module "vue" {
97
97
  interface GlobalComponents {
98
- PairingInterface: (typeof import("./PairingInterface.vue"))["default"];
98
+ PairingInterface: typeof PairingInterface;
99
99
  }
100
100
  }