@achyutlabsau/vue-payment-gateway 0.2.4 → 0.2.5

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 CHANGED
@@ -1,141 +1,141 @@
1
- # Vue Payment Gateway
2
-
3
- A Vue.js payment gateway library to handle payments with ease.
4
-
5
- ## Installation
6
-
7
- To install the library, run the following command:
8
-
9
- ```bash
10
- npm install @achyutlabsau/vue-payment-gateway
11
- ```
12
-
13
- ## Plugin Initialization
14
-
15
- To use the payment gateway, you need to initialize the plugin in your Vue app. Here’s an example of how to set it up:
16
-
17
- ```javascript
18
- import VuePaymentGateway from "@achyutlabsau/vue-payment-gateway";
19
-
20
- app.use(VuePaymentGateway, {
21
- productName: "Pratham Respos", // Name of your product
22
- productVersion: "3.3.0", // Version of your product
23
- productVendorName: "Achyutlabs", // Name of the product vendor
24
- posId: "unique-pos-id", // Unique identifier for the POS system
25
- posRegisterId: "pos-register-id", // Unique identifier for the POS register
26
- posRegisterName: "register-name", // Name of the POS register
27
- posBusinessName: "business name", // Name of the business using the POS system
28
- tyroApiKey: "tyro-api-key", // API key for Tyro integration
29
- environment: "development", // Set environment to 'development' or 'production'
30
- });
31
- ```
32
-
33
- > **Note:** Replace the placeholder values with the actual details of your POS system, product, and Tyro API key.
34
-
35
- ## Using the Payment Gateway
36
-
37
- This library supports multiple payment providers, such as Tyro, SmartPay, and Linkly. Here’s how to use them in your application.
38
-
39
- ### Using Tyro
40
-
41
- To use the Tyro payment gateway, import and initialize it as shown below:
42
-
43
- ```javascript
44
- import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
45
-
46
- const tyro = useTyro();
47
-
48
- // Example usage
49
- await tyro.processPayment(amount, options);
50
- ```
51
-
52
- ### Using SmartPay
53
-
54
- To use the SmartPay payment gateway, import and initialize it as shown below:
55
-
56
- ```javascript
57
- import { useSmartPay } from "@achyutlabsau/vue-payment-gateway/smartpay";
58
-
59
- const smartPay = useSmartPay();
60
-
61
- // Example usage
62
- await smartPay.processPayment(amount, options);
63
- ```
64
-
65
- ### Using Linkly
66
-
67
- To use the Linkly payment gateway, import and initialize it as shown below:
68
-
69
- ```javascript
70
- import { useLinkly } from "@achyutlabsau/vue-payment-gateway/linkly";
71
-
72
- const linkly = useLinkly();
73
-
74
- // Example usage
75
- await linkly.processPayment(amount, options);
76
- ```
77
-
78
- ## Payment Method API
79
-
80
- Each payment provider (Tyro, SmartPay, Linkly) provides methods to process payments. Here are some of the most commonly used methods:
81
-
82
- ### `processPayment(amount: number, options?: object)`
83
-
84
- Processes a payment for the specified amount.
85
-
86
- **Parameters:**
87
-
88
- - `amount`: The amount to be charged.
89
- - `options`: (Optional) Additional options for the payment.
90
-
91
- ### `cancelPayment()`
92
-
93
- Cancels an ongoing payment.
94
-
95
- ### `getStatus()`
96
-
97
- Gets the status of the current payment transaction.
98
-
99
- > **Note:** The methods may differ slightly between Tyro, SmartPay, and Linkly. Refer to the official documentation of each payment provider for more details.
100
-
101
- ## Environment Configuration
102
-
103
- The environment can be set to either `development` or `production`. Make sure to use `development` during testing and switch to `production` in a live environment to ensure security and proper tracking.
104
-
105
- ```javascript
106
- app.use(VuePaymentGateway, {
107
- ...
108
- environment: "production", // Set to 'production' in a live environment
109
- });
110
- ```
111
-
112
- ## Example Usage
113
-
114
- Here’s a complete example of how you might use the payment gateway to process a payment with Tyro:
115
-
116
- ```javascript
117
- import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
118
-
119
- const tyro = useTyro();
120
-
121
- async function handlePayment() {
122
- try {
123
- const paymentResult = await tyro.processPayment(100, { currency: "USD" });
124
- console.log("Payment successful:", paymentResult);
125
- } catch (error) {
126
- console.error("Payment failed:", error);
127
- }
128
- }
129
- ```
130
-
131
- ## Troubleshooting
132
-
133
- - **Environment Issues**: Make sure `environment` is set correctly (`development` or `production`).
134
- - **Invalid API Key**: Ensure the Tyro API key is valid and correctly set in the configuration.
135
- - **Payment Processing Issues**: Check if the payment provider's service is online and available.
136
-
137
- ## Additional Resources
138
-
139
- For more details and usage examples, refer to the official documentation or support channels provided by [Achyutlabs](https://achyutlabs.com/).
140
-
141
- With this guide, you should be able to set up and use the Vue Payment Gateway efficiently to handle payments with Tyro, SmartPay, and Linkly integrations.
1
+ # Vue Payment Gateway
2
+
3
+ A Vue.js payment gateway library to handle payments with ease.
4
+
5
+ ## Installation
6
+
7
+ To install the library, run the following command:
8
+
9
+ ```bash
10
+ npm install @achyutlabsau/vue-payment-gateway
11
+ ```
12
+
13
+ ## Plugin Initialization
14
+
15
+ To use the payment gateway, you need to initialize the plugin in your Vue app. Here’s an example of how to set it up:
16
+
17
+ ```javascript
18
+ import VuePaymentGateway from "@achyutlabsau/vue-payment-gateway";
19
+
20
+ app.use(VuePaymentGateway, {
21
+ productName: "Pratham Respos", // Name of your product
22
+ productVersion: "3.3.0", // Version of your product
23
+ productVendorName: "Achyutlabs", // Name of the product vendor
24
+ posId: "unique-pos-id", // Unique identifier for the POS system
25
+ posRegisterId: "pos-register-id", // Unique identifier for the POS register
26
+ posRegisterName: "register-name", // Name of the POS register
27
+ posBusinessName: "business name", // Name of the business using the POS system
28
+ tyroApiKey: "tyro-api-key", // API key for Tyro integration
29
+ environment: "development", // Set environment to 'development' or 'production'
30
+ });
31
+ ```
32
+
33
+ > **Note:** Replace the placeholder values with the actual details of your POS system, product, and Tyro API key.
34
+
35
+ ## Using the Payment Gateway
36
+
37
+ This library supports multiple payment providers, such as Tyro, SmartPay, and Linkly. Here’s how to use them in your application.
38
+
39
+ ### Using Tyro
40
+
41
+ To use the Tyro payment gateway, import and initialize it as shown below:
42
+
43
+ ```javascript
44
+ import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
45
+
46
+ const tyro = useTyro();
47
+
48
+ // Example usage
49
+ await tyro.processPayment(amount, options);
50
+ ```
51
+
52
+ ### Using SmartPay
53
+
54
+ To use the SmartPay payment gateway, import and initialize it as shown below:
55
+
56
+ ```javascript
57
+ import { useSmartPay } from "@achyutlabsau/vue-payment-gateway/smartpay";
58
+
59
+ const smartPay = useSmartPay();
60
+
61
+ // Example usage
62
+ await smartPay.processPayment(amount, options);
63
+ ```
64
+
65
+ ### Using Linkly
66
+
67
+ To use the Linkly payment gateway, import and initialize it as shown below:
68
+
69
+ ```javascript
70
+ import { useLinkly } from "@achyutlabsau/vue-payment-gateway/linkly";
71
+
72
+ const linkly = useLinkly();
73
+
74
+ // Example usage
75
+ await linkly.processPayment(amount, options);
76
+ ```
77
+
78
+ ## Payment Method API
79
+
80
+ Each payment provider (Tyro, SmartPay, Linkly) provides methods to process payments. Here are some of the most commonly used methods:
81
+
82
+ ### `processPayment(amount: number, options?: object)`
83
+
84
+ Processes a payment for the specified amount.
85
+
86
+ **Parameters:**
87
+
88
+ - `amount`: The amount to be charged.
89
+ - `options`: (Optional) Additional options for the payment.
90
+
91
+ ### `cancelPayment()`
92
+
93
+ Cancels an ongoing payment.
94
+
95
+ ### `getStatus()`
96
+
97
+ Gets the status of the current payment transaction.
98
+
99
+ > **Note:** The methods may differ slightly between Tyro, SmartPay, and Linkly. Refer to the official documentation of each payment provider for more details.
100
+
101
+ ## Environment Configuration
102
+
103
+ The environment can be set to either `development` or `production`. Make sure to use `development` during testing and switch to `production` in a live environment to ensure security and proper tracking.
104
+
105
+ ```javascript
106
+ app.use(VuePaymentGateway, {
107
+ ...
108
+ environment: "production", // Set to 'production' in a live environment
109
+ });
110
+ ```
111
+
112
+ ## Example Usage
113
+
114
+ Here’s a complete example of how you might use the payment gateway to process a payment with Tyro:
115
+
116
+ ```javascript
117
+ import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
118
+
119
+ const tyro = useTyro();
120
+
121
+ async function handlePayment() {
122
+ try {
123
+ const paymentResult = await tyro.processPayment(100, { currency: "USD" });
124
+ console.log("Payment successful:", paymentResult);
125
+ } catch (error) {
126
+ console.error("Payment failed:", error);
127
+ }
128
+ }
129
+ ```
130
+
131
+ ## Troubleshooting
132
+
133
+ - **Environment Issues**: Make sure `environment` is set correctly (`development` or `production`).
134
+ - **Invalid API Key**: Ensure the Tyro API key is valid and correctly set in the configuration.
135
+ - **Payment Processing Issues**: Check if the payment provider's service is online and available.
136
+
137
+ ## Additional Resources
138
+
139
+ For more details and usage examples, refer to the official documentation or support channels provided by [Achyutlabs](https://achyutlabs.com/).
140
+
141
+ With this guide, you should be able to set up and use the Vue Payment Gateway efficiently to handle payments with Tyro, SmartPay, and Linkly integrations.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { FunctionPlugin } from 'vue';
1
+ import { App } from 'vue';
2
2
 
3
3
  declare const _default: {
4
- install: FunctionPlugin<InstallOptions>;
4
+ install: (_app: App, options: InstallOptions) => void;
5
5
  };
6
6
  export default _default;
7
7
 
@@ -32,7 +32,6 @@ declare interface POSConfig {
32
32
  tyroApiKey: string;
33
33
  tillPaymentApiKey: string;
34
34
  tillPaymentMerchantId: string;
35
- mx51DeviceApiKey: string;
36
35
  }
37
36
 
38
37
  export { }
package/dist/index.js CHANGED
@@ -1,20 +1,13 @@
1
- import { s as setState, a as setEnvironment, i as isPluginInitialized } from "./state-D014QcxX.js";
1
+ import { s as setState, a as setEnvironment, i as isPluginInitialized } from "./state-DdRk6ppP.js";
2
2
  import "quasar";
3
3
  import { T as TYRO_CONSTANTS } from "./tyro.enums-OZuKaM2C.js";
4
4
  import { useScriptTag } from "@vueuse/core";
5
- import { s as spi } from "./event-Zm-ArxiV.js";
6
- import "vue";
7
- import "@mx51/spi-client-js";
8
- import "uuid";
9
5
  import { g } from "./index-C8vc_75e.js";
10
6
  const install = (_app, options) => {
11
7
  setState(options);
12
8
  options.environment && setEnvironment(options.environment);
13
9
  const tyroConfig = options.environment === "production" ? TYRO_CONSTANTS.URLS.PRODUCTION : TYRO_CONSTANTS.URLS.DEVELOPMENT;
14
10
  useScriptTag(tyroConfig.SDK_URL);
15
- spi.SetPosInfo(options.productVendorName, options.productVersion);
16
- spi.SetDeviceApiKey(options.mx51DeviceApiKey);
17
- spi.Start();
18
11
  isPluginInitialized.value = true;
19
12
  };
20
13
  const VuePaymentGateway = { install };
package/dist/linkly.js CHANGED
@@ -6,7 +6,7 @@ import { i as isNetworkError, a as isServerError, t as timeout, g as generateTra
6
6
  import axios, { isAxiosError, HttpStatusCode } from "axios";
7
7
  import { v7 } from "uuid";
8
8
  import { d as dialogDefaultOpts, T as TransactionTypes, R as ReceiptAutoPrint, C as CurrencyCodes, a as ResponseCodes, u as updateDialog, b as TransactionOutcome } from "./utils-DcpEg5Bx.js";
9
- import { b as state, e as environment } from "./state-D014QcxX.js";
9
+ import { b as state, e as environment } from "./state-DdRk6ppP.js";
10
10
  const LINKLY_CONSTANTS = {
11
11
  PATHS: {
12
12
  TRANSACTION: "transaction",
package/dist/mx51.d.ts CHANGED
@@ -4,13 +4,6 @@ import { DefineComponent } from 'vue';
4
4
  import { PublicProps } from 'vue';
5
5
  import { Spi } from '@mx51/spi-client-js';
6
6
 
7
- /**
8
- * Let the Eftpos terminal know whether merchant accepted or declined the signature
9
- *
10
- * @param accepted - whether merchant accepted the signature from customer or not
11
- **/
12
- export declare function acceptSignature(signatureConfirmed: boolean): void;
13
-
14
7
  /**
15
8
  * Attempts to cancel a transaction
16
9
  * Be subscribed to TxFlowStateChanged event to see how it goes
@@ -37,7 +30,7 @@ export declare const PairMX51: DefineComponent< {}, {}, {}, {}, {}, Component
37
30
  * Be subscribed to TxFlowStateChanged event to get updates on the process
38
31
  * Tip and cashout are not allowed simultaneously
39
32
  **/
40
- export declare function purchase({ purchaseAmount, tipAmount, cashoutAmount, promptForCashout, surchargeAmount }: PurchaseOptions): void;
33
+ export declare function purchase({ purchaseAmount, tipAmount, cashoutAmount, promptForCashout, surchargeAmount, }: PurchaseOptions): void;
41
34
 
42
35
  declare interface PurchaseOptions {
43
36
  /**
@@ -102,12 +95,8 @@ export declare function settlementEnquiry(): void;
102
95
  export declare const spi: Spi;
103
96
 
104
97
  export declare const TransactionDialog: DefineComponent< {}, {
105
- showDialog: (amount: number, type?: string) => void;
106
- }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
107
- "transaction-success": (ev: true) => any;
108
- }, string, PublicProps, Readonly<{}> & Readonly<{
109
- "onTransaction-success"?: ((ev: true) => any) | undefined;
110
- }>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
98
+ showDialog: (amount: number) => void;
99
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
111
100
 
112
101
  export { }
113
102
 
package/dist/mx51.js CHANGED
@@ -1,11 +1,137 @@
1
- import { l as log, s as spi, g as getPairingData, a as getTenants, r as receiptOptions } from "./event-Zm-ArxiV.js";
1
+ import { Spi, TransactionOptions, SuccessState, TransactionType, SpiStatus } from "@mx51/spi-client-js";
2
2
  import { defineComponent, ref, computed, onMounted, resolveDirective, openBlock, createElementBlock, createVNode, unref, withCtx, createElementVNode, createCommentVNode, createBlock, toDisplayString, withDirectives } from "vue";
3
3
  import { QForm, QSelect, QInput, QCheckbox, QIcon, QBtn, QDialog, QCard, QCardSection, Dialog } from "quasar";
4
4
  import { useEventListener } from "@vueuse/core";
5
- import { SpiStatus, TransactionType, SuccessState } from "@mx51/spi-client-js";
6
- import { b as state } from "./state-D014QcxX.js";
7
5
  import { v4 } from "uuid";
6
+ const spiSettings = {
7
+ posVendorId: "Pratham Respos",
8
+ // your POS company name/id
9
+ posVersion: "3.4.0",
10
+ // your POS version
11
+ deviceApiKey: "d5blbiSBWKQU6DtoSj3KscrT1yoKuFVF",
12
+ countryCode: "AU",
13
+ // if unsure check with integration support team
14
+ secureWebSockets: window.location.protocol === "https:" ? true : false,
15
+ // checks for HTTPs
16
+ printMerchantCopyOnEftpos: false,
17
+ // prints merchant receipt from terminal instead of POS
18
+ promptForCustomerCopyOnEftpos: false,
19
+ // prints customer receipt from terminal instead of POS
20
+ signatureFlowOnEftpos: false
21
+ // signature flow and receipts on terminal instead of POS
22
+ };
23
+ const getTenants = async () => {
24
+ try {
25
+ const res = await Spi.GetAvailableTenants(
26
+ spiSettings.posVendorId,
27
+ spiSettings.deviceApiKey,
28
+ spiSettings.countryCode
29
+ );
30
+ return res.Data;
31
+ } catch (error) {
32
+ console.warn(error);
33
+ return [];
34
+ }
35
+ };
36
+ const getPairingData = () => {
37
+ try {
38
+ return JSON.parse(localStorage.getItem("pairingData") ?? "{}");
39
+ } catch (error) {
40
+ return {};
41
+ }
42
+ };
43
+ const getSecrets = () => {
44
+ try {
45
+ const secrets = localStorage.getItem("secrets");
46
+ return secrets ? JSON.parse(secrets) : null;
47
+ } catch (error) {
48
+ return null;
49
+ }
50
+ };
51
+ const pairingData = getPairingData();
52
+ const spi = new Spi(
53
+ pairingData.posId ?? "",
54
+ pairingData.serialNumber ?? "",
55
+ pairingData.eftposAddress ?? "192.168.31.246",
56
+ getSecrets()
57
+ );
58
+ spi.SetTenantCode(pairingData.tenantCode ?? "gko");
59
+ spi.SetSecureWebSockets(spiSettings.secureWebSockets);
60
+ spi.Config.PrintMerchantCopy = spiSettings.printMerchantCopyOnEftpos;
61
+ spi.Config.PromptForCustomerCopyOnEftpos = spiSettings.promptForCustomerCopyOnEftpos;
62
+ spi.Config.SignatureFlowOnEftpos = spiSettings.signatureFlowOnEftpos;
63
+ const receiptOptions = new TransactionOptions();
64
+ function log(message, event) {
65
+ if (event) {
66
+ spi._log.info(`${message} -> `, event);
67
+ } else {
68
+ spi._log.info(message);
69
+ }
70
+ }
71
+ document.addEventListener("StatusChanged", (e) => {
72
+ log("Status changed", e.detail);
73
+ if ((e == null ? void 0 : e.detail) === "PairedConnected") ;
74
+ });
75
+ document.addEventListener("SecretsChanged", (e) => {
76
+ log("Secrets changed", e);
77
+ if (e == null ? void 0 : e.detail) {
78
+ window.localStorage.setItem("secrets", JSON.stringify(e.detail));
79
+ }
80
+ });
81
+ document.addEventListener("PairingFlowStateChanged", (e) => {
82
+ var _a, _b, _c, _d, _e, _f, _g;
83
+ log("Pairing flow state changed", e);
84
+ log(
85
+ ((_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
86
+ );
87
+ 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)) {
88
+ spi.AckFlowEndedAndBackToIdle();
89
+ }
90
+ });
91
+ document.addEventListener("TxFlowStateChanged", (e) => {
92
+ log("Transaction flow state changed", e);
93
+ if (e.detail.AwaitingSignatureCheck) ;
94
+ else if (e.detail.AwaitingPhoneForAuth) ;
95
+ else if (e.detail.Finished) {
96
+ switch (e.detail.Success) {
97
+ case SuccessState.Success:
98
+ switch (e.detail.Type) {
99
+ case TransactionType.Purchase:
100
+ break;
101
+ case TransactionType.Refund:
102
+ break;
103
+ }
104
+ break;
105
+ case SuccessState.Failed:
106
+ break;
107
+ case SuccessState.Unknown:
108
+ break;
109
+ }
110
+ }
111
+ });
112
+ document.addEventListener("DeviceAddressChanged", (e) => {
113
+ log("Device address changed", e);
114
+ if (e == null ? void 0 : e.detail.ip) {
115
+ window.localStorage.setItem("eftposAddress", JSON.stringify(e.detail.ip));
116
+ } else if (e == null ? void 0 : e.detail.fqdn) {
117
+ window.localStorage.setItem("eftposAddress", JSON.stringify(e.detail.fqdn));
118
+ }
119
+ });
120
+ spi.TerminalConfigurationResponse = (e) => {
121
+ log("Terminal configuration response", e);
122
+ spi.GetTerminalStatus();
123
+ };
124
+ spi.TerminalStatusResponse = (e) => {
125
+ log("Terminal status response", e);
126
+ };
127
+ spi.TransactionUpdateMessage = (e) => {
128
+ log("Transaction update", e);
129
+ };
130
+ spi.BatteryLevelChanged = (e) => {
131
+ log("Battery level changed", e);
132
+ };
8
133
  function pair(pairingInput) {
134
+ localStorage.setItem("pairingData", JSON.stringify(pairingInput));
9
135
  spi.SetTenantCode(pairingInput.tenantCode);
10
136
  spi.SetEftposAddress(pairingInput.eftposAddress);
11
137
  spi.SetSerialNumber(pairingInput.serialNumber);
@@ -42,22 +168,19 @@ const _hoisted_5$1 = {
42
168
  key: 2,
43
169
  class: "flex items-center gap-1 font-semibold"
44
170
  };
45
- const _hoisted_6$1 = { class: "text-center font-semibold text-gray-500 uppercase" };
46
- const _hoisted_7$1 = { class: "py-3 text-center text-2xl font-semibold text-slate-700 uppercase" };
171
+ const _hoisted_6 = { class: "text-center font-semibold text-gray-500 uppercase" };
172
+ const _hoisted_7 = { class: "py-3 text-center text-2xl font-semibold text-slate-700 uppercase" };
47
173
  const _hoisted_8 = { class: "text-center font-semibold text-gray-500 uppercase" };
48
174
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
49
175
  __name: "PairMX51",
50
176
  setup(__props) {
51
- function isValidIP(str) {
52
- const octet = "(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)";
53
- const regex = new RegExp(`^${octet}\\.${octet}\\.${octet}\\.${octet}$`);
54
- return regex.test(str);
55
- }
56
177
  const tenants = ref([]);
57
178
  const model = ref(false);
58
179
  const pairStatus = ref(spi._currentStatus);
59
180
  const isPaired = computed(() => {
60
- return [SpiStatus.PairedConnected, SpiStatus.PairedConnecting].includes(pairStatus.value);
181
+ return [SpiStatus.PairedConnected, SpiStatus.PairedConnecting].includes(
182
+ pairStatus.value
183
+ );
61
184
  });
62
185
  const pairForm = ref({
63
186
  posId: "",
@@ -84,7 +207,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
84
207
  });
85
208
  };
86
209
  onMounted(async () => {
87
- const res = await getTenants(state.productVendorName, state.mx51DeviceApiKey);
210
+ const res = await getTenants();
88
211
  if (res) {
89
212
  tenants.value = res;
90
213
  }
@@ -93,23 +216,19 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
93
216
  pairStatus.value = e.detail;
94
217
  });
95
218
  useEventListener(document, "PairingFlowStateChanged", (e) => {
96
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
219
+ var _a, _b, _c, _d, _e, _f, _g;
97
220
  model.value = true;
98
221
  pairInfo.value.message = (_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.Message;
99
222
  pairInfo.value.confirmationCode = (_b = e == null ? void 0 : e.detail) == null ? void 0 : _b.ConfirmationCode;
100
- if (((_c = e == null ? void 0 : e.detail) == null ? void 0 : _c.Successful) && ((_d = e == null ? void 0 : e.detail) == null ? void 0 : _d.Finished)) {
101
- localStorage.setItem("pairingData", JSON.stringify(pairForm.value));
102
- localStorage.setItem("eftposAddress", pairForm.value.eftposAddress);
103
- }
104
- if ((_e = e == null ? void 0 : e.detail) == null ? void 0 : _e.Finished) {
223
+ if ((_c = e == null ? void 0 : e.detail) == null ? void 0 : _c.Finished) {
105
224
  pairInfo.value.state = "FINISHED";
106
225
  return;
107
226
  }
108
- if (((_f = e == null ? void 0 : e.detail) == null ? void 0 : _f.AwaitingCheckFromEftpos) && ((_g = e == null ? void 0 : e.detail) == null ? void 0 : _g.AwaitingCheckFromPos)) {
227
+ if (((_d = e == null ? void 0 : e.detail) == null ? void 0 : _d.AwaitingCheckFromEftpos) && ((_e = e == null ? void 0 : e.detail) == null ? void 0 : _e.AwaitingCheckFromPos)) {
109
228
  pairInfo.value.state = "CONFIRMATION";
110
229
  return;
111
230
  }
112
- if (!((_h = e == null ? void 0 : e.detail) == null ? void 0 : _h.AwaitingCheckFromEftpos) || !((_i = e == null ? void 0 : e.detail) == null ? void 0 : _i.AwaitingCheckFromPos)) {
231
+ if (!((_f = e == null ? void 0 : e.detail) == null ? void 0 : _f.AwaitingCheckFromEftpos) || !((_g = e == null ? void 0 : e.detail) == null ? void 0 : _g.AwaitingCheckFromPos)) {
113
232
  pairInfo.value.state = "INPROGRESS";
114
233
  return;
115
234
  }
@@ -122,7 +241,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
122
241
  class: "space-y-4"
123
242
  }, {
124
243
  default: withCtx(() => [
125
- _cache[10] || (_cache[10] = createElementVNode("div", { class: "font-sans text-lg font-semibold text-gray-600" }, "MX 51 - SPI Terminal Pairing", -1)),
244
+ _cache[11] || (_cache[11] = createElementVNode("div", { class: "font-sans text-lg font-semibold text-gray-600" }, " Mx 51 Terminal Pairing ", -1)),
126
245
  createVNode(unref(QSelect), {
127
246
  disable: isPaired.value,
128
247
  dense: "",
@@ -146,11 +265,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
146
265
  modelValue: pairForm.value.posId,
147
266
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => pairForm.value.posId = $event),
148
267
  label: "POS ID",
149
- rules: [
150
- (v) => !!v || "POS ID is required",
151
- (val) => /^[a-zA-Z0-9]+$/.test(val) || "Pos id is not valid",
152
- (val) => val && val.length <= 16 || "POS ID must be less than 16 characters"
153
- ]
268
+ rules: [(v) => !!v || "POS ID is required"]
154
269
  }, null, 8, ["disable", "modelValue", "rules"]),
155
270
  createVNode(unref(QInput), {
156
271
  disable: isPaired.value,
@@ -169,11 +284,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
169
284
  modelValue: pairForm.value.eftposAddress,
170
285
  "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => pairForm.value.eftposAddress = $event),
171
286
  label: "Eftpos Address",
172
- rules: [
173
- (v) => !!v || "Eftpos Address is required",
174
- (v) => isValidIP(v) || "The Eftpos address is not in the right format"
175
- ],
176
- hint: "Enter the Eftpos Address associated with the terminal"
287
+ rules: [(v) => !!v || "Eftpos Address is required"],
288
+ hint: "Enter the Eftpos Address associated with the merchant"
177
289
  }, null, 8, ["disable", "modelValue", "rules"]),
178
290
  createElementVNode("div", null, [
179
291
  createVNode(unref(QCheckbox), {
@@ -184,29 +296,36 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
184
296
  dense: ""
185
297
  }, null, 8, ["modelValue", "disable"])
186
298
  ]),
299
+ createVNode(unref(QCheckbox), {
300
+ disable: isPaired.value,
301
+ dense: "",
302
+ label: "Auto Address Mode",
303
+ modelValue: pairForm.value.autoAddressResolution,
304
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => pairForm.value.autoAddressResolution = $event)
305
+ }, null, 8, ["disable", "modelValue"]),
187
306
  createElementVNode("div", _hoisted_2$1, [
188
- _cache[9] || (_cache[9] = createElementVNode("div", { class: "text-sm font-medium text-gray-500" }, "Pairing Status", -1)),
307
+ _cache[10] || (_cache[10] = createElementVNode("div", { class: "text-sm font-medium text-gray-500" }, "Pairing Status", -1)),
189
308
  pairStatus.value === unref(SpiStatus).PairedConnected ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
190
309
  createVNode(unref(QIcon), {
191
310
  name: "check_circle",
192
311
  size: "xs",
193
312
  color: "green"
194
313
  }),
195
- _cache[6] || (_cache[6] = createElementVNode("div", null, "Paired and Connected", -1))
314
+ _cache[7] || (_cache[7] = createElementVNode("div", null, "Paired and Connected", -1))
196
315
  ])) : pairStatus.value === unref(SpiStatus).Unpaired ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
197
316
  createVNode(unref(QIcon), {
198
317
  name: "cancel",
199
318
  size: "xs",
200
319
  color: "red"
201
320
  }),
202
- _cache[7] || (_cache[7] = createElementVNode("div", null, "Unpaired", -1))
321
+ _cache[8] || (_cache[8] = createElementVNode("div", null, "Unpaired", -1))
203
322
  ])) : pairStatus.value === unref(SpiStatus).PairedConnecting ? (openBlock(), createElementBlock("div", _hoisted_5$1, [
204
323
  createVNode(unref(QIcon), {
205
324
  name: "check_circle",
206
325
  size: "xs",
207
326
  color: "yellow-8"
208
327
  }),
209
- _cache[8] || (_cache[8] = createElementVNode("div", null, "Paired and trying to connect", -1))
328
+ _cache[9] || (_cache[9] = createElementVNode("div", null, "Paired and trying to connect", -1))
210
329
  ])) : createCommentVNode("", true)
211
330
  ]),
212
331
  !isPaired.value ? (openBlock(), createBlock(unref(QBtn), {
@@ -235,7 +354,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
235
354
  }),
236
355
  createVNode(unref(QDialog), {
237
356
  modelValue: model.value,
238
- "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => model.value = $event),
357
+ "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => model.value = $event),
239
358
  persistent: ""
240
359
  }, {
241
360
  default: withCtx(() => [
@@ -243,7 +362,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
243
362
  default: withCtx(() => [
244
363
  pairInfo.value.state === "INPROGRESS" ? (openBlock(), createBlock(unref(QCardSection), { key: 0 }, {
245
364
  default: withCtx(() => [
246
- createElementVNode("div", _hoisted_6$1, toDisplayString(pairInfo.value.message), 1),
365
+ createElementVNode("div", _hoisted_6, toDisplayString(pairInfo.value.message), 1),
247
366
  createVNode(unref(QBtn), {
248
367
  label: "Cancel",
249
368
  onClick: unref(cancelPairing),
@@ -258,9 +377,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
258
377
  _: 1
259
378
  })) : pairInfo.value.state === "CONFIRMATION" ? (openBlock(), createBlock(unref(QCardSection), { key: 1 }, {
260
379
  default: withCtx(() => [
261
- _cache[11] || (_cache[11] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, "Confirm your pairing code", -1)),
262
- createElementVNode("div", _hoisted_7$1, toDisplayString(pairInfo.value.confirmationCode), 1),
263
- _cache[12] || (_cache[12] = createElementVNode("div", { class: "text-center text-sm text-gray-500" }, "Confirm the matching pairing code on the terminal", -1))
380
+ _cache[12] || (_cache[12] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, " Confirm your pairing code ", -1)),
381
+ createElementVNode("div", _hoisted_7, toDisplayString(pairInfo.value.confirmationCode), 1),
382
+ _cache[13] || (_cache[13] = createElementVNode("div", { class: "text-center text-sm text-gray-500" }, " Confirm the matching pairing code on the terminal ", -1))
264
383
  ]),
265
384
  _: 1
266
385
  })) : pairInfo.value.state === "FINISHED" ? (openBlock(), createBlock(unref(QCardSection), { key: 2 }, {
@@ -293,7 +412,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
293
412
  function posRefIdGenerator(type) {
294
413
  return (/* @__PURE__ */ new Date()).toISOString() + "-" + type + v4();
295
414
  }
296
- function purchase({ purchaseAmount, tipAmount, cashoutAmount, promptForCashout, surchargeAmount }) {
415
+ function purchase({
416
+ purchaseAmount,
417
+ tipAmount,
418
+ cashoutAmount,
419
+ promptForCashout,
420
+ surchargeAmount
421
+ }) {
297
422
  spi.AckFlowEndedAndBackToIdle();
298
423
  spi.InitiatePurchaseTxV2(
299
424
  posRefIdGenerator("purchase"),
@@ -335,57 +460,41 @@ function settlement() {
335
460
  }
336
461
  function settlementEnquiry() {
337
462
  spi.AckFlowEndedAndBackToIdle();
338
- spi.InitiateSettlementEnquiry(posRefIdGenerator("settlementEnquiry"), receiptOptions);
463
+ spi.InitiateSettlementEnquiry(
464
+ posRefIdGenerator("settlementEnquiry"),
465
+ receiptOptions
466
+ );
339
467
  }
340
- function acceptSignature(signatureConfirmed) {
341
- spi.AcceptSignature(signatureConfirmed);
468
+ function overrideTransaction(isSuccess) {
469
+ if (isSuccess) {
470
+ spi.AckFlowEndedAndBackToIdle();
471
+ } else {
472
+ spi.AckFlowEndedAndBackToIdle();
473
+ }
342
474
  }
343
475
  const _hoisted_1 = { class: "text-center font-semibold text-gray-500 uppercase" };
344
476
  const _hoisted_2 = { class: "text-center font-semibold text-gray-500" };
345
477
  const _hoisted_3 = { class: "text-center font-semibold text-gray-500" };
346
478
  const _hoisted_4 = { class: "grid grid-cols-2 gap-3" };
347
479
  const _hoisted_5 = { class: "text-center font-semibold text-gray-500" };
348
- const _hoisted_6 = { class: "grid grid-cols-2 gap-3" };
349
- const _hoisted_7 = { class: "text-center font-semibold text-gray-500" };
350
480
  const _sfc_main = /* @__PURE__ */ defineComponent({
351
481
  __name: "TransactionDialog",
352
- emits: ["transaction-success"],
353
- setup(__props, { expose: __expose, emit: __emit }) {
354
- const emit = __emit;
482
+ setup(__props, { expose: __expose }) {
355
483
  const pairInfo = ref({
356
484
  state: "INPROGRESS",
357
- message: "Processing",
358
- transactionType: TransactionType.Purchase
485
+ message: "Processing"
359
486
  });
360
487
  const model = ref(false);
361
488
  const transactionAmount = ref(0);
362
- function overrideTransaction(isSuccess) {
363
- if (isSuccess) {
364
- spi.AckFlowEndedAndBackToIdle();
365
- pairInfo.value.state = "SUCCESS";
366
- emit("transaction-success", true);
367
- } else {
368
- spi.AckFlowEndedAndBackToIdle();
369
- pairInfo.value.state = "FAILED";
370
- pairInfo.value.message = "Manual Recovery";
371
- }
372
- }
373
489
  document.addEventListener("TxFlowStateChanged", (e) => {
374
- var _a, _b, _c;
375
490
  model.value = true;
376
- transactionAmount.value = e.detail.AmountCents / 100;
377
- localStorage.setItem("mx51.posRefId", e.detail.PosRefId);
378
- localStorage.setItem("mx51.txType", e.detail.Type);
379
491
  if (e.detail.AttemptingToCancel) {
380
492
  pairInfo.value.state = "AWAITING_CANCELLATION";
381
493
  pairInfo.value.message = "Please wait";
382
494
  }
383
- if (e.detail.AwaitingSignatureCheck) {
384
- pairInfo.value.state = "AWAITING_SIGNATURE_CHECK";
385
- } else if (e.detail.AwaitingPhoneForAuth) ;
495
+ if (e.detail.AwaitingSignatureCheck) ;
496
+ else if (e.detail.AwaitingPhoneForAuth) ;
386
497
  else if (e.detail.Finished) {
387
- localStorage.removeItem("mx51.posRefId");
388
- localStorage.removeItem("mx51.txType");
389
498
  switch (e.detail.Success) {
390
499
  case SuccessState.Success:
391
500
  pairInfo.value.state = "SUCCESS";
@@ -397,7 +506,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
397
506
  }
398
507
  break;
399
508
  case SuccessState.Failed:
400
- pairInfo.value.message = ((_c = (_b = (_a = e.detail) == null ? void 0 : _a.Response) == null ? void 0 : _b.Data) == null ? void 0 : _c.error_detail) ?? e.detail.DisplayMessage;
509
+ const ResponseData = e.detail.Response.Data;
510
+ pairInfo.value.message = ResponseData.error_detail ?? "Failed";
401
511
  pairInfo.value.state = "FAILED";
402
512
  break;
403
513
  case SuccessState.Unknown:
@@ -409,19 +519,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
409
519
  spi.TransactionUpdateMessage = (e) => {
410
520
  pairInfo.value.message = e.Data.display_message_text;
411
521
  };
412
- const showDialog = (amount, type) => {
522
+ const showDialog = (amount) => {
413
523
  transactionAmount.value = amount;
414
524
  pairInfo.value.state = "INPROGRESS";
415
525
  pairInfo.value.message = "Processing";
416
526
  model.value = true;
417
- pairInfo.value.transactionType = type ?? TransactionType.Purchase;
418
527
  };
419
528
  __expose({ showDialog });
420
529
  return (_ctx, _cache) => {
421
530
  const _directive_close_popup = resolveDirective("close-popup");
422
531
  return openBlock(), createBlock(unref(QDialog), {
423
532
  modelValue: model.value,
424
- "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => model.value = $event),
533
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => model.value = $event),
425
534
  persistent: ""
426
535
  }, {
427
536
  default: withCtx(() => [
@@ -429,7 +538,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
429
538
  default: withCtx(() => [
430
539
  pairInfo.value.state === "INPROGRESS" ? (openBlock(), createBlock(unref(QCardSection), { key: 0 }, {
431
540
  default: withCtx(() => [
432
- createElementVNode("div", _hoisted_1, toDisplayString(pairInfo.value.transactionType) + " of $" + toDisplayString(transactionAmount.value) + " in progress... ", 1),
541
+ createElementVNode("div", _hoisted_1, " Purchase of $" + toDisplayString(transactionAmount.value) + " in progress... ", 1),
433
542
  createElementVNode("div", _hoisted_2, toDisplayString(pairInfo.value.message), 1),
434
543
  createVNode(unref(QBtn), {
435
544
  label: "Cancel",
@@ -445,19 +554,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
445
554
  _: 1
446
555
  })) : pairInfo.value.state === "AWAITING_CANCELLATION" ? (openBlock(), createBlock(unref(QCardSection), { key: 1 }, {
447
556
  default: withCtx(() => [
448
- _cache[5] || (_cache[5] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, "Attempting to cancel transaction", -1)),
557
+ _cache[3] || (_cache[3] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, " Attempting to cancel transaction ", -1)),
449
558
  createElementVNode("div", _hoisted_3, toDisplayString(pairInfo.value.message), 1)
450
559
  ]),
451
560
  _: 1
452
561
  })) : pairInfo.value.state === "MANUAL_RECOVERY" ? (openBlock(), createBlock(unref(QCardSection), { key: 2 }, {
453
562
  default: withCtx(() => [
454
- _cache[6] || (_cache[6] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, "Was the transaction successful", -1)),
455
- _cache[7] || (_cache[7] = createElementVNode("div", { class: "text-center font-semibold text-gray-500" }, "Check the EFTPOS terminal", -1)),
563
+ _cache[4] || (_cache[4] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, " Was the transaction successful ", -1)),
564
+ _cache[5] || (_cache[5] = createElementVNode("div", { class: "text-center font-semibold text-gray-500" }, " Check the EFTPOS terminal ", -1)),
456
565
  createElementVNode("div", _hoisted_4, [
457
566
  createVNode(unref(QBtn), {
458
567
  label: "Yes",
459
568
  color: "primary",
460
- onClick: _cache[0] || (_cache[0] = ($event) => overrideTransaction(true)),
569
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(overrideTransaction)(true)),
461
570
  outline: "",
462
571
  class: "!mt-6",
463
572
  unelevated: "",
@@ -468,35 +577,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
468
577
  label: "No",
469
578
  color: "primary",
470
579
  outline: "",
471
- onClick: _cache[1] || (_cache[1] = ($event) => overrideTransaction(false)),
472
- class: "!mt-6",
473
- unelevated: "",
474
- "no-caps": "",
475
- ripple: false
476
- })
477
- ])
478
- ]),
479
- _: 1
480
- })) : pairInfo.value.state === "AWAITING_SIGNATURE_CHECK" ? (openBlock(), createBlock(unref(QCardSection), { key: 3 }, {
481
- default: withCtx(() => [
482
- _cache[8] || (_cache[8] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, "Confirm the customer's signature", -1)),
483
- createElementVNode("div", _hoisted_5, toDisplayString(pairInfo.value.message), 1),
484
- createElementVNode("div", _hoisted_6, [
485
- createVNode(unref(QBtn), {
486
- label: "Accept",
487
- color: "primary",
488
- onClick: _cache[2] || (_cache[2] = ($event) => unref(acceptSignature)(true)),
489
- outline: "",
490
- class: "!mt-6",
491
- unelevated: "",
492
- "no-caps": "",
493
- ripple: false
494
- }),
495
- createVNode(unref(QBtn), {
496
- label: "Decline",
497
- color: "primary",
498
- outline: "",
499
- onClick: _cache[3] || (_cache[3] = ($event) => unref(acceptSignature)(false)),
580
+ onClick: _cache[1] || (_cache[1] = ($event) => unref(overrideTransaction)(false)),
500
581
  class: "!mt-6",
501
582
  unelevated: "",
502
583
  "no-caps": "",
@@ -505,9 +586,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
505
586
  ])
506
587
  ]),
507
588
  _: 1
508
- })) : pairInfo.value.state === "SUCCESS" ? (openBlock(), createBlock(unref(QCardSection), { key: 4 }, {
589
+ })) : pairInfo.value.state === "SUCCESS" ? (openBlock(), createBlock(unref(QCardSection), { key: 3 }, {
509
590
  default: withCtx(() => [
510
- _cache[9] || (_cache[9] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, "Transaction Successful", -1)),
591
+ _cache[6] || (_cache[6] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, " Transaction Successful ", -1)),
511
592
  withDirectives(createVNode(unref(QBtn), {
512
593
  label: "OK",
513
594
  color: "primary",
@@ -521,10 +602,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
521
602
  ])
522
603
  ]),
523
604
  _: 1
524
- })) : pairInfo.value.state === "FAILED" ? (openBlock(), createBlock(unref(QCardSection), { key: 5 }, {
605
+ })) : pairInfo.value.state === "FAILED" ? (openBlock(), createBlock(unref(QCardSection), { key: 4 }, {
525
606
  default: withCtx(() => [
526
- _cache[10] || (_cache[10] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, "Transaction Failed", -1)),
527
- createElementVNode("div", _hoisted_7, toDisplayString(pairInfo.value.message), 1),
607
+ _cache[7] || (_cache[7] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, " Transaction Failed ", -1)),
608
+ createElementVNode("div", _hoisted_5, toDisplayString(pairInfo.value.message), 1),
528
609
  withDirectives(createVNode(unref(QBtn), {
529
610
  label: "OK",
530
611
  color: "primary",
@@ -551,7 +632,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
551
632
  export {
552
633
  _sfc_main$1 as PairMX51,
553
634
  _sfc_main as TransactionDialog,
554
- acceptSignature,
555
635
  cancelTransaction,
556
636
  getTransaction,
557
637
  log,
package/dist/smartpay.js CHANGED
@@ -5,7 +5,7 @@ import axios, { HttpStatusCode, isAxiosError } from "axios";
5
5
  import { t as timeout } from "./index-C8vc_75e.js";
6
6
  import { Dialog } from "quasar";
7
7
  import { d as dialogDefaultOpts } from "./utils-DcpEg5Bx.js";
8
- import { b as state, e as environment } from "./state-D014QcxX.js";
8
+ import { b as state, e as environment } from "./state-DdRk6ppP.js";
9
9
  var TransactionOutcome = /* @__PURE__ */ ((TransactionOutcome2) => {
10
10
  TransactionOutcome2[TransactionOutcome2["Accepted"] = 1] = "Accepted";
11
11
  TransactionOutcome2[TransactionOutcome2["Declined"] = 2] = "Declined";
@@ -9,8 +9,7 @@ const state = reactive({
9
9
  posBusinessName: "",
10
10
  tyroApiKey: "",
11
11
  tillPaymentApiKey: "",
12
- tillPaymentMerchantId: "",
13
- mx51DeviceApiKey: ""
12
+ tillPaymentMerchantId: ""
14
13
  });
15
14
  const environment = ref("production");
16
15
  const isPluginInitialized = ref(false);
@@ -25,7 +24,6 @@ const setState = (options) => {
25
24
  options.tyroApiKey && (state.tyroApiKey = options.tyroApiKey);
26
25
  options.tillPaymentApiKey && (state.tillPaymentApiKey = options.tillPaymentApiKey);
27
26
  options.tillPaymentMerchantId && (state.tillPaymentMerchantId = options.tillPaymentMerchantId);
28
- options.mx51DeviceApiKey && (state.mx51DeviceApiKey = options.mx51DeviceApiKey);
29
27
  };
30
28
  const setEnvironment = (env) => environment.value = env;
31
29
  const checkPluginInitialized = () => {
package/dist/tyro.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { QSpinnerHourglass, Dialog } from "quasar";
2
- import { c as checkPluginInitialized, e as environment, b as state } from "./state-D014QcxX.js";
2
+ import { c as checkPluginInitialized, e as environment, b as state } from "./state-DdRk6ppP.js";
3
3
  import { T as TYRO_CONSTANTS } from "./tyro.enums-OZuKaM2C.js";
4
4
  import { a } from "./tyro.enums-OZuKaM2C.js";
5
5
  const dialogDefaultOpts = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@achyutlabsau/vue-payment-gateway",
3
3
  "private": false,
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,125 +0,0 @@
1
- import { Spi, TransactionOptions, SuccessState, TransactionType } from "@mx51/spi-client-js";
2
- const spiSettings = {
3
- secureWebSockets: window.location.protocol === "https:" ? true : false,
4
- // checks for HTTPs
5
- printMerchantCopyOnEftpos: false,
6
- // prints merchant receipt from terminal instead of POS
7
- promptForCustomerCopyOnEftpos: false,
8
- // prints customer receipt from terminal instead of POS
9
- signatureFlowOnEftpos: false
10
- // signature flow and receipts on terminal instead of POS
11
- };
12
- const getTenants = async (vendorId, deviceApiKey) => {
13
- try {
14
- const res = await Spi.GetAvailableTenants(vendorId, deviceApiKey, "AU");
15
- return res.Data;
16
- } catch (error) {
17
- console.warn(error);
18
- return [];
19
- }
20
- };
21
- const getPairingData = () => {
22
- try {
23
- return JSON.parse(localStorage.getItem("pairingData") ?? "{}");
24
- } catch (error) {
25
- return {};
26
- }
27
- };
28
- const getSecrets = () => {
29
- try {
30
- const secrets = localStorage.getItem("secrets");
31
- return secrets ? JSON.parse(secrets) : null;
32
- } catch (error) {
33
- return null;
34
- }
35
- };
36
- const pairingData = getPairingData();
37
- const spi = new Spi(
38
- pairingData.posId ?? "",
39
- pairingData.serialNumber ?? "",
40
- localStorage.getItem("eftposAddress") ?? "192.168.31.246",
41
- getSecrets()
42
- );
43
- spi.SetAutoAddressResolution(!!pairingData.autoAddressResolution);
44
- spi.SetTenantCode(pairingData.tenantCode ?? "gko");
45
- spi.SetSecureWebSockets(spiSettings.secureWebSockets);
46
- spi.Config.PrintMerchantCopy = spiSettings.printMerchantCopyOnEftpos;
47
- spi.Config.PromptForCustomerCopyOnEftpos = spiSettings.promptForCustomerCopyOnEftpos;
48
- spi.Config.SignatureFlowOnEftpos = spiSettings.signatureFlowOnEftpos;
49
- const receiptOptions = new TransactionOptions();
50
- function log(message, event) {
51
- if (event) {
52
- spi._log.info(`${message} -> `, event);
53
- } else {
54
- spi._log.info(message);
55
- }
56
- }
57
- document.addEventListener("StatusChanged", (e) => {
58
- log("Status changed", e.detail);
59
- if ((e == null ? void 0 : e.detail) === "PairedConnected") ;
60
- });
61
- document.addEventListener("SecretsChanged", (e) => {
62
- log("Secrets changed", e);
63
- if (e == null ? void 0 : e.detail) {
64
- window.localStorage.setItem("secrets", JSON.stringify(e.detail));
65
- }
66
- });
67
- document.addEventListener("PairingFlowStateChanged", (e) => {
68
- var _a, _b, _c, _d, _e, _f, _g;
69
- log("Pairing flow state changed", e);
70
- log(
71
- ((_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
72
- );
73
- 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)) {
74
- spi.AckFlowEndedAndBackToIdle();
75
- }
76
- });
77
- document.addEventListener("TxFlowStateChanged", (e) => {
78
- log("Transaction flow state changed", e);
79
- if (e.detail.AwaitingSignatureCheck) ;
80
- else if (e.detail.AwaitingPhoneForAuth) ;
81
- else if (e.detail.Finished) {
82
- switch (e.detail.Success) {
83
- case SuccessState.Success:
84
- switch (e.detail.Type) {
85
- case TransactionType.Purchase:
86
- break;
87
- case TransactionType.Refund:
88
- break;
89
- }
90
- break;
91
- case SuccessState.Failed:
92
- break;
93
- case SuccessState.Unknown:
94
- break;
95
- }
96
- }
97
- });
98
- document.addEventListener("DeviceAddressChanged", (e) => {
99
- log("Device address changed", e);
100
- if (e == null ? void 0 : e.detail.ip) {
101
- window.localStorage.setItem("eftposAddress", JSON.stringify(e.detail.ip));
102
- } else if (e == null ? void 0 : e.detail.fqdn) {
103
- window.localStorage.setItem("eftposAddress", JSON.stringify(e.detail.fqdn));
104
- }
105
- });
106
- spi.TerminalConfigurationResponse = (e) => {
107
- log("Terminal configuration response", e);
108
- spi.GetTerminalStatus();
109
- };
110
- spi.TerminalStatusResponse = (e) => {
111
- log("Terminal status response", e);
112
- };
113
- spi.TransactionUpdateMessage = (e) => {
114
- log("Transaction update", e);
115
- };
116
- spi.BatteryLevelChanged = (e) => {
117
- log("Battery level changed", e);
118
- };
119
- export {
120
- getTenants as a,
121
- getPairingData as g,
122
- log as l,
123
- receiptOptions as r,
124
- spi as s
125
- };