@achyutlabsau/vue-payment-gateway 0.0.1 → 0.0.3
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/dist/index.js +5 -0
- package/dist/smartpay.d.ts +12 -4
- package/dist/smartpay.js +81 -1
- package/dist/tyro.d.ts +14 -8
- package/dist/tyro.enums-OZuKaM2C.js +26 -0
- package/dist/tyro.js +7 -21
- package/package.json +14 -5
package/dist/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { s as setState, a as setEnvironment, i as isPluginInitialized } from "./state-0HFa2Xwz.js";
|
|
2
|
+
import "quasar";
|
|
3
|
+
import { T as TYRO_CONSTANTS } from "./tyro.enums-OZuKaM2C.js";
|
|
4
|
+
import { useScriptTag } from "@vueuse/core";
|
|
2
5
|
import { g } from "./index-C8vc_75e.js";
|
|
3
6
|
const install = (_app, options) => {
|
|
4
7
|
setState(options);
|
|
5
8
|
options.environment && setEnvironment(options.environment);
|
|
9
|
+
const tyroConfig = options.environment === "production" ? TYRO_CONSTANTS.URLS.PRODUCTION : TYRO_CONSTANTS.URLS.DEVELOPMENT;
|
|
10
|
+
useScriptTag(tyroConfig.SDK_URL);
|
|
6
11
|
isPluginInitialized.value = true;
|
|
7
12
|
};
|
|
8
13
|
const VuePaymentGateway = { install };
|
package/dist/smartpay.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ export declare interface PollingResponseData {
|
|
|
27
27
|
data?: TransactionData;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export declare interface PollingResult {
|
|
31
|
+
transactionOutcome: TransactionOutcome;
|
|
32
|
+
responseData: PollingResponseData;
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
export declare const PROD_SMARTPAY_API_URL = "https://api.smart-connect.cloud/POS";
|
|
31
36
|
|
|
32
37
|
export declare enum ResultType {
|
|
@@ -37,6 +42,10 @@ export declare enum ResultType {
|
|
|
37
42
|
FailedInterface = "FAILED-INTERFACE"
|
|
38
43
|
}
|
|
39
44
|
|
|
45
|
+
declare interface SmartConnectPayRef extends PollingResult {
|
|
46
|
+
smartPayCustomerReceipt?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
export declare class SmartPay {
|
|
41
50
|
private api;
|
|
42
51
|
constructor();
|
|
@@ -46,10 +55,7 @@ export declare class SmartPay {
|
|
|
46
55
|
message: string;
|
|
47
56
|
}>;
|
|
48
57
|
createTransaction(amount: number, transactionType: TransactionTypes): Promise<string>;
|
|
49
|
-
pollForOutcome(pollingUrl: string, delayed?: () => void): Promise<
|
|
50
|
-
transactionOutcome: TransactionOutcome;
|
|
51
|
-
responseData: PollingResponseData;
|
|
52
|
-
}>;
|
|
58
|
+
pollForOutcome(pollingUrl: string, delayed?: () => void): Promise<PollingResult>;
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
declare interface TransactionData {
|
|
@@ -137,6 +143,8 @@ export declare const useSmartPay: () => {
|
|
|
137
143
|
success: boolean;
|
|
138
144
|
message: string;
|
|
139
145
|
}>;
|
|
146
|
+
initiatePurchase: (amount: number) => Promise<SmartConnectPayRef>;
|
|
147
|
+
initiateRefund: (amount: number) => Promise<SmartConnectPayRef>;
|
|
140
148
|
};
|
|
141
149
|
|
|
142
150
|
export { }
|
package/dist/smartpay.js
CHANGED
|
@@ -165,6 +165,44 @@ class SmartConnectAPI {
|
|
|
165
165
|
return poll();
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
const updateDialog = (dialog, transactionOutcome) => {
|
|
169
|
+
if (transactionOutcome === TransactionOutcome.Accepted) {
|
|
170
|
+
dialog.update({
|
|
171
|
+
title: "Success!",
|
|
172
|
+
class: "text-green-500",
|
|
173
|
+
progress: false,
|
|
174
|
+
message: '<div class="text-gray-800 text-base">Transaction Accepted!</div>'
|
|
175
|
+
});
|
|
176
|
+
} else if (transactionOutcome === TransactionOutcome.Declined) {
|
|
177
|
+
dialog.update({
|
|
178
|
+
title: "Failed!",
|
|
179
|
+
class: "text-red-500",
|
|
180
|
+
progress: false,
|
|
181
|
+
message: '<div class="text-gray-800 text-base">Transaction Declined!</div>'
|
|
182
|
+
});
|
|
183
|
+
} else if (transactionOutcome === TransactionOutcome.Cancelled) {
|
|
184
|
+
dialog.update({
|
|
185
|
+
title: "Failed!",
|
|
186
|
+
class: "text-red-500",
|
|
187
|
+
progress: false,
|
|
188
|
+
message: '<div class="text-gray-800 text-base">Transaction Cancelled!</div>'
|
|
189
|
+
});
|
|
190
|
+
} else if (transactionOutcome === TransactionOutcome.DeviceOffline) {
|
|
191
|
+
dialog.update({
|
|
192
|
+
title: "Failed!",
|
|
193
|
+
class: "text-red-500",
|
|
194
|
+
progress: false,
|
|
195
|
+
message: '<div class="text-gray-800 text-base">Transaction Cancelled! Please check if the device is powered on and online.</div>'
|
|
196
|
+
});
|
|
197
|
+
} else {
|
|
198
|
+
dialog.update({
|
|
199
|
+
title: "Failed!",
|
|
200
|
+
class: "text-red-500",
|
|
201
|
+
progress: false,
|
|
202
|
+
message: '<div class="text-gray-800 text-base">Transaction Failed!</div>'
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
};
|
|
168
206
|
const useSmartPay = () => {
|
|
169
207
|
const smartPayApi = new SmartConnectAPI();
|
|
170
208
|
const pairTerminal = async (pairingCode) => {
|
|
@@ -190,7 +228,49 @@ const useSmartPay = () => {
|
|
|
190
228
|
setTimeout(dialog.hide, 2500);
|
|
191
229
|
}
|
|
192
230
|
};
|
|
193
|
-
|
|
231
|
+
const initiateSmartConnectPayment = (cardAmount, transactionType) => {
|
|
232
|
+
return new Promise((resolve, reject) => {
|
|
233
|
+
const dialog = Dialog.create({ ...dialogDefaultOpts });
|
|
234
|
+
let delayedShown = false;
|
|
235
|
+
const delayed = function() {
|
|
236
|
+
if (!delayedShown) {
|
|
237
|
+
delayedShown = true;
|
|
238
|
+
dialog.update({
|
|
239
|
+
message: "Transaction delayed! Check if the device is powered on and online"
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
smartPayApi.createTransaction(cardAmount, transactionType).then((pollingUrl) => {
|
|
244
|
+
dialog.update({
|
|
245
|
+
message: "Transaction is in process! Please wait"
|
|
246
|
+
});
|
|
247
|
+
return smartPayApi.pollForOutcome(pollingUrl, delayed);
|
|
248
|
+
}).then((response) => {
|
|
249
|
+
var _a, _b;
|
|
250
|
+
updateDialog(dialog, response.transactionOutcome);
|
|
251
|
+
resolve({
|
|
252
|
+
...response,
|
|
253
|
+
smartPayCustomerReceipt: (_b = (_a = response.responseData) == null ? void 0 : _a.data) == null ? void 0 : _b.Receipt
|
|
254
|
+
});
|
|
255
|
+
setTimeout(dialog.hide, 3e3);
|
|
256
|
+
}).catch((errorMessage) => {
|
|
257
|
+
dialog.update({
|
|
258
|
+
title: "Error!",
|
|
259
|
+
class: "text-red-500",
|
|
260
|
+
progress: false,
|
|
261
|
+
message: `<div class="text-gray-800 text-base">${errorMessage}</div>`
|
|
262
|
+
});
|
|
263
|
+
reject({ success: false });
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
const initiatePurchase = (amount) => {
|
|
268
|
+
return initiateSmartConnectPayment(amount, TransactionTypes.Purchase);
|
|
269
|
+
};
|
|
270
|
+
const initiateRefund = (amount) => {
|
|
271
|
+
return initiateSmartConnectPayment(amount, TransactionTypes.Refund);
|
|
272
|
+
};
|
|
273
|
+
return { pairTerminal, initiatePurchase, initiateRefund };
|
|
194
274
|
};
|
|
195
275
|
export {
|
|
196
276
|
DEV_SMARTPAY_API_URL,
|
package/dist/tyro.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
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
1
|
export declare interface PairResponse {
|
|
6
2
|
/**
|
|
7
3
|
* Status of the pairing request, can be inProgress, success, failure. If inProgress then more responses will follow.
|
|
@@ -19,10 +15,6 @@ export declare interface PairResponse {
|
|
|
19
15
|
|
|
20
16
|
export declare type PairTyroCallback = (response: PairResponse) => void;
|
|
21
17
|
|
|
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
18
|
export declare interface PurchaseRequestParams {
|
|
27
19
|
/**
|
|
28
20
|
* Indicate whether receipts will be printed on the POS (true) or on the terminal (false).
|
|
@@ -109,6 +101,19 @@ export declare interface TransactionCompleteResponse {
|
|
|
109
101
|
result: TyroTransactionStatus;
|
|
110
102
|
}
|
|
111
103
|
|
|
104
|
+
export declare const TYRO_CONSTANTS: {
|
|
105
|
+
URLS: {
|
|
106
|
+
DEVELOPMENT: {
|
|
107
|
+
SDK_URL: string;
|
|
108
|
+
IFRAME_URL: string;
|
|
109
|
+
};
|
|
110
|
+
PRODUCTION: {
|
|
111
|
+
SDK_URL: string;
|
|
112
|
+
IFRAME_URL: string;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
112
117
|
export declare interface TyroPosProductInfo {
|
|
113
118
|
/**
|
|
114
119
|
* Name of your company.
|
|
@@ -139,6 +144,7 @@ export declare enum TyroTransactionStatus {
|
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
export declare const useTyro: () => {
|
|
147
|
+
IFRAME_URL: string;
|
|
142
148
|
pairTyro: (merchantId: string, terminalId: string) => Promise<PairResponse>;
|
|
143
149
|
initiateTyroPurchase: (requestParams: PurchaseRequestParams, receiptCallback: ReceiptCallback) => Promise<TransactionCompleteResponse>;
|
|
144
150
|
initiateTyroRefund: (requestParams: RefundRequestParams, receiptCallback: ReceiptCallback) => Promise<TransactionCompleteResponse>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const TYRO_CONSTANTS = {
|
|
2
|
+
URLS: {
|
|
3
|
+
DEVELOPMENT: {
|
|
4
|
+
SDK_URL: "https://iclientsimulator.test.tyro.com/iclient-with-ui-v1.js",
|
|
5
|
+
IFRAME_URL: "https://iclientsimulator.test.tyro.com/logs.html#"
|
|
6
|
+
},
|
|
7
|
+
PRODUCTION: {
|
|
8
|
+
SDK_URL: "https://iclient.tyro.com/iclient-with-ui-v1.js",
|
|
9
|
+
IFRAME_URL: "https://iclient.tyro.com/logs.html#"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var TyroTransactionStatus = /* @__PURE__ */ ((TyroTransactionStatus2) => {
|
|
14
|
+
TyroTransactionStatus2["APPROVED"] = "APPROVED";
|
|
15
|
+
TyroTransactionStatus2["CANCELLED"] = "CANCELLED";
|
|
16
|
+
TyroTransactionStatus2["REVERSED"] = "REVERSED";
|
|
17
|
+
TyroTransactionStatus2["DECLINED"] = "DECLINED";
|
|
18
|
+
TyroTransactionStatus2["NOT_STARTED"] = "NOT STARTED";
|
|
19
|
+
TyroTransactionStatus2["SYSTEM_ERROR"] = "SYSTEM ERROR";
|
|
20
|
+
TyroTransactionStatus2["UNKNOWN"] = "UNKNOWN";
|
|
21
|
+
return TyroTransactionStatus2;
|
|
22
|
+
})(TyroTransactionStatus || {});
|
|
23
|
+
export {
|
|
24
|
+
TYRO_CONSTANTS as T,
|
|
25
|
+
TyroTransactionStatus as a
|
|
26
|
+
};
|
package/dist/tyro.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { QSpinnerHourglass, Dialog } from "quasar";
|
|
2
|
-
import { c as checkPluginInitialized, b as state } from "./state-0HFa2Xwz.js";
|
|
2
|
+
import { c as checkPluginInitialized, e as environment, b as state } from "./state-0HFa2Xwz.js";
|
|
3
|
+
import { T as TYRO_CONSTANTS } from "./tyro.enums-OZuKaM2C.js";
|
|
4
|
+
import { a } from "./tyro.enums-OZuKaM2C.js";
|
|
3
5
|
const dialogDefaultOpts = {
|
|
4
6
|
message: "Pairing in progress...",
|
|
5
7
|
class: "text-lg",
|
|
@@ -45,6 +47,7 @@ const responseReceivedCallbackImp = (dialog, response) => {
|
|
|
45
47
|
};
|
|
46
48
|
const useTyro = () => {
|
|
47
49
|
checkPluginInitialized();
|
|
50
|
+
const { IFRAME_URL } = environment.value === "production" ? TYRO_CONSTANTS.URLS.PRODUCTION : TYRO_CONSTANTS.URLS.DEVELOPMENT;
|
|
48
51
|
const iclient = new TYRO.IClientWithUI(state.tyroApiKey, {
|
|
49
52
|
posProductVendor: state.productVendorName,
|
|
50
53
|
posProductName: state.productName,
|
|
@@ -85,27 +88,10 @@ const useTyro = () => {
|
|
|
85
88
|
iclient.initiateRefund(requestParams, { transactionCompleteCallback: resolve, receiptCallback });
|
|
86
89
|
});
|
|
87
90
|
};
|
|
88
|
-
return { pairTyro, initiateTyroPurchase, initiateTyroRefund };
|
|
91
|
+
return { IFRAME_URL, pairTyro, initiateTyroPurchase, initiateTyroRefund };
|
|
89
92
|
};
|
|
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
93
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
PROD_TYRO_IFRAME_URL,
|
|
108
|
-
PROD_TYRO_SDK_URL,
|
|
109
|
-
TyroTransactionStatus,
|
|
94
|
+
TYRO_CONSTANTS,
|
|
95
|
+
a as TyroTransactionStatus,
|
|
110
96
|
useTyro
|
|
111
97
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@achyutlabsau/vue-payment-gateway",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Achyut-Labs/al-pay-npm-pkg.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/Achyut-Labs/al-pay-npm-pkg/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/Achyut-Labs/al-pay-npm-pkg#readme",
|
|
6
14
|
"files": [
|
|
7
15
|
"dist"
|
|
8
16
|
],
|
|
@@ -31,20 +39,21 @@
|
|
|
31
39
|
"build": "vue-tsc -b && vite build",
|
|
32
40
|
"preview": "vite preview"
|
|
33
41
|
},
|
|
34
|
-
"dependencies": {},
|
|
35
42
|
"peerDependencies": {
|
|
36
|
-
"uuid": "^11.x.x",
|
|
37
43
|
"axios": "^1.7.x",
|
|
44
|
+
"@vueuse/core": "*",
|
|
38
45
|
"quasar": "^2.x.x",
|
|
46
|
+
"uuid": "^11.x.x",
|
|
39
47
|
"vue": "^3.5.x"
|
|
40
48
|
},
|
|
41
49
|
"devDependencies": {
|
|
42
50
|
"@types/node": "^22.10.1",
|
|
43
51
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
44
|
-
"
|
|
52
|
+
"@vueuse/core": "^12.0.0",
|
|
45
53
|
"axios": "^1.7.9",
|
|
46
54
|
"quasar": "^2.x.x",
|
|
47
|
-
"typescript": "5.
|
|
55
|
+
"typescript": "5.6.2",
|
|
56
|
+
"uuid": "^11.0.3",
|
|
48
57
|
"vite": "^6.0.3",
|
|
49
58
|
"vite-plugin-dts": "^4.3.0",
|
|
50
59
|
"vue": "^3.5.13",
|