@achyutlabsau/vue-payment-gateway 0.2.2 → 0.2.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 +141 -141
- package/dist/event-Zm-ArxiV.js +125 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +8 -1
- package/dist/linkly.js +1 -1
- package/dist/mx51.d.ts +14 -3
- package/dist/mx51.js +115 -195
- package/dist/smartpay.js +1 -1
- package/dist/{state-DdRk6ppP.js → state-D014QcxX.js} +3 -1
- package/dist/tyro.js +1 -1
- package/package.json +1 -1
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.
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionPlugin } from 'vue';
|
|
2
2
|
|
|
3
3
|
declare const _default: {
|
|
4
|
-
install:
|
|
4
|
+
install: FunctionPlugin<InstallOptions>;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
7
|
|
|
@@ -32,6 +32,7 @@ declare interface POSConfig {
|
|
|
32
32
|
tyroApiKey: string;
|
|
33
33
|
tillPaymentApiKey: string;
|
|
34
34
|
tillPaymentMerchantId: string;
|
|
35
|
+
mx51DeviceApiKey: string;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { s as setState, a as setEnvironment, i as isPluginInitialized } from "./state-
|
|
1
|
+
import { s as setState, a as setEnvironment, i as isPluginInitialized } from "./state-D014QcxX.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";
|
|
5
9
|
import { g } from "./index-C8vc_75e.js";
|
|
6
10
|
const install = (_app, options) => {
|
|
7
11
|
setState(options);
|
|
8
12
|
options.environment && setEnvironment(options.environment);
|
|
9
13
|
const tyroConfig = options.environment === "production" ? TYRO_CONSTANTS.URLS.PRODUCTION : TYRO_CONSTANTS.URLS.DEVELOPMENT;
|
|
10
14
|
useScriptTag(tyroConfig.SDK_URL);
|
|
15
|
+
spi.SetPosInfo(options.productVendorName, options.productVersion);
|
|
16
|
+
spi.SetDeviceApiKey(options.mx51DeviceApiKey);
|
|
17
|
+
spi.Start();
|
|
11
18
|
isPluginInitialized.value = true;
|
|
12
19
|
};
|
|
13
20
|
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-
|
|
9
|
+
import { b as state, e as environment } from "./state-D014QcxX.js";
|
|
10
10
|
const LINKLY_CONSTANTS = {
|
|
11
11
|
PATHS: {
|
|
12
12
|
TRANSACTION: "transaction",
|
package/dist/mx51.d.ts
CHANGED
|
@@ -4,6 +4,13 @@ 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
|
+
|
|
7
14
|
/**
|
|
8
15
|
* Attempts to cancel a transaction
|
|
9
16
|
* Be subscribed to TxFlowStateChanged event to see how it goes
|
|
@@ -30,7 +37,7 @@ export declare const PairMX51: DefineComponent< {}, {}, {}, {}, {}, Component
|
|
|
30
37
|
* Be subscribed to TxFlowStateChanged event to get updates on the process
|
|
31
38
|
* Tip and cashout are not allowed simultaneously
|
|
32
39
|
**/
|
|
33
|
-
export declare function purchase({ purchaseAmount, tipAmount, cashoutAmount, promptForCashout, surchargeAmount
|
|
40
|
+
export declare function purchase({ purchaseAmount, tipAmount, cashoutAmount, promptForCashout, surchargeAmount }: PurchaseOptions): void;
|
|
34
41
|
|
|
35
42
|
declare interface PurchaseOptions {
|
|
36
43
|
/**
|
|
@@ -95,8 +102,12 @@ export declare function settlementEnquiry(): void;
|
|
|
95
102
|
export declare const spi: Spi;
|
|
96
103
|
|
|
97
104
|
export declare const TransactionDialog: DefineComponent< {}, {
|
|
98
|
-
showDialog: (amount: number) => void;
|
|
99
|
-
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
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>;
|
|
100
111
|
|
|
101
112
|
export { }
|
|
102
113
|
|
package/dist/mx51.js
CHANGED
|
@@ -1,137 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as log, s as spi, g as getPairingData, a as getTenants, r as receiptOptions } from "./event-Zm-ArxiV.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";
|
|
5
7
|
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
|
-
};
|
|
133
8
|
function pair(pairingInput) {
|
|
134
|
-
localStorage.setItem("pairingData", JSON.stringify(pairingInput));
|
|
135
9
|
spi.SetTenantCode(pairingInput.tenantCode);
|
|
136
10
|
spi.SetEftposAddress(pairingInput.eftposAddress);
|
|
137
11
|
spi.SetSerialNumber(pairingInput.serialNumber);
|
|
@@ -168,19 +42,22 @@ const _hoisted_5$1 = {
|
|
|
168
42
|
key: 2,
|
|
169
43
|
class: "flex items-center gap-1 font-semibold"
|
|
170
44
|
};
|
|
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" };
|
|
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" };
|
|
173
47
|
const _hoisted_8 = { class: "text-center font-semibold text-gray-500 uppercase" };
|
|
174
48
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
175
49
|
__name: "PairMX51",
|
|
176
50
|
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
|
+
}
|
|
177
56
|
const tenants = ref([]);
|
|
178
57
|
const model = ref(false);
|
|
179
58
|
const pairStatus = ref(spi._currentStatus);
|
|
180
59
|
const isPaired = computed(() => {
|
|
181
|
-
return [SpiStatus.PairedConnected, SpiStatus.PairedConnecting].includes(
|
|
182
|
-
pairStatus.value
|
|
183
|
-
);
|
|
60
|
+
return [SpiStatus.PairedConnected, SpiStatus.PairedConnecting].includes(pairStatus.value);
|
|
184
61
|
});
|
|
185
62
|
const pairForm = ref({
|
|
186
63
|
posId: "",
|
|
@@ -207,7 +84,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
207
84
|
});
|
|
208
85
|
};
|
|
209
86
|
onMounted(async () => {
|
|
210
|
-
const res = await getTenants();
|
|
87
|
+
const res = await getTenants(state.productVendorName, state.mx51DeviceApiKey);
|
|
211
88
|
if (res) {
|
|
212
89
|
tenants.value = res;
|
|
213
90
|
}
|
|
@@ -216,19 +93,23 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
216
93
|
pairStatus.value = e.detail;
|
|
217
94
|
});
|
|
218
95
|
useEventListener(document, "PairingFlowStateChanged", (e) => {
|
|
219
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
96
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
220
97
|
model.value = true;
|
|
221
98
|
pairInfo.value.message = (_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.Message;
|
|
222
99
|
pairInfo.value.confirmationCode = (_b = e == null ? void 0 : e.detail) == null ? void 0 : _b.ConfirmationCode;
|
|
223
|
-
if ((_c = e == null ? void 0 : e.detail) == null ? void 0 : _c.Finished) {
|
|
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) {
|
|
224
105
|
pairInfo.value.state = "FINISHED";
|
|
225
106
|
return;
|
|
226
107
|
}
|
|
227
|
-
if (((
|
|
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)) {
|
|
228
109
|
pairInfo.value.state = "CONFIRMATION";
|
|
229
110
|
return;
|
|
230
111
|
}
|
|
231
|
-
if (!((
|
|
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)) {
|
|
232
113
|
pairInfo.value.state = "INPROGRESS";
|
|
233
114
|
return;
|
|
234
115
|
}
|
|
@@ -241,7 +122,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
241
122
|
class: "space-y-4"
|
|
242
123
|
}, {
|
|
243
124
|
default: withCtx(() => [
|
|
244
|
-
_cache[
|
|
125
|
+
_cache[10] || (_cache[10] = createElementVNode("div", { class: "font-sans text-lg font-semibold text-gray-600" }, "MX 51 - SPI Terminal Pairing", -1)),
|
|
245
126
|
createVNode(unref(QSelect), {
|
|
246
127
|
disable: isPaired.value,
|
|
247
128
|
dense: "",
|
|
@@ -265,7 +146,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
265
146
|
modelValue: pairForm.value.posId,
|
|
266
147
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => pairForm.value.posId = $event),
|
|
267
148
|
label: "POS ID",
|
|
268
|
-
rules: [
|
|
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
|
+
]
|
|
269
154
|
}, null, 8, ["disable", "modelValue", "rules"]),
|
|
270
155
|
createVNode(unref(QInput), {
|
|
271
156
|
disable: isPaired.value,
|
|
@@ -284,8 +169,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
284
169
|
modelValue: pairForm.value.eftposAddress,
|
|
285
170
|
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => pairForm.value.eftposAddress = $event),
|
|
286
171
|
label: "Eftpos Address",
|
|
287
|
-
rules: [
|
|
288
|
-
|
|
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"
|
|
289
177
|
}, null, 8, ["disable", "modelValue", "rules"]),
|
|
290
178
|
createElementVNode("div", null, [
|
|
291
179
|
createVNode(unref(QCheckbox), {
|
|
@@ -296,36 +184,29 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
296
184
|
dense: ""
|
|
297
185
|
}, null, 8, ["modelValue", "disable"])
|
|
298
186
|
]),
|
|
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"]),
|
|
306
187
|
createElementVNode("div", _hoisted_2$1, [
|
|
307
|
-
_cache[
|
|
188
|
+
_cache[9] || (_cache[9] = createElementVNode("div", { class: "text-sm font-medium text-gray-500" }, "Pairing Status", -1)),
|
|
308
189
|
pairStatus.value === unref(SpiStatus).PairedConnected ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
|
|
309
190
|
createVNode(unref(QIcon), {
|
|
310
191
|
name: "check_circle",
|
|
311
192
|
size: "xs",
|
|
312
193
|
color: "green"
|
|
313
194
|
}),
|
|
314
|
-
_cache[
|
|
195
|
+
_cache[6] || (_cache[6] = createElementVNode("div", null, "Paired and Connected", -1))
|
|
315
196
|
])) : pairStatus.value === unref(SpiStatus).Unpaired ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
|
|
316
197
|
createVNode(unref(QIcon), {
|
|
317
198
|
name: "cancel",
|
|
318
199
|
size: "xs",
|
|
319
200
|
color: "red"
|
|
320
201
|
}),
|
|
321
|
-
_cache[
|
|
202
|
+
_cache[7] || (_cache[7] = createElementVNode("div", null, "Unpaired", -1))
|
|
322
203
|
])) : pairStatus.value === unref(SpiStatus).PairedConnecting ? (openBlock(), createElementBlock("div", _hoisted_5$1, [
|
|
323
204
|
createVNode(unref(QIcon), {
|
|
324
205
|
name: "check_circle",
|
|
325
206
|
size: "xs",
|
|
326
207
|
color: "yellow-8"
|
|
327
208
|
}),
|
|
328
|
-
_cache[
|
|
209
|
+
_cache[8] || (_cache[8] = createElementVNode("div", null, "Paired and trying to connect", -1))
|
|
329
210
|
])) : createCommentVNode("", true)
|
|
330
211
|
]),
|
|
331
212
|
!isPaired.value ? (openBlock(), createBlock(unref(QBtn), {
|
|
@@ -354,7 +235,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
354
235
|
}),
|
|
355
236
|
createVNode(unref(QDialog), {
|
|
356
237
|
modelValue: model.value,
|
|
357
|
-
"onUpdate:modelValue": _cache[
|
|
238
|
+
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => model.value = $event),
|
|
358
239
|
persistent: ""
|
|
359
240
|
}, {
|
|
360
241
|
default: withCtx(() => [
|
|
@@ -362,7 +243,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
362
243
|
default: withCtx(() => [
|
|
363
244
|
pairInfo.value.state === "INPROGRESS" ? (openBlock(), createBlock(unref(QCardSection), { key: 0 }, {
|
|
364
245
|
default: withCtx(() => [
|
|
365
|
-
createElementVNode("div", _hoisted_6, toDisplayString(pairInfo.value.message), 1),
|
|
246
|
+
createElementVNode("div", _hoisted_6$1, toDisplayString(pairInfo.value.message), 1),
|
|
366
247
|
createVNode(unref(QBtn), {
|
|
367
248
|
label: "Cancel",
|
|
368
249
|
onClick: unref(cancelPairing),
|
|
@@ -377,9 +258,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
377
258
|
_: 1
|
|
378
259
|
})) : pairInfo.value.state === "CONFIRMATION" ? (openBlock(), createBlock(unref(QCardSection), { key: 1 }, {
|
|
379
260
|
default: withCtx(() => [
|
|
380
|
-
_cache[
|
|
381
|
-
createElementVNode("div", _hoisted_7, toDisplayString(pairInfo.value.confirmationCode), 1),
|
|
382
|
-
_cache[
|
|
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))
|
|
383
264
|
]),
|
|
384
265
|
_: 1
|
|
385
266
|
})) : pairInfo.value.state === "FINISHED" ? (openBlock(), createBlock(unref(QCardSection), { key: 2 }, {
|
|
@@ -412,13 +293,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
412
293
|
function posRefIdGenerator(type) {
|
|
413
294
|
return (/* @__PURE__ */ new Date()).toISOString() + "-" + type + v4();
|
|
414
295
|
}
|
|
415
|
-
function purchase({
|
|
416
|
-
purchaseAmount,
|
|
417
|
-
tipAmount,
|
|
418
|
-
cashoutAmount,
|
|
419
|
-
promptForCashout,
|
|
420
|
-
surchargeAmount
|
|
421
|
-
}) {
|
|
296
|
+
function purchase({ purchaseAmount, tipAmount, cashoutAmount, promptForCashout, surchargeAmount }) {
|
|
422
297
|
spi.AckFlowEndedAndBackToIdle();
|
|
423
298
|
spi.InitiatePurchaseTxV2(
|
|
424
299
|
posRefIdGenerator("purchase"),
|
|
@@ -460,41 +335,57 @@ function settlement() {
|
|
|
460
335
|
}
|
|
461
336
|
function settlementEnquiry() {
|
|
462
337
|
spi.AckFlowEndedAndBackToIdle();
|
|
463
|
-
spi.InitiateSettlementEnquiry(
|
|
464
|
-
posRefIdGenerator("settlementEnquiry"),
|
|
465
|
-
receiptOptions
|
|
466
|
-
);
|
|
338
|
+
spi.InitiateSettlementEnquiry(posRefIdGenerator("settlementEnquiry"), receiptOptions);
|
|
467
339
|
}
|
|
468
|
-
function
|
|
469
|
-
|
|
470
|
-
spi.AckFlowEndedAndBackToIdle();
|
|
471
|
-
} else {
|
|
472
|
-
spi.AckFlowEndedAndBackToIdle();
|
|
473
|
-
}
|
|
340
|
+
function acceptSignature(signatureConfirmed) {
|
|
341
|
+
spi.AcceptSignature(signatureConfirmed);
|
|
474
342
|
}
|
|
475
343
|
const _hoisted_1 = { class: "text-center font-semibold text-gray-500 uppercase" };
|
|
476
344
|
const _hoisted_2 = { class: "text-center font-semibold text-gray-500" };
|
|
477
345
|
const _hoisted_3 = { class: "text-center font-semibold text-gray-500" };
|
|
478
346
|
const _hoisted_4 = { class: "grid grid-cols-2 gap-3" };
|
|
479
347
|
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" };
|
|
480
350
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
481
351
|
__name: "TransactionDialog",
|
|
482
|
-
|
|
352
|
+
emits: ["transaction-success"],
|
|
353
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
354
|
+
const emit = __emit;
|
|
483
355
|
const pairInfo = ref({
|
|
484
356
|
state: "INPROGRESS",
|
|
485
|
-
message: "Processing"
|
|
357
|
+
message: "Processing",
|
|
358
|
+
transactionType: TransactionType.Purchase
|
|
486
359
|
});
|
|
487
360
|
const model = ref(false);
|
|
488
361
|
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
|
+
}
|
|
489
373
|
document.addEventListener("TxFlowStateChanged", (e) => {
|
|
374
|
+
var _a, _b, _c;
|
|
490
375
|
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);
|
|
491
379
|
if (e.detail.AttemptingToCancel) {
|
|
492
380
|
pairInfo.value.state = "AWAITING_CANCELLATION";
|
|
493
381
|
pairInfo.value.message = "Please wait";
|
|
494
382
|
}
|
|
495
|
-
if (e.detail.AwaitingSignatureCheck)
|
|
496
|
-
|
|
383
|
+
if (e.detail.AwaitingSignatureCheck) {
|
|
384
|
+
pairInfo.value.state = "AWAITING_SIGNATURE_CHECK";
|
|
385
|
+
} else if (e.detail.AwaitingPhoneForAuth) ;
|
|
497
386
|
else if (e.detail.Finished) {
|
|
387
|
+
localStorage.removeItem("mx51.posRefId");
|
|
388
|
+
localStorage.removeItem("mx51.txType");
|
|
498
389
|
switch (e.detail.Success) {
|
|
499
390
|
case SuccessState.Success:
|
|
500
391
|
pairInfo.value.state = "SUCCESS";
|
|
@@ -506,8 +397,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
506
397
|
}
|
|
507
398
|
break;
|
|
508
399
|
case SuccessState.Failed:
|
|
509
|
-
|
|
510
|
-
pairInfo.value.message = ResponseData.error_detail ?? "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;
|
|
511
401
|
pairInfo.value.state = "FAILED";
|
|
512
402
|
break;
|
|
513
403
|
case SuccessState.Unknown:
|
|
@@ -519,18 +409,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
519
409
|
spi.TransactionUpdateMessage = (e) => {
|
|
520
410
|
pairInfo.value.message = e.Data.display_message_text;
|
|
521
411
|
};
|
|
522
|
-
const showDialog = (amount) => {
|
|
412
|
+
const showDialog = (amount, type) => {
|
|
523
413
|
transactionAmount.value = amount;
|
|
524
414
|
pairInfo.value.state = "INPROGRESS";
|
|
525
415
|
pairInfo.value.message = "Processing";
|
|
526
416
|
model.value = true;
|
|
417
|
+
pairInfo.value.transactionType = type ?? TransactionType.Purchase;
|
|
527
418
|
};
|
|
528
419
|
__expose({ showDialog });
|
|
529
420
|
return (_ctx, _cache) => {
|
|
530
421
|
const _directive_close_popup = resolveDirective("close-popup");
|
|
531
422
|
return openBlock(), createBlock(unref(QDialog), {
|
|
532
423
|
modelValue: model.value,
|
|
533
|
-
"onUpdate:modelValue": _cache[
|
|
424
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => model.value = $event),
|
|
534
425
|
persistent: ""
|
|
535
426
|
}, {
|
|
536
427
|
default: withCtx(() => [
|
|
@@ -538,7 +429,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
538
429
|
default: withCtx(() => [
|
|
539
430
|
pairInfo.value.state === "INPROGRESS" ? (openBlock(), createBlock(unref(QCardSection), { key: 0 }, {
|
|
540
431
|
default: withCtx(() => [
|
|
541
|
-
createElementVNode("div", _hoisted_1, "
|
|
432
|
+
createElementVNode("div", _hoisted_1, toDisplayString(pairInfo.value.transactionType) + " of $" + toDisplayString(transactionAmount.value) + " in progress... ", 1),
|
|
542
433
|
createElementVNode("div", _hoisted_2, toDisplayString(pairInfo.value.message), 1),
|
|
543
434
|
createVNode(unref(QBtn), {
|
|
544
435
|
label: "Cancel",
|
|
@@ -554,19 +445,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
554
445
|
_: 1
|
|
555
446
|
})) : pairInfo.value.state === "AWAITING_CANCELLATION" ? (openBlock(), createBlock(unref(QCardSection), { key: 1 }, {
|
|
556
447
|
default: withCtx(() => [
|
|
557
|
-
_cache[
|
|
448
|
+
_cache[5] || (_cache[5] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, "Attempting to cancel transaction", -1)),
|
|
558
449
|
createElementVNode("div", _hoisted_3, toDisplayString(pairInfo.value.message), 1)
|
|
559
450
|
]),
|
|
560
451
|
_: 1
|
|
561
452
|
})) : pairInfo.value.state === "MANUAL_RECOVERY" ? (openBlock(), createBlock(unref(QCardSection), { key: 2 }, {
|
|
562
453
|
default: withCtx(() => [
|
|
563
|
-
_cache[
|
|
564
|
-
_cache[
|
|
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)),
|
|
565
456
|
createElementVNode("div", _hoisted_4, [
|
|
566
457
|
createVNode(unref(QBtn), {
|
|
567
458
|
label: "Yes",
|
|
568
459
|
color: "primary",
|
|
569
|
-
onClick: _cache[0] || (_cache[0] = ($event) =>
|
|
460
|
+
onClick: _cache[0] || (_cache[0] = ($event) => overrideTransaction(true)),
|
|
570
461
|
outline: "",
|
|
571
462
|
class: "!mt-6",
|
|
572
463
|
unelevated: "",
|
|
@@ -577,7 +468,35 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
577
468
|
label: "No",
|
|
578
469
|
color: "primary",
|
|
579
470
|
outline: "",
|
|
580
|
-
onClick: _cache[1] || (_cache[1] = ($event) =>
|
|
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)),
|
|
581
500
|
class: "!mt-6",
|
|
582
501
|
unelevated: "",
|
|
583
502
|
"no-caps": "",
|
|
@@ -586,9 +505,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
586
505
|
])
|
|
587
506
|
]),
|
|
588
507
|
_: 1
|
|
589
|
-
})) : pairInfo.value.state === "SUCCESS" ? (openBlock(), createBlock(unref(QCardSection), { key:
|
|
508
|
+
})) : pairInfo.value.state === "SUCCESS" ? (openBlock(), createBlock(unref(QCardSection), { key: 4 }, {
|
|
590
509
|
default: withCtx(() => [
|
|
591
|
-
_cache[
|
|
510
|
+
_cache[9] || (_cache[9] = createElementVNode("div", { class: "text-center font-semibold text-gray-500 uppercase" }, "Transaction Successful", -1)),
|
|
592
511
|
withDirectives(createVNode(unref(QBtn), {
|
|
593
512
|
label: "OK",
|
|
594
513
|
color: "primary",
|
|
@@ -602,10 +521,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
602
521
|
])
|
|
603
522
|
]),
|
|
604
523
|
_: 1
|
|
605
|
-
})) : pairInfo.value.state === "FAILED" ? (openBlock(), createBlock(unref(QCardSection), { key:
|
|
524
|
+
})) : pairInfo.value.state === "FAILED" ? (openBlock(), createBlock(unref(QCardSection), { key: 5 }, {
|
|
606
525
|
default: withCtx(() => [
|
|
607
|
-
_cache[
|
|
608
|
-
createElementVNode("div",
|
|
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),
|
|
609
528
|
withDirectives(createVNode(unref(QBtn), {
|
|
610
529
|
label: "OK",
|
|
611
530
|
color: "primary",
|
|
@@ -632,6 +551,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
632
551
|
export {
|
|
633
552
|
_sfc_main$1 as PairMX51,
|
|
634
553
|
_sfc_main as TransactionDialog,
|
|
554
|
+
acceptSignature,
|
|
635
555
|
cancelTransaction,
|
|
636
556
|
getTransaction,
|
|
637
557
|
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-
|
|
8
|
+
import { b as state, e as environment } from "./state-D014QcxX.js";
|
|
9
9
|
var TransactionOutcome = /* @__PURE__ */ ((TransactionOutcome2) => {
|
|
10
10
|
TransactionOutcome2[TransactionOutcome2["Accepted"] = 1] = "Accepted";
|
|
11
11
|
TransactionOutcome2[TransactionOutcome2["Declined"] = 2] = "Declined";
|
|
@@ -9,7 +9,8 @@ const state = reactive({
|
|
|
9
9
|
posBusinessName: "",
|
|
10
10
|
tyroApiKey: "",
|
|
11
11
|
tillPaymentApiKey: "",
|
|
12
|
-
tillPaymentMerchantId: ""
|
|
12
|
+
tillPaymentMerchantId: "",
|
|
13
|
+
mx51DeviceApiKey: ""
|
|
13
14
|
});
|
|
14
15
|
const environment = ref("production");
|
|
15
16
|
const isPluginInitialized = ref(false);
|
|
@@ -24,6 +25,7 @@ const setState = (options) => {
|
|
|
24
25
|
options.tyroApiKey && (state.tyroApiKey = options.tyroApiKey);
|
|
25
26
|
options.tillPaymentApiKey && (state.tillPaymentApiKey = options.tillPaymentApiKey);
|
|
26
27
|
options.tillPaymentMerchantId && (state.tillPaymentMerchantId = options.tillPaymentMerchantId);
|
|
28
|
+
options.mx51DeviceApiKey && (state.mx51DeviceApiKey = options.mx51DeviceApiKey);
|
|
27
29
|
};
|
|
28
30
|
const setEnvironment = (env) => environment.value = env;
|
|
29
31
|
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-
|
|
2
|
+
import { c as checkPluginInitialized, e as environment, b as state } from "./state-D014QcxX.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 = {
|