@achyutlabsau/vue-payment-gateway 1.0.0-alpha.2 → 1.0.0-alpha.4

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,193 +1,193 @@
1
- # Vue Payment Gateway
2
-
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) | `useAnz` (`/anz`) |
21
- | **Valpay (Adyen)** | Cloud Terminal API | `useValpay` (`/valpay`) |
22
-
23
- ## Installation
24
-
25
- ```bash
26
- npm install @achyutlabsau/vue-payment-gateway
27
- ```
28
-
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.
31
-
32
- ## Plugin Initialization
33
-
34
- ```ts
35
- import { createApp } from "vue";
36
- import VuePaymentGateway from "@achyutlabsau/vue-payment-gateway";
37
-
38
- const app = createApp(App);
39
-
40
- app.use(VuePaymentGateway, {
41
- currencyCode: "AUD",
42
- productName: "Pratham Respos", // Name of your product
43
- productVersion: "3.3.0", // Version of your product
44
- productVendorName: "Achyutlabs", // Name of the product vendor
45
- posId: "unique-pos-id", // Unique identifier for the POS system
46
- posRegisterId: "pos-register-id", // Unique identifier for the POS register
47
- posRegisterName: "register-name", // Name of the POS register
48
- posBusinessName: "business name", // Name of the business using the POS system
49
- tyroApiKey: "tyro-api-key", // API key for Tyro integration
50
- environment: "development", // "development" | "production"
51
- onReceiptPrint: (receipt, type) => {
52
- // MX51 SPI only; other providers return receipts on the result — see docs/features/receipts.md
53
- },
54
- });
55
-
56
- app.mount("#app");
57
- ```
58
-
59
- > Only set the credentials for the providers you actually use — see the [Install Options Reference](docs/installation.md#install-options-reference).
60
-
61
- ## Using the Payment Gateway
62
-
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, Valpay and ANZ have converged on a shared `PaymentTerminal`
66
- contract (`pair` / `unpair` / `isPaired` / `purchase` / `refund`); Tyro, Linkly and MX51 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.
69
-
70
- ### SmartPay, Till Payments, Valpay (shared contract)
71
-
72
- ```ts
73
- import { useSmartPay } from "@achyutlabsau/vue-payment-gateway/smartpay";
74
-
75
- const smartpay = useSmartPay();
76
-
77
- await smartpay.pair({ pairingCode: "123456" });
78
- smartpay.isPaired(); // boolean
79
-
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
82
-
83
- await smartpay.refund(1000);
84
- smartpay.unpair();
85
- ```
86
-
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 })`.
90
-
91
- ### Tyro
92
-
93
- ```ts
94
- import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
95
-
96
- const tyro = useTyro();
97
-
98
- await tyro.pairTyro(merchantId, terminalId);
99
-
100
- const res = await tyro.initiateTyroPurchase({ integratedReceipt: true, amount: "1000" }, receiptCallback);
101
- // res.result is a TyroTransactionStatus, e.g. "APPROVED"
102
-
103
- await tyro.initiateTyroRefund({ integratedReceipt: true, amount: "1000" }, receiptCallback);
104
- ```
105
-
106
- ### Linkly
107
-
108
- ```ts
109
- import { useLinkly, ReceiptAutoPrint } from "@achyutlabsau/vue-payment-gateway/linkly";
110
-
111
- const linkly = useLinkly();
112
-
113
- await linkly.pairPinpad({ username, password, pairCode: "123456" });
114
-
115
- const res = await linkly.initiatePurchase({
116
- AmtPurchase: 1000,
117
- ReceiptAutoPrint: ReceiptAutoPrint.ReturnToPOS,
118
- });
119
-
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
- ```
127
-
128
- ### MX51 SPI
129
-
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).
133
-
134
- ### ANZ (Worldline)
135
-
136
- ANZ implements the shared contract plus `settle()` for the daily closing. Worldline's TimAPI SDK ships with the
137
- package — pass it through the `anz` install option (see [ANZ](docs/gateways/anz.md#setup)):
138
-
139
- ```ts
140
- import { useAnz } from "@achyutlabsau/vue-payment-gateway/anz";
141
-
142
- const anz = useAnz();
143
- const res = await anz.purchase(1000); // cents → PaymentResult
144
- await anz.refund(1000); // unreferenced (standalone) refund
145
- await anz.refund(0, { originalTransactionId: res.transactionId! }); // referenced (linked) refund
146
- await anz.settle(); // daily closing
147
- ```
148
-
149
- ## Checking Pairing Status
150
-
151
- ```ts
152
- import { isPaymentGatewayConnected, PaymentGateways } from "@achyutlabsau/vue-payment-gateway";
153
-
154
- isPaymentGatewayConnected(PaymentGateways.Linkly); // reads linkly.pairConfig from localStorage
155
- ```
156
-
157
- ## Logging
158
-
159
- Every provider logs through one shared, IndexedDB-backed logger (`./logger` subpath) — persistent across reloads,
160
- attributable to a gateway, correlated by transaction, and with secrets/PANs redacted centrally. See
161
- [Logging](docs/features/logging.md) for configuration, the `LogViewer` component, and how to query/export logs.
162
-
163
- ## Shared Utilities
164
-
165
- ```ts
166
- import {
167
- toCents,
168
- toMajorUnits,
169
- formatCents,
170
- maskPan,
171
- normalizeCardScheme,
172
- CardScheme,
173
- } from "@achyutlabsau/vue-payment-gateway/utils";
174
- ```
175
-
176
- Available from the root entry too, alongside `generateTransactionId()`, `setState()`, and `setCurrencyCode()`.
177
-
178
- ## Troubleshooting
179
-
180
- - **"Plugin not initialized" errors** — provider composables throw if called before `app.use(VuePaymentGateway, …)`
181
- has run. Call `use*` inside components/handlers, not at module load time.
182
- - **Environment issues** — make sure `environment` is set correctly (`"development"` or `"production"`); it selects
183
- each provider's SDK/endpoint URLs.
184
- - **Invalid API key** — confirm the provider's API key/merchant credentials are set in the plugin options.
185
- - **Diagnosing a failed transaction** — check the [Logging](docs/features/logging.md) guide; every gateway's request,
186
- response and retry history is queryable through `logger.query()` or the `LogViewer` component.
187
-
188
- ## Additional Resources
189
-
190
- - [Full documentation](docs/index.md)
191
- - [Changelog](CHANGELOG.md)
192
- - [Migration guide (pre-1.0 → v1)](docs/migration-v1.md)
193
- - [Achyutlabs](https://achyutlabs.com/)
1
+ # Vue Payment Gateway
2
+
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) | `useAnz` (`/anz`) |
21
+ | **Valpay (Adyen)** | Cloud Terminal API | `useValpay` (`/valpay`) |
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install @achyutlabsau/vue-payment-gateway
27
+ ```
28
+
29
+ Peer dependencies your app must also install: `@vueuse/core`, `axios`, `dayjs`, `dexie`, `quasar`,
30
+ `uuid`, `vue`. See [Installation](docs/installation.md) for versions and full setup.
31
+
32
+ ## Plugin Initialization
33
+
34
+ ```ts
35
+ import { createApp } from "vue";
36
+ import VuePaymentGateway from "@achyutlabsau/vue-payment-gateway";
37
+
38
+ const app = createApp(App);
39
+
40
+ app.use(VuePaymentGateway, {
41
+ currencyCode: "AUD",
42
+ productName: "Pratham Respos", // Name of your product
43
+ productVersion: "3.3.0", // Version of your product
44
+ productVendorName: "Achyutlabs", // Name of the product vendor
45
+ posId: "unique-pos-id", // Unique identifier for the POS system
46
+ posRegisterId: "pos-register-id", // Unique identifier for the POS register
47
+ posRegisterName: "register-name", // Name of the POS register
48
+ posBusinessName: "business name", // Name of the business using the POS system
49
+ tyroApiKey: "tyro-api-key", // API key for Tyro integration
50
+ environment: "development", // "development" | "production"
51
+ onReceiptPrint: (receipt, type) => {
52
+ // MX51 SPI only; other providers return receipts on the result — see docs/features/receipts.md
53
+ },
54
+ });
55
+
56
+ app.mount("#app");
57
+ ```
58
+
59
+ > Only set the credentials for the providers you actually use — see the [Install Options Reference](docs/installation.md#install-options-reference).
60
+
61
+ ## Using the Payment Gateway
62
+
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, Valpay and ANZ have converged on a shared `PaymentTerminal`
66
+ contract (`pair` / `unpair` / `isPaired` / `purchase` / `refund`); Tyro, Linkly and MX51 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.
69
+
70
+ ### SmartPay, Till Payments, Valpay (shared contract)
71
+
72
+ ```ts
73
+ import { useSmartPay } from "@achyutlabsau/vue-payment-gateway/smartpay";
74
+
75
+ const smartpay = useSmartPay();
76
+
77
+ await smartpay.pair({ pairingCode: "123456" });
78
+ smartpay.isPaired(); // boolean
79
+
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
82
+
83
+ await smartpay.refund(1000);
84
+ smartpay.unpair();
85
+ ```
86
+
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 })`.
90
+
91
+ ### Tyro
92
+
93
+ ```ts
94
+ import { useTyro } from "@achyutlabsau/vue-payment-gateway/tyro";
95
+
96
+ const tyro = useTyro();
97
+
98
+ await tyro.pairTyro(merchantId, terminalId);
99
+
100
+ const res = await tyro.initiateTyroPurchase({ integratedReceipt: true, amount: "1000" }, receiptCallback);
101
+ // res.result is a TyroTransactionStatus, e.g. "APPROVED"
102
+
103
+ await tyro.initiateTyroRefund({ integratedReceipt: true, amount: "1000" }, receiptCallback);
104
+ ```
105
+
106
+ ### Linkly
107
+
108
+ ```ts
109
+ import { useLinkly, ReceiptAutoPrint } from "@achyutlabsau/vue-payment-gateway/linkly";
110
+
111
+ const linkly = useLinkly();
112
+
113
+ await linkly.pairPinpad({ username, password, pairCode: "123456" });
114
+
115
+ const res = await linkly.initiatePurchase({
116
+ AmtPurchase: 1000,
117
+ ReceiptAutoPrint: ReceiptAutoPrint.ReturnToPOS,
118
+ });
119
+
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
+ ```
127
+
128
+ ### MX51 SPI
129
+
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).
133
+
134
+ ### ANZ (Worldline)
135
+
136
+ ANZ implements the shared contract plus `settle()` for the daily closing. Worldline's TimAPI SDK ships with the
137
+ package — pass it through the `anz` install option (see [ANZ](docs/gateways/anz.md#setup)):
138
+
139
+ ```ts
140
+ import { useAnz } from "@achyutlabsau/vue-payment-gateway/anz";
141
+
142
+ const anz = useAnz();
143
+ const res = await anz.purchase(1000); // cents → PaymentResult
144
+ await anz.refund(1000); // unreferenced (standalone) refund
145
+ await anz.refund(0, { originalTransactionId: res.transactionId! }); // referenced (linked) refund
146
+ await anz.settle(); // daily closing
147
+ ```
148
+
149
+ ## Checking Pairing Status
150
+
151
+ ```ts
152
+ import { isPaymentGatewayConnected, PaymentGateways } from "@achyutlabsau/vue-payment-gateway";
153
+
154
+ isPaymentGatewayConnected(PaymentGateways.Linkly); // reads linkly.pairConfig from localStorage
155
+ ```
156
+
157
+ ## Logging
158
+
159
+ Every provider logs through one shared, IndexedDB-backed logger (`./logger` subpath) — persistent across reloads,
160
+ attributable to a gateway, correlated by transaction, and with secrets/PANs redacted centrally. See
161
+ [Logging](docs/features/logging.md) for configuration, the `LogViewer` component, and how to query/export logs.
162
+
163
+ ## Shared Utilities
164
+
165
+ ```ts
166
+ import {
167
+ toCents,
168
+ toMajorUnits,
169
+ formatCents,
170
+ maskPan,
171
+ normalizeCardScheme,
172
+ CardScheme,
173
+ } from "@achyutlabsau/vue-payment-gateway/utils";
174
+ ```
175
+
176
+ Available from the root entry too, alongside `generateTransactionId()`, `setState()`, and `setCurrencyCode()`.
177
+
178
+ ## Troubleshooting
179
+
180
+ - **"Plugin not initialized" errors** — provider composables throw if called before `app.use(VuePaymentGateway, …)`
181
+ has run. Call `use*` inside components/handlers, not at module load time.
182
+ - **Environment issues** — make sure `environment` is set correctly (`"development"` or `"production"`); it selects
183
+ each provider's SDK/endpoint URLs.
184
+ - **Invalid API key** — confirm the provider's API key/merchant credentials are set in the plugin options.
185
+ - **Diagnosing a failed transaction** — check the [Logging](docs/features/logging.md) guide; every gateway's request,
186
+ response and retry history is queryable through `logger.query()` or the `LogViewer` component.
187
+
188
+ ## Additional Resources
189
+
190
+ - [Full documentation](docs/index.md)
191
+ - [Changelog](CHANGELOG.md)
192
+ - [Migration guide (pre-1.0 → v1)](docs/migration-v1.md)
193
+ - [Achyutlabs](https://achyutlabs.com/)
@@ -1,4 +1,4 @@
1
- import { _ as e, d as t, g as n, l as r, p as i, r as a, u as o } from "./logger-C4IV3krr.js";
1
+ import { _ as e, d as t, f as n, m as r, r as i, u as a, v as o } from "./logger-4FM6sy9j.js";
2
2
  import { createBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, openBlock as f, unref as p, withCtx as m } from "vue";
3
3
  //#region src/components/PairInstructions.vue?vue&type=script&setup=true&lang.ts
4
4
  var h = { class: "gap-4 flex flex-nowrap items-start" }, g = {
@@ -9,22 +9,22 @@ var h = { class: "gap-4 flex flex-nowrap items-start" }, g = {
9
9
  props: { steps: {} },
10
10
  emits: ["next"],
11
11
  setup(d) {
12
- return (_, v) => (f(), s(p(r), null, {
13
- footer: m(() => [u(p(t), {
12
+ return (_, v) => (f(), s(p(a), null, {
13
+ footer: m(() => [u(p(n), {
14
14
  label: "Continue",
15
- "icon-right": p(n),
15
+ "icon-right": p(e),
16
16
  onClick: v[0] ||= (e) => _.$emit("next")
17
17
  }, null, 8, ["icon-right"])]),
18
18
  default: m(() => [
19
- c("div", h, [c("span", g, [u(p(i), {
20
- name: p(e),
19
+ c("div", h, [c("span", g, [u(p(r), {
20
+ name: p(o),
21
21
  size: 26
22
22
  }, null, 8, ["name"])]), v[1] ||= c("div", { class: "min-w-0" }, [c("h2", { class: "text-lg font-semibold text-gray-900 dark:text-white" }, "Terminal setup"), c("p", { class: "mt-0.5 text-sm text-gray-500 dark:text-gray-400" }, " Follow these steps on the terminal, then continue to enter its details. ")], -1)]),
23
- u(p(a), {
23
+ u(p(i), {
24
24
  steps: d.steps,
25
25
  class: "mt-5"
26
26
  }, null, 8, ["steps"]),
27
- u(p(o), {
27
+ u(p(t), {
28
28
  tone: "warning",
29
29
  title: "Before you start",
30
30
  class: "mt-5"
@@ -1,4 +1,4 @@
1
- import { f as e, i as t, l as n } from "./logger-C4IV3krr.js";
1
+ import { i as e, p as t, u as n } from "./logger-4FM6sy9j.js";
2
2
  import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createVNode as l, defineComponent as u, openBlock as d, renderList as f, renderSlot as p, toDisplayString as m, unref as h, withCtx as g } from "vue";
3
3
  //#region src/components/PairedTerminal.vue?vue&type=script&setup=true&lang.ts
4
4
  var _ = { class: "gap-4 flex flex-nowrap items-start" }, v = { class: "min-w-0 flex-1" }, y = { class: "gap-2 flex flex-wrap items-center" }, b = { class: "text-lg font-semibold text-gray-900 dark:text-white" }, x = {
@@ -33,11 +33,11 @@ var _ = { class: "gap-4 flex flex-nowrap items-start" }, v = { class: "min-w-0 f
33
33
  }), e;
34
34
  });
35
35
  return (i, E) => (d(), a(h(n), null, {
36
- default: g(() => [c("div", _, [l(h(t), {
36
+ default: g(() => [c("div", _, [l(h(e), {
37
37
  status: "success",
38
38
  size: "lg"
39
39
  }), c("div", v, [
40
- c("div", y, [c("h2", b, m(u.title), 1), l(h(e), {
40
+ c("div", y, [c("h2", b, m(u.title), 1), l(h(t), {
41
41
  tone: "success",
42
42
  dot: "",
43
43
  label: "Paired"