@achyutlabsau/vue-payment-gateway 0.19.0 → 1.0.0-beta.1

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 (43) hide show
  1. package/README.md +119 -97
  2. package/dist/PBtn-B_JOD69N.js +38 -0
  3. package/dist/PairInstructions-CzbeFfD_.js +45 -0
  4. package/dist/core-ExhZA5wz.js +215 -0
  5. package/dist/index.d.ts +587 -0
  6. package/dist/index.js +80 -69
  7. package/dist/linkly-BfEScMPq.js +613 -0
  8. package/dist/linkly.d.ts +29 -3
  9. package/dist/linkly.js +2 -2
  10. package/dist/logger-c0YCqJje.js +589 -0
  11. package/dist/logger.d.ts +1760 -0
  12. package/dist/logger.js +2 -0
  13. package/dist/mx51-Cx-QU9ms.js +621 -0
  14. package/dist/mx51.js +1 -1
  15. package/dist/smartpay-DAyaqvId.js +313 -0
  16. package/dist/smartpay.d.ts +197 -26
  17. package/dist/smartpay.js +2 -2
  18. package/dist/{till-payment-Cpoq8EVJ.js → till-payment-ooytbfnP.js} +219 -183
  19. package/dist/till-payment.d.ts +37 -15
  20. package/dist/till-payment.js +2 -2
  21. package/dist/tyro-SIziM17_.js +228 -0
  22. package/dist/tyro.d.ts +8 -14
  23. package/dist/tyro.js +2 -2
  24. package/dist/utils.d.ts +1337 -0
  25. package/dist/utils.js +38 -0
  26. package/dist/valpay-D8GbM2Iv.js +769 -0
  27. package/dist/valpay.d.ts +176 -28
  28. package/dist/valpay.js +1 -1
  29. package/dist/worldline-BHzSNXMN.js +457 -0
  30. package/dist/worldline.d.ts +467 -0
  31. package/dist/worldline.js +2 -2
  32. package/package.json +19 -3
  33. package/dist/PBtn-CB98SoO5.js +0 -19
  34. package/dist/PairInstructions-CVnT81Id.js +0 -65
  35. package/dist/core-BMUVlh-t.js +0 -109
  36. package/dist/linkly-kVIcGvAk.js +0 -544
  37. package/dist/mx51-FCR8P_qa.js +0 -621
  38. package/dist/smartpay-sB9Pt9PZ.js +0 -269
  39. package/dist/tyro-DvHhgqHe.js +0 -242
  40. package/dist/utils-BPFf60Ai.js +0 -21
  41. package/dist/utils-CAwJtwP_.js +0 -33
  42. package/dist/valpay-DoVz604A.js +0 -582
  43. package/dist/worldline-DRyAhSeD.js +0 -512
package/README.md CHANGED
@@ -1,22 +1,42 @@
1
1
  # Vue Payment Gateway
2
2
 
3
- A Vue.js payment gateway library to handle payments with ease.
3
+ **@achyutlabsau/vue-payment-gateway** is a Vue 3 library that provides unified integration with multiple payment
4
+ terminal providers — in-store EFTPOS terminals and cloud-based payment APIs — behind a small, consistent Vue
5
+ composable API per provider.
6
+
7
+ Full documentation, including a step-by-step guide, install options reference, and per-gateway details, lives in the
8
+ [docs site](https://achyut-labs.github.io/al-pay-npm-pkg/) (or run `npm run docs:dev` locally). This README is a
9
+ quick-reference summary.
10
+
11
+ ## Supported Providers
12
+
13
+ | Provider | Type | Composable / Entry |
14
+ | ------------------ | ------------------------ | ---------------------------------- |
15
+ | **Tyro** | In-store EFTPOS (iframe) | `useTyro` (`/tyro`) |
16
+ | **Linkly** | In-store (Linkly Cloud) | `useLinkly` (`/linkly`) |
17
+ | **SmartPay** | In-store (cloud polling) | `useSmartPay` (`/smartpay`) |
18
+ | **Till Payments** | In-store (REST intents) | `useTillPayment` (`/till-payment`) |
19
+ | **MX51 SPI** | In-store (SPI, events) | `useMX51` (`/mx51`) |
20
+ | **ANZ Worldline** | In-store (TimAPI / WASM) | `timApi` (`/worldline`) |
21
+ | **Valpay (Adyen)** | Cloud Terminal API | `useValpay` (`/valpay`) |
4
22
 
5
23
  ## Installation
6
24
 
7
- To install the library, run the following command:
8
-
9
25
  ```bash
10
26
  npm install @achyutlabsau/vue-payment-gateway
11
27
  ```
12
28
 
13
- ## Plugin Initialization
29
+ Peer dependencies your app must also install: `@vueuse/core`, `@vueuse/rxjs`, `axios`, `dayjs`, `dexie`, `quasar`,
30
+ `uuid`, `vue`. See [Installation](docs/installation.md) for versions and full setup.
14
31
 
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:
32
+ ## Plugin Initialization
16
33
 
17
- ```javascript
34
+ ```ts
35
+ import { createApp } from "vue";
18
36
  import VuePaymentGateway from "@achyutlabsau/vue-payment-gateway";
19
37
 
38
+ const app = createApp(App);
39
+
20
40
  app.use(VuePaymentGateway, {
21
41
  currencyCode: "AUD",
22
42
  productName: "Pratham Respos", // Name of your product
@@ -27,142 +47,144 @@ app.use(VuePaymentGateway, {
27
47
  posRegisterName: "register-name", // Name of the POS register
28
48
  posBusinessName: "business name", // Name of the business using the POS system
29
49
  tyroApiKey: "tyro-api-key", // API key for Tyro integration
30
- valpayApiKey: "valpay-api-key", // API key for Valpay (Adyen) integration
31
- environment: "development", // Set environment to 'development' or 'production'
50
+ environment: "development", // "development" | "production"
51
+ onReceiptPrint: (receipt, type) => {
52
+ // Unified across every provider — see docs/features/receipts.md
53
+ },
32
54
  });
55
+
56
+ app.mount("#app");
33
57
  ```
34
58
 
35
- > **Note:** Replace the placeholder values with the actual details of your POS system, product, and Tyro API key.
59
+ > Only set the credentials for the providers you actually use — see the [Install Options Reference](docs/installation.md#install-options-reference).
36
60
 
37
61
  ## Using the Payment Gateway
38
62
 
39
- This library supports multiple payment providers, such as Tyro, SmartPay, and Linkly. Here’s how to use them in your application.
63
+ Provider composables are **not** identical — method names mirror each vendor's own terminology rather than being
64
+ forced into one generic shape, because the underlying protocols differ (event-driven SPI vs. cloud polling vs. an
65
+ iframe SDK). SmartPay, Till Payments and Valpay have converged on a shared `PaymentTerminal` contract
66
+ (`pair` / `unpair` / `isPaired` / `purchase` / `refund`); Tyro, Linkly, MX51 and Worldline still expose their own
67
+ surface. See [Transaction Processing](docs/features/transactions.md) for the full per-provider reference, and
68
+ [migration-v1.md](docs/migration-v1.md) if you're upgrading from a pre-1.0 release.
40
69
 
41
- ### Using Tyro
70
+ ### SmartPay, Till Payments, Valpay (shared contract)
42
71
 
43
- To use the Tyro payment gateway, import and initialize it as shown below:
44
-
45
- ```javascript
46
- import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
47
-
48
- const tyro = useTyro();
49
-
50
- // Example usage
51
- await tyro.processPayment(amount, options);
52
- ```
53
-
54
- ### Using SmartPay
55
-
56
- To use the SmartPay payment gateway, import and initialize it as shown below:
57
-
58
- ```javascript
72
+ ```ts
59
73
  import { useSmartPay } from "@achyutlabsau/vue-payment-gateway/smartpay";
60
74
 
61
- const smartPay = useSmartPay();
62
-
63
- // Example usage
64
- await smartPay.processPayment(amount, options);
65
- ```
66
-
67
- ### Using Linkly
75
+ const smartpay = useSmartPay();
68
76
 
69
- To use the Linkly payment gateway, import and initialize it as shown below:
77
+ await smartpay.pair({ pairingCode: "123456" });
78
+ smartpay.isPaired(); // boolean
70
79
 
71
- ```javascript
72
- import { useLinkly } from "@achyutlabsau/vue-payment-gateway/linkly";
80
+ const res = await smartpay.purchase(1000); // $10.00, amounts are in cents
81
+ // res.success, res.status, res.amount, res.tipAmount, res.maskedCard, res.cardScheme, res.receipts
73
82
 
74
- const linkly = useLinkly();
75
-
76
- // Example usage
77
- await linkly.processPayment(amount, options);
83
+ await smartpay.refund(1000);
84
+ smartpay.unpair();
78
85
  ```
79
86
 
80
- ### Using Valpay (Adyen)
87
+ `useTillPayment()` and `useValpay()` follow the same `pair`/`unpair`/`isPaired`/`purchase`/`refund` shape and both
88
+ resolve with the same `PaymentResult`. Till and Valpay additionally support **referenced (linked) refunds** via
89
+ `refund(cents, { originalTransactionId })`.
81
90
 
82
- To use the Valpay (Adyen Terminal API) payment gateway, import and initialize it as shown below:
91
+ ### Tyro
83
92
 
84
- ```javascript
85
- import { useValpay } from "@achyutlabsau/vue-payment-gateway/valpay";
93
+ ```ts
94
+ import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
86
95
 
87
- const valpay = useValpay();
96
+ const tyro = useTyro();
88
97
 
89
- // Get connected terminals
90
- const { success, terminals } = await valpay.getConnectedTerminals();
98
+ await tyro.pairTyro(merchantId, terminalId);
91
99
 
92
- // Process a payment
93
- const result = await valpay.processPayment(
94
- 10050, // Amount in minor units (100.50)
95
- "AUD", // Currency code
96
- "V400m-324688179", // Terminal ID (POIID)
97
- "transaction-12345", // Transaction ID
98
- "POSSystemID12345", // Sale ID
99
- );
100
+ const res = await tyro.initiateTyroPurchase({ integratedReceipt: true, amount: "1000" }, receiptCallback);
101
+ // res.result is a TyroTransactionStatus, e.g. "APPROVED"
100
102
 
101
- // Cancel an ongoing payment
102
- const cancelResult = await valpay.cancelPayment("MerchantAbort");
103
+ await tyro.initiateTyroRefund({ integratedReceipt: true, amount: "1000" }, receiptCallback);
103
104
  ```
104
105
 
105
- ## Payment Method API
106
+ ### Linkly
106
107
 
107
- Each payment provider (Tyro, SmartPay, Linkly) provides methods to process payments. Here are some of the most commonly used methods:
108
+ ```ts
109
+ import { useLinkly, ReceiptAutoPrint } from "@achyutlabsau/vue-payment-gateway/linkly";
108
110
 
109
- ### `processPayment(amount: number, options?: object)`
111
+ const linkly = useLinkly();
110
112
 
111
- Processes a payment for the specified amount.
113
+ await linkly.pairPinpad({ username, password, pairCode: "123456" });
112
114
 
113
- **Parameters:**
115
+ const res = await linkly.initiatePurchase({
116
+ AmtPurchase: 1000,
117
+ ReceiptAutoPrint: ReceiptAutoPrint.ReturnToPOS,
118
+ });
114
119
 
115
- - `amount`: The amount to be charged.
116
- - `options`: (Optional) Additional options for the payment.
120
+ // Referenced (linked) refund — pass the original purchase's RFN:
121
+ await linkly.initiateRefund({
122
+ AmtPurchase: 1000,
123
+ ReceiptAutoPrint: ReceiptAutoPrint.ReturnToPOS,
124
+ referenceNumber: rfn,
125
+ });
126
+ ```
117
127
 
118
- ### `cancelPayment()`
128
+ ### MX51 SPI
119
129
 
120
- Cancels an ongoing payment.
130
+ MX51 is event-driven: `initiatePurchase`/`initiateRefund` start the flow but resolve with `void`. Subscribe to the
131
+ `TxFlowStateChanged` document event (or use the bundled `TransactionDialog`) to observe the outcome. See
132
+ [Transaction Processing](docs/features/transactions.md#mx51-spi).
121
133
 
122
- ### `getStatus()`
134
+ ### ANZ Worldline (TimAPI)
123
135
 
124
- Gets the status of the current payment transaction.
136
+ Worldline is driven directly through the `timApi` instance rather than a composable:
125
137
 
126
- > **Note:** The methods may differ slightly between Tyro, SmartPay, and Linkly. Refer to the official documentation of each payment provider for more details.
138
+ ```ts
139
+ import { timApi } from "@achyutlabsau/vue-payment-gateway/worldline";
127
140
 
128
- ## Environment Configuration
141
+ timApi.actionPurchase(1000); // cents
142
+ timApi.actionRefund(1000); // unreferenced (standalone) refund
143
+ timApi.actionRefund(1000, lastTransactionSeq); // referenced (linked) refund
144
+ ```
129
145
 
130
- 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.
146
+ ## Checking Pairing Status
131
147
 
132
- ```javascript
133
- app.use(VuePaymentGateway, {
134
- ...
135
- environment: "production", // Set to 'production' in a live environment
136
- });
137
- ```
148
+ ```ts
149
+ import { isPaymentGatewayConnected, PaymentGateways } from "@achyutlabsau/vue-payment-gateway";
138
150
 
139
- ## Example Usage
151
+ isPaymentGatewayConnected(PaymentGateways.Linkly); // reads linkly.pairConfig from localStorage
152
+ ```
140
153
 
141
- Here’s a complete example of how you might use the payment gateway to process a payment with Tyro:
154
+ ## Logging
142
155
 
143
- ```javascript
144
- import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
156
+ Every provider logs through one shared, IndexedDB-backed logger (`./logger` subpath) — persistent across reloads,
157
+ attributable to a gateway, correlated by transaction, and with secrets/PANs redacted centrally. See
158
+ [Logging](docs/features/logging.md) for configuration, the `LogViewer` component, and how to query/export logs.
145
159
 
146
- const tyro = useTyro();
160
+ ## Shared Utilities
147
161
 
148
- async function handlePayment() {
149
- try {
150
- const paymentResult = await tyro.processPayment(100, { currency: "USD" });
151
- console.log("Payment successful:", paymentResult);
152
- } catch (error) {
153
- console.error("Payment failed:", error);
154
- }
155
- }
162
+ ```ts
163
+ import {
164
+ toCents,
165
+ toMajorUnits,
166
+ formatCents,
167
+ maskPan,
168
+ normalizeCardScheme,
169
+ CardScheme,
170
+ } from "@achyutlabsau/vue-payment-gateway/utils";
156
171
  ```
157
172
 
173
+ Available from the root entry too, alongside `generateTransactionId()`, `setState()`, and `setCurrencyCode()`.
174
+
158
175
  ## Troubleshooting
159
176
 
160
- - **Environment Issues**: Make sure `environment` is set correctly (`development` or `production`).
161
- - **Invalid API Key**: Ensure the Tyro API key is valid and correctly set in the configuration.
162
- - **Payment Processing Issues**: Check if the payment provider's service is online and available.
177
+ - **"Plugin not initialized" errors** — provider composables throw if called before `app.use(VuePaymentGateway, …)`
178
+ has run. Call `use*` inside components/handlers, not at module load time.
179
+ - **Environment issues** — make sure `environment` is set correctly (`"development"` or `"production"`); it selects
180
+ each provider's SDK/endpoint URLs.
181
+ - **Invalid API key** — confirm the provider's API key/merchant credentials are set in the plugin options.
182
+ - **Diagnosing a failed transaction** — check the [Logging](docs/features/logging.md) guide; every gateway's request,
183
+ response and retry history is queryable through `logger.query()` or the `LogViewer` component.
163
184
 
164
185
  ## Additional Resources
165
186
 
166
- For more details and usage examples, refer to the official documentation or support channels provided by [Achyutlabs](https://achyutlabs.com/).
167
-
168
- 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.
187
+ - [Full documentation](docs/index.md)
188
+ - [Changelog](CHANGELOG.md)
189
+ - [Migration guide (pre-1.0 → v1)](docs/migration-v1.md)
190
+ - [Achyutlabs](https://achyutlabs.com/)
@@ -0,0 +1,38 @@
1
+ import { createBlock as e, defineComponent as t, openBlock as n, reactive as r, ref as i, unref as a } from "vue";
2
+ import { QBtn as o } from "quasar";
3
+ //#region src/plugin/state.ts
4
+ var s = /* @__PURE__ */ function(e) {
5
+ return e.Tyro = "tyro", e.TillPayment = "till-instore", e.MX51 = "mx51-spi", e.Linkly = "linkly", e.SmartPay = "smartpay", e.ANZ = "anz-instore", e.ADYEN = "adyen-instore", e;
6
+ }({}), c = r({
7
+ productName: "",
8
+ productVersion: "",
9
+ productVendorName: "",
10
+ posId: "",
11
+ posRegisterId: "",
12
+ posRegisterName: "",
13
+ posBusinessName: "",
14
+ tyroApiKey: "",
15
+ tillPaymentApiKey: "",
16
+ tillPaymentMerchantId: "",
17
+ mx51DeviceApiKey: "",
18
+ apiBaseUrl: ""
19
+ }), l = i("AUD"), u = i("production"), d = i(!1), f = (e) => {
20
+ e.productName && (c.productName = e.productName), e.productVersion && (c.productVersion = e.productVersion), e.productVendorName && (c.productVendorName = e.productVendorName), e.posId && (c.posId = e.posId), e.posRegisterId && (c.posRegisterId = e.posRegisterId), e.posRegisterName && (c.posRegisterName = e.posRegisterName), e.posBusinessName && (c.posBusinessName = e.posBusinessName), e.tyroApiKey && (c.tyroApiKey = e.tyroApiKey), e.tillPaymentApiKey && (c.tillPaymentApiKey = e.tillPaymentApiKey), e.tillPaymentMerchantId && (c.tillPaymentMerchantId = e.tillPaymentMerchantId), e.mx51DeviceApiKey && (c.mx51DeviceApiKey = e.mx51DeviceApiKey), e.apiBaseUrl && (c.apiBaseUrl = e.apiBaseUrl);
21
+ }, p = (e) => l.value = e, m = (e) => u.value = e, h = () => {
22
+ if (d.value) return !0;
23
+ throw Error("[Vue Payment Gateway] Plugin is not initialized.");
24
+ }, g = /* @__PURE__ */ t({
25
+ __name: "PBtn",
26
+ setup(t) {
27
+ return (t, r) => (n(), e(a(o), {
28
+ label: "Cancel",
29
+ color: "primary",
30
+ size: "16px",
31
+ class: "!py-2.5",
32
+ unelevated: "",
33
+ ripple: !1
34
+ }));
35
+ }
36
+ });
37
+ //#endregion
38
+ export { u as a, m as c, l as i, f as l, s as n, d as o, h as r, p as s, g as t, c as u };
@@ -0,0 +1,45 @@
1
+ import { t as e } from "./PBtn-B_JOD69N.js";
2
+ import { Fragment as t, createBlock as n, createElementBlock as r, createElementVNode as i, createVNode as a, defineComponent as o, openBlock as s, renderList as c, toDisplayString as l, unref as u, withCtx as d } from "vue";
3
+ import { QCard as f, QIcon as p } from "quasar";
4
+ //#region node_modules/@quasar/extras/exports/mdi-v7/index.js
5
+ var m = "M2,6H4V18H2V6M5,6H6V18H5V6M7,6H10V18H7V6M11,6H12V18H11V6M14,6H16V18H14V6M17,6H20V18H17V6M21,6H22V18H21V6Z", h = "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", g = "M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z", _ = "M3 6H21V4H3C1.9 4 1 4.9 1 6V18C1 19.1 1.9 20 3 20H7V18H3V6M13 12H9V13.78C8.39 14.33 8 15.11 8 16C8 16.89 8.39 17.67 9 18.22V20H13V18.22C13.61 17.67 14 16.88 14 16S13.61 14.33 13 13.78V12M11 17.5C10.17 17.5 9.5 16.83 9.5 16S10.17 14.5 11 14.5 12.5 15.17 12.5 16 11.83 17.5 11 17.5M22 8H16C15.5 8 15 8.5 15 9V19C15 19.5 15.5 20 16 20H22C22.5 20 23 19.5 23 19V9C23 8.5 22.5 8 22 8M21 18H17V10H21V18Z", v = "M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z", y = "M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z", b = "M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z", x = { class: "mb-8 space-y-4" }, S = { class: "flex items-center justify-center" }, C = { class: "mb-8 space-y-4" }, w = { class: "h-8 w-8 bg-gray-100 font-semibold dark:bg-gray-700 flex shrink-0 items-center justify-center rounded-full" }, T = { class: "text-gray-700 dark:text-gray-200" }, E = { class: "mb-6 space-x-3 rounded-lg bg-amber-50 p-4 text-base dark:bg-slate-700 flex items-start" }, D = { class: "flex justify-end" }, O = /* @__PURE__ */ o({
6
+ __name: "PairInstructions",
7
+ props: { steps: {} },
8
+ emits: ["next"],
9
+ setup(o) {
10
+ return (m, h) => (s(), n(u(f), {
11
+ class: "rounded-lg p-6",
12
+ flat: "",
13
+ bordered: ""
14
+ }, {
15
+ default: d(() => [
16
+ i("div", x, [
17
+ i("div", S, [a(u(p), {
18
+ name: u(_),
19
+ size: "4rem",
20
+ class: "text-primary"
21
+ }, null, 8, ["name"])]),
22
+ h[1] ||= i("h2", { class: "text-2xl !font-medium text-center" }, "Terminal Setup Instructions", -1),
23
+ h[2] ||= i("p", { class: "text-base text-gray-600 dark:text-gray-200 text-center" }, " Please follow these steps to pair your terminal ", -1)
24
+ ]),
25
+ i("ul", C, [(s(!0), r(t, null, c(o.steps, (e, t) => (s(), r("li", {
26
+ key: t,
27
+ class: "space-x-3 text-base flex flex-nowrap items-center"
28
+ }, [i("span", w, l(t + 1), 1), i("span", T, l(e), 1)]))), 128))]),
29
+ i("div", E, [a(u(p), {
30
+ name: u(v),
31
+ size: "md",
32
+ class: "mt-0.5 text-amber-500 dark:text-white"
33
+ }, null, 8, ["name"]), h[3] ||= i("div", { class: "flex-1" }, [i("div", { class: "font-medium text-amber-800 dark:text-white" }, "Important Note"), i("div", { class: "text-amber-700 dark:text-gray-300" }, " Please refer to your terminal guide for the most up-to-date instructions. ")], -1)]),
34
+ i("div", D, [a(e, {
35
+ "icon-right": "chevron_right",
36
+ label: "Next",
37
+ onClick: h[0] ||= (e) => m.$emit("next")
38
+ })])
39
+ ]),
40
+ _: 1
41
+ }));
42
+ }
43
+ });
44
+ //#endregion
45
+ export { y as a, g as i, m as n, b as o, h as r, O as t };
@@ -0,0 +1,215 @@
1
+ import { t as e } from "./PBtn-B_JOD69N.js";
2
+ import { createBlock as t, createCommentVNode as n, createElementVNode as r, createVNode as i, defineComponent as a, openBlock as o, resolveDirective as s, toDisplayString as c, unref as l, withCtx as u, withDirectives as d } from "vue";
3
+ import { Dialog as f, QCard as p, QCardSection as m, QDialog as h, QSpinnerHourglass as g, useDialogPluginComponent as _ } from "quasar";
4
+ //#region src/core/types.ts
5
+ var v = /* @__PURE__ */ function(e) {
6
+ return e.Approved = "approved", e.Declined = "declined", e.Cancelled = "cancelled", e.Failed = "failed", e.Timeout = "timeout", e;
7
+ }({});
8
+ function y(e) {
9
+ return {
10
+ transactionId: null,
11
+ amount: null,
12
+ tipAmount: null,
13
+ surchargeAmount: null,
14
+ maskedCard: null,
15
+ cardScheme: null,
16
+ receipts: {},
17
+ raw: null,
18
+ ...e,
19
+ success: e.status === "approved"
20
+ };
21
+ }
22
+ //#endregion
23
+ //#region src/components/PairDialog.vue?vue&type=script&setup=true&lang.ts
24
+ var b = { class: "text-lg font-semibold text-gray-500 text-center uppercase" }, x = { class: "!mt-2 text-base text-gray-800 dark:text-gray-300 text-center" }, S = { class: "!mt-2 text-base text-gray-800 dark:text-gray-300 text-center" }, C = /* @__PURE__ */ a({
25
+ __name: "PairDialog",
26
+ props: {
27
+ message: {},
28
+ title: {},
29
+ cancelPairing: { type: Function }
30
+ },
31
+ emits: [..._.emits],
32
+ setup(a) {
33
+ let { dialogRef: f, onDialogHide: v } = _();
34
+ return (_, y) => {
35
+ let C = s("close-popup");
36
+ return o(), t(l(h), {
37
+ ref_key: "dialogRef",
38
+ ref: f,
39
+ onHide: l(v),
40
+ persistent: ""
41
+ }, {
42
+ default: u(() => [i(l(p), { class: "q-dialog-plugin px-6 py-3" }, {
43
+ default: u(() => [a.title === "INPROGRESS" ? (o(), t(l(m), {
44
+ key: 0,
45
+ class: "text-center"
46
+ }, {
47
+ default: u(() => [
48
+ i(l(g), {
49
+ color: "amber",
50
+ size: "3rem",
51
+ class: "!mb-4"
52
+ }),
53
+ r("div", b, c(a.message), 1),
54
+ i(e, {
55
+ label: "Cancel",
56
+ onClick: a.cancelPairing,
57
+ color: "primary",
58
+ outline: "",
59
+ class: "!mt-6 !w-full"
60
+ }, null, 8, ["onClick"])
61
+ ]),
62
+ _: 1
63
+ })) : a.title === "SUCCESS" ? (o(), t(l(m), { key: 1 }, {
64
+ default: u(() => [
65
+ y[0] ||= r("div", { class: "text-lg font-semibold text-green-500 text-center uppercase" }, "Success!", -1),
66
+ r("div", x, c(a.message), 1),
67
+ d(i(e, {
68
+ label: "OK",
69
+ color: "primary",
70
+ outline: "",
71
+ class: "!mt-6 !w-full"
72
+ }, null, 512), [[C]])
73
+ ]),
74
+ _: 1
75
+ })) : a.title === "FAILED" ? (o(), t(l(m), { key: 2 }, {
76
+ default: u(() => [
77
+ y[1] ||= r("div", { class: "text-lg font-semibold text-red-500 text-center uppercase" }, "Failed!", -1),
78
+ r("div", S, c(a.message), 1),
79
+ d(i(e, {
80
+ label: "OK",
81
+ color: "primary",
82
+ outline: "",
83
+ class: "!mt-6 !w-full"
84
+ }, null, 512), [[C]])
85
+ ]),
86
+ _: 1
87
+ })) : n("", !0)]),
88
+ _: 1
89
+ })]),
90
+ _: 1
91
+ }, 8, ["onHide"]);
92
+ };
93
+ }
94
+ }), w = { class: "text-lg font-semibold text-gray-500 text-center uppercase" }, T = { class: "text-lg font-semibold text-gray-500 text-center uppercase" }, E = { class: "text-lg font-semibold text-gray-500 text-center uppercase" }, D = /* @__PURE__ */ a({
95
+ __name: "TransactionDialog",
96
+ props: {
97
+ message: {},
98
+ title: {},
99
+ cancelTxn: { type: Function }
100
+ },
101
+ emits: [..._.emits],
102
+ setup(a) {
103
+ let { dialogRef: f, onDialogHide: g } = _();
104
+ return (_, v) => {
105
+ let y = s("close-popup");
106
+ return o(), t(l(h), {
107
+ ref_key: "dialogRef",
108
+ ref: f,
109
+ onHide: l(g),
110
+ persistent: ""
111
+ }, {
112
+ default: u(() => [i(l(p), { class: "q-dialog-plugin px-6 py-3" }, {
113
+ default: u(() => [a.title === "INPROGRESS" ? (o(), t(l(m), { key: 0 }, {
114
+ default: u(() => [r("div", w, c(a.message), 1), i(e, {
115
+ label: "Cancel",
116
+ onClick: a.cancelTxn,
117
+ color: "primary",
118
+ outline: "",
119
+ class: "!mt-6 !w-full"
120
+ }, null, 8, ["onClick"])]),
121
+ _: 1
122
+ })) : a.title === "SUCCESS" ? (o(), t(l(m), { key: 1 }, {
123
+ default: u(() => [r("div", T, c(a.message), 1), d(i(e, {
124
+ label: "OK",
125
+ color: "primary",
126
+ outline: "",
127
+ class: "!mt-6 !w-full"
128
+ }, null, 512), [[y]])]),
129
+ _: 1
130
+ })) : a.title === "FAILED" ? (o(), t(l(m), { key: 2 }, {
131
+ default: u(() => [r("div", E, c(a.message), 1), d(i(e, {
132
+ label: "OK",
133
+ color: "primary",
134
+ outline: "",
135
+ class: "!mt-6 !w-full"
136
+ }, null, 512), [[y]])]),
137
+ _: 1
138
+ })) : n("", !0)]),
139
+ _: 1
140
+ })]),
141
+ _: 1
142
+ }, 8, ["onHide"]);
143
+ };
144
+ }
145
+ });
146
+ //#endregion
147
+ //#region src/core/dialog.ts
148
+ function O(e) {
149
+ let t = e.successHideDelay ?? 1e3, n = f.create({
150
+ component: D,
151
+ componentProps: {
152
+ title: "INPROGRESS",
153
+ message: e.message,
154
+ cancelTxn: () => e.onCancel?.()
155
+ }
156
+ }), r = (e) => n.update({
157
+ title: "INPROGRESS",
158
+ message: e
159
+ }), i = (e = "Transaction Accepted!") => {
160
+ n.update({
161
+ title: "SUCCESS",
162
+ message: e
163
+ }), setTimeout(() => n.hide(), t);
164
+ }, a = (e = "Transaction Failed!") => n.update({
165
+ title: "FAILED",
166
+ message: e
167
+ });
168
+ return {
169
+ progress: r,
170
+ success: i,
171
+ failed: a,
172
+ settle: (e, t) => {
173
+ e === v.Approved ? i(t) : a(t);
174
+ },
175
+ hide: () => n.hide(),
176
+ hideAfter: (e = t) => {
177
+ setTimeout(() => n.hide(), e);
178
+ }
179
+ };
180
+ }
181
+ function k(e = {}) {
182
+ let { message: t = "Pairing in progress...", onCancel: n, successHideDelay: r = 3e3 } = typeof e == "string" ? { message: e } : e, i = f.create({
183
+ component: C,
184
+ componentProps: {
185
+ title: "INPROGRESS",
186
+ message: t,
187
+ cancelPairing: () => n?.()
188
+ }
189
+ }), a = (e) => i.update({
190
+ title: "INPROGRESS",
191
+ message: e
192
+ }), o = (e = r) => {
193
+ setTimeout(() => i.hide(), e);
194
+ }, s = (e = "Paired successfully!") => {
195
+ i.update({
196
+ title: "SUCCESS",
197
+ message: e
198
+ }), o();
199
+ }, c = (e = "Pairing failed!") => i.update({
200
+ title: "FAILED",
201
+ message: e
202
+ });
203
+ return {
204
+ progress: a,
205
+ success: s,
206
+ failed: c,
207
+ settle: (e, t) => {
208
+ e === "inProgress" ? a(t ?? "") : e === "success" ? s(t) : c(t);
209
+ },
210
+ hide: () => i.hide(),
211
+ hideAfter: o
212
+ };
213
+ }
214
+ //#endregion
215
+ export { y as i, O as n, v as r, k as t };