@achyutlabsau/vue-payment-gateway 0.0.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.
- package/README.md +141 -0
- package/dist/index-C8vc_75e.js +15 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +12 -0
- package/dist/linkly.d.ts +390 -0
- package/dist/linkly.js +9 -0
- package/dist/smartpay.d.ts +142 -0
- package/dist/smartpay.js +205 -0
- package/dist/state-0HFa2Xwz.js +36 -0
- package/dist/tyro.d.ts +147 -0
- package/dist/tyro.js +111 -0
- package/dist/useLinkly-Cj-lTWld.js +452 -0
- package/package.json +53 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export declare const DEV_SMARTPAY_API_URL = "https://api-dev.smart-connect.cloud/POS";
|
|
2
|
+
|
|
3
|
+
export declare interface PairingParams {
|
|
4
|
+
POSRegisterID: string;
|
|
5
|
+
POSRegisterName: string;
|
|
6
|
+
POSBusinessName: string;
|
|
7
|
+
POSVendorName: string;
|
|
8
|
+
"Contact Name"?: string;
|
|
9
|
+
Address?: string;
|
|
10
|
+
City?: string;
|
|
11
|
+
State?: string;
|
|
12
|
+
ZipCode?: string;
|
|
13
|
+
Email?: string;
|
|
14
|
+
Phone?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare interface PairingResponse {
|
|
18
|
+
result: "success";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare interface PollingResponseData {
|
|
22
|
+
transactionId: string;
|
|
23
|
+
transactionTimeStamp: string;
|
|
24
|
+
merchantId: string;
|
|
25
|
+
deviceId: string;
|
|
26
|
+
transactionStatus: TransactionStatus;
|
|
27
|
+
data?: TransactionData;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare const PROD_SMARTPAY_API_URL = "https://api.smart-connect.cloud/POS";
|
|
31
|
+
|
|
32
|
+
export declare enum ResultType {
|
|
33
|
+
Ok = "OK",
|
|
34
|
+
Cancelled = "CANCELLED",
|
|
35
|
+
DelayedTransaction = "DELAYED-TRANSACTION",
|
|
36
|
+
Failed = "FAILED",
|
|
37
|
+
FailedInterface = "FAILED-INTERFACE"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare class SmartPay {
|
|
41
|
+
private api;
|
|
42
|
+
constructor();
|
|
43
|
+
private getPairingParams;
|
|
44
|
+
sendPairingRequest(pairingCode: string): Promise<{
|
|
45
|
+
success: boolean;
|
|
46
|
+
message: string;
|
|
47
|
+
}>;
|
|
48
|
+
createTransaction(amount: number, transactionType: TransactionTypes): Promise<string>;
|
|
49
|
+
pollForOutcome(pollingUrl: string, delayed?: () => void): Promise<{
|
|
50
|
+
transactionOutcome: TransactionOutcome;
|
|
51
|
+
responseData: PollingResponseData;
|
|
52
|
+
}>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare interface TransactionData {
|
|
56
|
+
PosVendor: string;
|
|
57
|
+
PosRegisterID: string;
|
|
58
|
+
PosBusinessName: string;
|
|
59
|
+
AmountTotal: string;
|
|
60
|
+
DeviceID: string;
|
|
61
|
+
Function: string;
|
|
62
|
+
Merchant: string;
|
|
63
|
+
Company: string;
|
|
64
|
+
RequestId: string;
|
|
65
|
+
TransactionResult: TransactionResult;
|
|
66
|
+
Result: ResultType;
|
|
67
|
+
ResultText: string;
|
|
68
|
+
AuthId: string;
|
|
69
|
+
AcquirerRef: string;
|
|
70
|
+
TerminalRef: string;
|
|
71
|
+
CardPan: string;
|
|
72
|
+
CardType: string;
|
|
73
|
+
AccountType: string;
|
|
74
|
+
AmountSurcharge: string;
|
|
75
|
+
AmountTip: string;
|
|
76
|
+
Timestamp: string;
|
|
77
|
+
Receipt: string;
|
|
78
|
+
RequestTimestamp: string;
|
|
79
|
+
ResponseTimestamp: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare enum TransactionOutcome {
|
|
83
|
+
/**
|
|
84
|
+
* TransactionResult = "OK-ACCEPTED"
|
|
85
|
+
*/
|
|
86
|
+
Accepted = 1,
|
|
87
|
+
/**
|
|
88
|
+
* TransactionResult = "OK-DECLINED"
|
|
89
|
+
*/
|
|
90
|
+
Declined = 2,
|
|
91
|
+
/**
|
|
92
|
+
* TransactionResult = "CANCELLED", Result != "FAILED-INTERFACE"
|
|
93
|
+
*/
|
|
94
|
+
Cancelled = 3,
|
|
95
|
+
/**
|
|
96
|
+
* TransactionResult = "CANCELLED", Result = "FAILED-INTERFACE"
|
|
97
|
+
*/
|
|
98
|
+
DeviceOffline = 4,
|
|
99
|
+
/**
|
|
100
|
+
* Everything else
|
|
101
|
+
*/
|
|
102
|
+
Failed = 5
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export declare interface TransactionRequestParams {
|
|
106
|
+
POSRegisterID: string;
|
|
107
|
+
POSBusinessName: string;
|
|
108
|
+
POSVendorName: string;
|
|
109
|
+
TransactionMode: "ASYNC";
|
|
110
|
+
TransactionType: TransactionTypes;
|
|
111
|
+
AmountTotal: number;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export declare interface TransactionResponseData {
|
|
115
|
+
PollingUrl: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export declare enum TransactionResult {
|
|
119
|
+
OkAccepted = "OK-ACCEPTED",
|
|
120
|
+
OkDeclined = "OK-DECLINED",
|
|
121
|
+
OkDelayed = "OK-DELAYED",
|
|
122
|
+
Cancelled = "CANCELLED"
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export declare enum TransactionStatus {
|
|
126
|
+
Completed = "COMPLETED",
|
|
127
|
+
Pending = "PENDING"
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare enum TransactionTypes {
|
|
131
|
+
Purchase = "Card.Purchase",
|
|
132
|
+
Refund = "Card.Refund"
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export declare const useSmartPay: () => {
|
|
136
|
+
pairTerminal: (pairingCode: string) => Promise<{
|
|
137
|
+
success: boolean;
|
|
138
|
+
message: string;
|
|
139
|
+
}>;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export { }
|
package/dist/smartpay.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import axios, { HttpStatusCode, isAxiosError } from "axios";
|
|
5
|
+
import { t as timeout } from "./index-C8vc_75e.js";
|
|
6
|
+
import { c as checkPluginInitialized, e as environment, b as state } from "./state-0HFa2Xwz.js";
|
|
7
|
+
import { Dialog } from "quasar";
|
|
8
|
+
import { d as dialogDefaultOpts } from "./useLinkly-Cj-lTWld.js";
|
|
9
|
+
var TransactionOutcome = /* @__PURE__ */ ((TransactionOutcome2) => {
|
|
10
|
+
TransactionOutcome2[TransactionOutcome2["Accepted"] = 1] = "Accepted";
|
|
11
|
+
TransactionOutcome2[TransactionOutcome2["Declined"] = 2] = "Declined";
|
|
12
|
+
TransactionOutcome2[TransactionOutcome2["Cancelled"] = 3] = "Cancelled";
|
|
13
|
+
TransactionOutcome2[TransactionOutcome2["DeviceOffline"] = 4] = "DeviceOffline";
|
|
14
|
+
TransactionOutcome2[TransactionOutcome2["Failed"] = 5] = "Failed";
|
|
15
|
+
return TransactionOutcome2;
|
|
16
|
+
})(TransactionOutcome || {});
|
|
17
|
+
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
18
|
+
TransactionStatus2["Completed"] = "COMPLETED";
|
|
19
|
+
TransactionStatus2["Pending"] = "PENDING";
|
|
20
|
+
return TransactionStatus2;
|
|
21
|
+
})(TransactionStatus || {});
|
|
22
|
+
var TransactionResult = /* @__PURE__ */ ((TransactionResult2) => {
|
|
23
|
+
TransactionResult2["OkAccepted"] = "OK-ACCEPTED";
|
|
24
|
+
TransactionResult2["OkDeclined"] = "OK-DECLINED";
|
|
25
|
+
TransactionResult2["OkDelayed"] = "OK-DELAYED";
|
|
26
|
+
TransactionResult2["Cancelled"] = "CANCELLED";
|
|
27
|
+
return TransactionResult2;
|
|
28
|
+
})(TransactionResult || {});
|
|
29
|
+
var ResultType = /* @__PURE__ */ ((ResultType2) => {
|
|
30
|
+
ResultType2["Ok"] = "OK";
|
|
31
|
+
ResultType2["Cancelled"] = "CANCELLED";
|
|
32
|
+
ResultType2["DelayedTransaction"] = "DELAYED-TRANSACTION";
|
|
33
|
+
ResultType2["Failed"] = "FAILED";
|
|
34
|
+
ResultType2["FailedInterface"] = "FAILED-INTERFACE";
|
|
35
|
+
return ResultType2;
|
|
36
|
+
})(ResultType || {});
|
|
37
|
+
var TransactionTypes = /* @__PURE__ */ ((TransactionTypes2) => {
|
|
38
|
+
TransactionTypes2["Purchase"] = "Card.Purchase";
|
|
39
|
+
TransactionTypes2["Refund"] = "Card.Refund";
|
|
40
|
+
return TransactionTypes2;
|
|
41
|
+
})(TransactionTypes || {});
|
|
42
|
+
const DEV_SMARTPAY_API_URL = "https://api-dev.smart-connect.cloud/POS";
|
|
43
|
+
const PROD_SMARTPAY_API_URL = "https://api.smart-connect.cloud/POS";
|
|
44
|
+
class SmartConnectAPI {
|
|
45
|
+
constructor() {
|
|
46
|
+
__publicField(this, "api");
|
|
47
|
+
checkPluginInitialized();
|
|
48
|
+
this.api = axios.create({
|
|
49
|
+
baseURL: environment.value === "production" ? PROD_SMARTPAY_API_URL : DEV_SMARTPAY_API_URL,
|
|
50
|
+
headers: {
|
|
51
|
+
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
getPairingParams() {
|
|
56
|
+
return {
|
|
57
|
+
POSRegisterID: state.posRegisterId,
|
|
58
|
+
POSRegisterName: state.posRegisterName,
|
|
59
|
+
POSBusinessName: state.posBusinessName,
|
|
60
|
+
POSVendorName: state.productVendorName
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async sendPairingRequest(pairingCode) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
try {
|
|
66
|
+
if (!pairingCode) {
|
|
67
|
+
return { success: false, message: "A pairing code has to be supplied." };
|
|
68
|
+
}
|
|
69
|
+
const pairingEndpoint = `/Pairing/${pairingCode}`;
|
|
70
|
+
const parameters = this.getPairingParams();
|
|
71
|
+
const res = await this.api.put(pairingEndpoint, null, { params: parameters });
|
|
72
|
+
return {
|
|
73
|
+
success: res.status === HttpStatusCode.Ok,
|
|
74
|
+
message: res.status === HttpStatusCode.Ok ? "Pairing complete! Your device should now show it is paired." : "Failed to pair terminal"
|
|
75
|
+
};
|
|
76
|
+
} catch (error) {
|
|
77
|
+
const errorMessage = isAxiosError(error) ? (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error : error;
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
message: errorMessage
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async createTransaction(amount, transactionType) {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
if (!Number.isInteger(amount) || amount <= 0) {
|
|
87
|
+
throw new Error("The amount must be a positive integer.");
|
|
88
|
+
}
|
|
89
|
+
if (!transactionType) {
|
|
90
|
+
throw new Error("The transactionType must be supplied.");
|
|
91
|
+
}
|
|
92
|
+
const transactionEndpoint = "/Transaction";
|
|
93
|
+
const parameters = {
|
|
94
|
+
...this.getPairingParams(),
|
|
95
|
+
TransactionMode: "ASYNC",
|
|
96
|
+
TransactionType: transactionType,
|
|
97
|
+
AmountTotal: amount
|
|
98
|
+
};
|
|
99
|
+
try {
|
|
100
|
+
const response = await this.api.post(
|
|
101
|
+
transactionEndpoint,
|
|
102
|
+
null,
|
|
103
|
+
{ params: parameters }
|
|
104
|
+
);
|
|
105
|
+
if (response.status === HttpStatusCode.Ok && ((_b = (_a = response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.PollingUrl)) {
|
|
106
|
+
return response.data.data.PollingUrl;
|
|
107
|
+
} else {
|
|
108
|
+
throw new Error("Invalid response or missing Polling URL");
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error("Transaction creation failed:", error);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async pollForOutcome(pollingUrl, delayed) {
|
|
116
|
+
if (!pollingUrl) {
|
|
117
|
+
throw new Error("Polling URL must be provided");
|
|
118
|
+
}
|
|
119
|
+
const MAX_INTERVAL_TIME = 10 * 60 * 1e3;
|
|
120
|
+
const endTime = Date.now() + MAX_INTERVAL_TIME;
|
|
121
|
+
const poll = async () => {
|
|
122
|
+
var _a;
|
|
123
|
+
console.log("Polling for outcome:", pollingUrl);
|
|
124
|
+
try {
|
|
125
|
+
const response = await this.api.get(pollingUrl);
|
|
126
|
+
console.log("Polling response:", response.data);
|
|
127
|
+
if (response.status === HttpStatusCode.Ok && ((_a = response.data) == null ? void 0 : _a.data)) {
|
|
128
|
+
const transactionStatus = response.data.transactionStatus;
|
|
129
|
+
const transactionResult = response.data.data.TransactionResult;
|
|
130
|
+
const result = response.data.data.Result;
|
|
131
|
+
if (transactionStatus === TransactionStatus.Completed) {
|
|
132
|
+
let transactionOutcome;
|
|
133
|
+
if (transactionResult === TransactionResult.OkAccepted) {
|
|
134
|
+
transactionOutcome = TransactionOutcome.Accepted;
|
|
135
|
+
} else if (transactionResult === TransactionResult.OkDeclined) {
|
|
136
|
+
transactionOutcome = TransactionOutcome.Declined;
|
|
137
|
+
} else if (transactionResult === TransactionResult.Cancelled && result !== ResultType.FailedInterface) {
|
|
138
|
+
transactionOutcome = TransactionOutcome.Cancelled;
|
|
139
|
+
} else if (transactionResult === TransactionResult.Cancelled && result === ResultType.FailedInterface) {
|
|
140
|
+
transactionOutcome = TransactionOutcome.DeviceOffline;
|
|
141
|
+
} else {
|
|
142
|
+
transactionOutcome = TransactionOutcome.Failed;
|
|
143
|
+
}
|
|
144
|
+
return { transactionOutcome, responseData: response.data };
|
|
145
|
+
} else if (transactionStatus === TransactionStatus.Pending && transactionResult === TransactionResult.OkDelayed && delayed) {
|
|
146
|
+
delayed();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (Date.now() < endTime) {
|
|
150
|
+
await timeout();
|
|
151
|
+
return poll();
|
|
152
|
+
} else {
|
|
153
|
+
throw new Error("Polling timed out");
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error("Polling request failed:", error);
|
|
157
|
+
if (Date.now() < endTime) {
|
|
158
|
+
await timeout();
|
|
159
|
+
return poll();
|
|
160
|
+
} else {
|
|
161
|
+
throw new Error("Polling timed out");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
return poll();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const useSmartPay = () => {
|
|
169
|
+
const smartPayApi = new SmartConnectAPI();
|
|
170
|
+
const pairTerminal = async (pairingCode) => {
|
|
171
|
+
const dialog = Dialog.create({ ...dialogDefaultOpts, message: "Pairing with the terminal" });
|
|
172
|
+
try {
|
|
173
|
+
const res = await smartPayApi.sendPairingRequest(pairingCode);
|
|
174
|
+
dialog.update({
|
|
175
|
+
title: res.success ? "Success!" : "Failed!",
|
|
176
|
+
class: res.success ? "text-green-500" : "text-red-500",
|
|
177
|
+
message: "Pairing complete! Your device should now show it is paired.",
|
|
178
|
+
progress: false
|
|
179
|
+
});
|
|
180
|
+
return res;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
dialog.update({
|
|
183
|
+
title: "Failed!",
|
|
184
|
+
class: "text-red-500",
|
|
185
|
+
progress: false,
|
|
186
|
+
message: `Error! Message: ${error}`
|
|
187
|
+
});
|
|
188
|
+
return { success: false, message: `Error! Message: ${error}` };
|
|
189
|
+
} finally {
|
|
190
|
+
setTimeout(dialog.hide, 2500);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
return { pairTerminal };
|
|
194
|
+
};
|
|
195
|
+
export {
|
|
196
|
+
DEV_SMARTPAY_API_URL,
|
|
197
|
+
PROD_SMARTPAY_API_URL,
|
|
198
|
+
ResultType,
|
|
199
|
+
SmartConnectAPI as SmartPay,
|
|
200
|
+
TransactionOutcome,
|
|
201
|
+
TransactionResult,
|
|
202
|
+
TransactionStatus,
|
|
203
|
+
TransactionTypes,
|
|
204
|
+
useSmartPay
|
|
205
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { reactive, ref } from "vue";
|
|
2
|
+
const state = reactive({
|
|
3
|
+
productName: "",
|
|
4
|
+
productVersion: "",
|
|
5
|
+
productVendorName: "",
|
|
6
|
+
posId: "",
|
|
7
|
+
posRegisterId: "",
|
|
8
|
+
posRegisterName: "",
|
|
9
|
+
posBusinessName: "",
|
|
10
|
+
tyroApiKey: ""
|
|
11
|
+
});
|
|
12
|
+
const environment = ref("production");
|
|
13
|
+
const isPluginInitialized = ref(false);
|
|
14
|
+
const setState = (options) => {
|
|
15
|
+
options.productName && (state.productName = options.productName);
|
|
16
|
+
options.productVersion && (state.productVersion = options.productVersion);
|
|
17
|
+
options.productVendorName && (state.productVendorName = options.productVendorName);
|
|
18
|
+
options.posId && (state.posId = options.posId);
|
|
19
|
+
options.posRegisterId && (state.posRegisterId = options.posRegisterId);
|
|
20
|
+
options.posRegisterName && (state.posRegisterName = options.posRegisterName);
|
|
21
|
+
options.posBusinessName && (state.posBusinessName = options.posBusinessName);
|
|
22
|
+
options.tyroApiKey && (state.tyroApiKey = options.tyroApiKey);
|
|
23
|
+
};
|
|
24
|
+
const setEnvironment = (env) => environment.value = env;
|
|
25
|
+
const checkPluginInitialized = () => {
|
|
26
|
+
if (isPluginInitialized.value) return true;
|
|
27
|
+
throw new Error("[Vue Payment Gateway] Plugin is not initialized.");
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
setEnvironment as a,
|
|
31
|
+
state as b,
|
|
32
|
+
checkPluginInitialized as c,
|
|
33
|
+
environment as e,
|
|
34
|
+
isPluginInitialized as i,
|
|
35
|
+
setState as s
|
|
36
|
+
};
|
package/dist/tyro.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export declare const DEV_TYRO_IFRAME_URL = "https://iclientsimulator.test.tyro.com/logs.html#";
|
|
2
|
+
|
|
3
|
+
export declare const DEV_TYRO_SDK_URL = "https://iclientsimulator.test.tyro.com/iclient-with-ui-v1.js";
|
|
4
|
+
|
|
5
|
+
export declare interface PairResponse {
|
|
6
|
+
/**
|
|
7
|
+
* Status of the pairing request, can be inProgress, success, failure. If inProgress then more responses will follow.
|
|
8
|
+
*/
|
|
9
|
+
status: "success" | "inProgress" | "failure";
|
|
10
|
+
/**
|
|
11
|
+
* The Text message to display to the merchant
|
|
12
|
+
*/
|
|
13
|
+
message: string;
|
|
14
|
+
/**
|
|
15
|
+
* The integration key that is returned, and is to be used to authenticate when transacting.
|
|
16
|
+
*/
|
|
17
|
+
integrationKey: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare type PairTyroCallback = (response: PairResponse) => void;
|
|
21
|
+
|
|
22
|
+
export declare const PROD_TYRO_IFRAME_URL = "https://iclient.tyro.com/logs.html#";
|
|
23
|
+
|
|
24
|
+
export declare const PROD_TYRO_SDK_URL = "https://iclient.tyro.com/iclient-with-ui-v1.js";
|
|
25
|
+
|
|
26
|
+
export declare interface PurchaseRequestParams {
|
|
27
|
+
/**
|
|
28
|
+
* Indicate whether receipts will be printed on the POS (true) or on the terminal (false).
|
|
29
|
+
*/
|
|
30
|
+
integratedReceipt: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Apply a surcharge to this transaction (if the card used attracts a surcharge).
|
|
33
|
+
*/
|
|
34
|
+
enableSurcharge?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The purchase amount (amount to charge the customer) in cents.
|
|
37
|
+
*/
|
|
38
|
+
amount: string;
|
|
39
|
+
/**
|
|
40
|
+
* Cash out amount in cents.
|
|
41
|
+
*/
|
|
42
|
+
cashout?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Supply a transaction Id to be used for the transaction.
|
|
45
|
+
*/
|
|
46
|
+
transactionId?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare type ReceiptCallback = (response: ReceiptResponse) => void;
|
|
50
|
+
|
|
51
|
+
export declare interface ReceiptResponse {
|
|
52
|
+
/**
|
|
53
|
+
* Indicates whether a signature line should be printed and a customer signature collected.
|
|
54
|
+
*/
|
|
55
|
+
signatureRequired: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Text representation of the Tyro receipt intended for the merchant. Formatted to be printed in a monospaced font.
|
|
58
|
+
*/
|
|
59
|
+
merchantReceipt: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare interface RefundRequestParams {
|
|
63
|
+
/**
|
|
64
|
+
* Indicate whether receipts will be printed on the POS (true) or on the terminal (false).
|
|
65
|
+
*/
|
|
66
|
+
integratedReceipt: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The refund amount in cents.
|
|
69
|
+
*/
|
|
70
|
+
amount: string;
|
|
71
|
+
/**
|
|
72
|
+
* Supply a transaction Id to be used for the transaction.
|
|
73
|
+
*/
|
|
74
|
+
transactionId?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare interface TransactionCallbacks {
|
|
78
|
+
/**
|
|
79
|
+
* Invoked when integrated receipts are enabled and a merchant copy of the receipt is available.
|
|
80
|
+
* Ignored if integrated receipt printing is disabled. Called with the following parameters as part of the receipt object.
|
|
81
|
+
* @param response
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
receiptCallback: ReceiptCallback;
|
|
85
|
+
/**
|
|
86
|
+
* Invoked when the transaction has been completed on the terminal.
|
|
87
|
+
* Called with a subset of the following parameters as part of the transactionData object.
|
|
88
|
+
* for more info visit https://docs.integrated-eftpos.tyro.com/integrated-eftpos/iclient/implementation-guide/purchase-cashout-refund/callback/
|
|
89
|
+
* @param response
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
transactionCompleteCallback: (response: TransactionCompleteResponse) => void;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export declare interface TransactionCompleteResponse {
|
|
96
|
+
/**
|
|
97
|
+
* The applied surcharge amount for the given transaction.
|
|
98
|
+
*/
|
|
99
|
+
surchargeAmount: string;
|
|
100
|
+
/**
|
|
101
|
+
* Text representation of the Tyro receipt intended for the customer.
|
|
102
|
+
* Only included if integrated receipt printing is enabled. Formatted to be printed in a monospaced font.
|
|
103
|
+
*/
|
|
104
|
+
customerReceipt: string;
|
|
105
|
+
/**
|
|
106
|
+
* The scheme displayed on the card (Visa, Mastercard, etc).
|
|
107
|
+
*/
|
|
108
|
+
cardType: string;
|
|
109
|
+
result: TyroTransactionStatus;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export declare interface TyroPosProductInfo {
|
|
113
|
+
/**
|
|
114
|
+
* Name of your company.
|
|
115
|
+
*/
|
|
116
|
+
posProductVendor: string;
|
|
117
|
+
/**
|
|
118
|
+
* Name of your product.
|
|
119
|
+
*/
|
|
120
|
+
posProductName: string;
|
|
121
|
+
/**
|
|
122
|
+
* Version of your product.
|
|
123
|
+
*/
|
|
124
|
+
posProductVersion: string;
|
|
125
|
+
/**
|
|
126
|
+
* customer ID or address
|
|
127
|
+
*/
|
|
128
|
+
siteReference: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export declare enum TyroTransactionStatus {
|
|
132
|
+
APPROVED = "APPROVED",
|
|
133
|
+
CANCELLED = "CANCELLED",
|
|
134
|
+
REVERSED = "REVERSED",
|
|
135
|
+
DECLINED = "DECLINED",
|
|
136
|
+
NOT_STARTED = "NOT STARTED",
|
|
137
|
+
SYSTEM_ERROR = "SYSTEM ERROR",
|
|
138
|
+
UNKNOWN = "UNKNOWN"
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export declare const useTyro: () => {
|
|
142
|
+
pairTyro: (merchantId: string, terminalId: string) => Promise<PairResponse>;
|
|
143
|
+
initiateTyroPurchase: (requestParams: PurchaseRequestParams, receiptCallback: ReceiptCallback) => Promise<TransactionCompleteResponse>;
|
|
144
|
+
initiateTyroRefund: (requestParams: RefundRequestParams, receiptCallback: ReceiptCallback) => Promise<TransactionCompleteResponse>;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export { }
|
package/dist/tyro.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { QSpinnerHourglass, Dialog } from "quasar";
|
|
2
|
+
import { c as checkPluginInitialized, b as state } from "./state-0HFa2Xwz.js";
|
|
3
|
+
const dialogDefaultOpts = {
|
|
4
|
+
message: "Pairing in progress...",
|
|
5
|
+
class: "text-lg",
|
|
6
|
+
progress: {
|
|
7
|
+
// spinner: QSpinnerClock,
|
|
8
|
+
spinner: QSpinnerHourglass,
|
|
9
|
+
color: "amber"
|
|
10
|
+
},
|
|
11
|
+
persistent: true,
|
|
12
|
+
html: true,
|
|
13
|
+
ok: false,
|
|
14
|
+
cancel: {
|
|
15
|
+
label: "Close",
|
|
16
|
+
noCaps: true,
|
|
17
|
+
color: "red",
|
|
18
|
+
outline: true
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const responseReceivedCallbackImp = (dialog, response) => {
|
|
22
|
+
console.log(response);
|
|
23
|
+
if (response.status === "inProgress") {
|
|
24
|
+
dialog == null ? void 0 : dialog.update({ message: response.message });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (response.status === "success") {
|
|
28
|
+
dialog == null ? void 0 : dialog.update({
|
|
29
|
+
title: "Success!",
|
|
30
|
+
class: "text-green-500",
|
|
31
|
+
progress: false,
|
|
32
|
+
message: `<div class="text-gray-800 text-base">${response.message}</div>`
|
|
33
|
+
});
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
dialog == null ? void 0 : dialog.hide();
|
|
36
|
+
}, 4500);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
dialog == null ? void 0 : dialog.update({
|
|
40
|
+
title: "Failed!",
|
|
41
|
+
class: "text-red-500",
|
|
42
|
+
progress: false,
|
|
43
|
+
message: `<div class="text-gray-800 text-base">${response.message}</div>`
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const useTyro = () => {
|
|
47
|
+
checkPluginInitialized();
|
|
48
|
+
const iclient = new TYRO.IClientWithUI(state.tyroApiKey, {
|
|
49
|
+
posProductVendor: state.productVendorName,
|
|
50
|
+
posProductName: state.productName,
|
|
51
|
+
posProductVersion: state.productVersion,
|
|
52
|
+
siteReference: ""
|
|
53
|
+
});
|
|
54
|
+
const pairTyro = (merchantId, terminalId) => {
|
|
55
|
+
return new Promise((resolve, _reject) => {
|
|
56
|
+
const dialog = Dialog.create({ ...dialogDefaultOpts });
|
|
57
|
+
if (!merchantId || !terminalId) {
|
|
58
|
+
responseReceivedCallbackImp(dialog, {
|
|
59
|
+
message: "merchantId and terminalId is required to pair tyro.",
|
|
60
|
+
status: "failure",
|
|
61
|
+
integrationKey: ""
|
|
62
|
+
});
|
|
63
|
+
resolve({
|
|
64
|
+
message: "merchantId and terminalId is required to pair tyro.",
|
|
65
|
+
status: "failure",
|
|
66
|
+
integrationKey: ""
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
iclient.pairTerminal(merchantId, terminalId, (res) => {
|
|
71
|
+
responseReceivedCallbackImp(dialog, res);
|
|
72
|
+
if (res.status !== "inProgress") {
|
|
73
|
+
resolve(res);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const initiateTyroPurchase = (requestParams, receiptCallback) => {
|
|
79
|
+
return new Promise((resolve, _reject) => {
|
|
80
|
+
iclient.initiatePurchase(requestParams, { transactionCompleteCallback: resolve, receiptCallback });
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const initiateTyroRefund = (requestParams, receiptCallback) => {
|
|
84
|
+
return new Promise((resolve, _reject) => {
|
|
85
|
+
iclient.initiateRefund(requestParams, { transactionCompleteCallback: resolve, receiptCallback });
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return { pairTyro, initiateTyroPurchase, initiateTyroRefund };
|
|
89
|
+
};
|
|
90
|
+
const DEV_TYRO_IFRAME_URL = "https://iclientsimulator.test.tyro.com/logs.html#";
|
|
91
|
+
const DEV_TYRO_SDK_URL = "https://iclientsimulator.test.tyro.com/iclient-with-ui-v1.js";
|
|
92
|
+
const PROD_TYRO_IFRAME_URL = "https://iclient.tyro.com/logs.html#";
|
|
93
|
+
const PROD_TYRO_SDK_URL = "https://iclient.tyro.com/iclient-with-ui-v1.js";
|
|
94
|
+
var TyroTransactionStatus = /* @__PURE__ */ ((TyroTransactionStatus2) => {
|
|
95
|
+
TyroTransactionStatus2["APPROVED"] = "APPROVED";
|
|
96
|
+
TyroTransactionStatus2["CANCELLED"] = "CANCELLED";
|
|
97
|
+
TyroTransactionStatus2["REVERSED"] = "REVERSED";
|
|
98
|
+
TyroTransactionStatus2["DECLINED"] = "DECLINED";
|
|
99
|
+
TyroTransactionStatus2["NOT_STARTED"] = "NOT STARTED";
|
|
100
|
+
TyroTransactionStatus2["SYSTEM_ERROR"] = "SYSTEM ERROR";
|
|
101
|
+
TyroTransactionStatus2["UNKNOWN"] = "UNKNOWN";
|
|
102
|
+
return TyroTransactionStatus2;
|
|
103
|
+
})(TyroTransactionStatus || {});
|
|
104
|
+
export {
|
|
105
|
+
DEV_TYRO_IFRAME_URL,
|
|
106
|
+
DEV_TYRO_SDK_URL,
|
|
107
|
+
PROD_TYRO_IFRAME_URL,
|
|
108
|
+
PROD_TYRO_SDK_URL,
|
|
109
|
+
TyroTransactionStatus,
|
|
110
|
+
useTyro
|
|
111
|
+
};
|