@achyutlabsau/vue-payment-gateway 1.0.0-beta.2 → 1.0.0-beta.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 +1 -1
- package/dist/{valpay-C31V13Nz.js → valpay-MfJgW2Rh.js} +129 -129
- package/dist/valpay.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { o as w, t as T } from "./tyro-P_beqaoJ.js";
|
|
|
7
7
|
import { t as E } from "./linkly-C9NDmzIU.js";
|
|
8
8
|
import { t as D } from "./smartpay-BlPtSJAm.js";
|
|
9
9
|
import { t as O } from "./till-payment-DFyssYl7.js";
|
|
10
|
-
import { t as k } from "./valpay-
|
|
10
|
+
import { t as k } from "./valpay-MfJgW2Rh.js";
|
|
11
11
|
import { createBlock as A, createCommentVNode as j, createElementBlock as M, defineComponent as N, openBlock as P, unref as F } from "vue";
|
|
12
12
|
import { useEventListener as I, useScriptTag as L } from "@vueuse/core";
|
|
13
13
|
//#region src/plugin/types.ts
|
|
@@ -2,23 +2,23 @@ import { a as e, i as t, n, r, u as i } from "./PBtn-B_JOD69N.js";
|
|
|
2
2
|
import { T as a, d as o, h as s, i as c, r as l, u } from "./logger-Chsffh2c.js";
|
|
3
3
|
import { t as d } from "./PairInstructions-Dt9aD4Qn.js";
|
|
4
4
|
import { delay as f, formatCents as p, isServerError as m, normalizeCardScheme as h, toCents as g, toMajorUnits as _ } from "./utils.js";
|
|
5
|
-
import { i as
|
|
6
|
-
import { createBlock as
|
|
7
|
-
import { useLocalStorage as
|
|
8
|
-
import { Dialog as
|
|
9
|
-
import { v7 as
|
|
10
|
-
import
|
|
5
|
+
import { i as ee, n as v, r as y } from "./core-ExhZA5wz.js";
|
|
6
|
+
import { createBlock as b, createElementBlock as x, createElementVNode as S, createTextVNode as C, createVNode as w, defineComponent as te, onMounted as ne, openBlock as T, ref as E, toDisplayString as D, unref as O, withCtx as k } from "vue";
|
|
7
|
+
import { useLocalStorage as re } from "@vueuse/core";
|
|
8
|
+
import { Dialog as A, Loading as ie, Notify as j, QBtn as M, QCard as N, QCardSection as ae, QForm as oe, QIcon as se, QInput as ce, QSelect as le } from "quasar";
|
|
9
|
+
import { v7 as P } from "uuid";
|
|
10
|
+
import ue, { isAxiosError as F } from "axios";
|
|
11
11
|
//#region src/library/valpay/valpay.storage.ts
|
|
12
|
-
var
|
|
12
|
+
var I = {
|
|
13
13
|
SALE_ID: "valpay.saleId",
|
|
14
14
|
TERMINAL_ID: "valpay.terminalId",
|
|
15
15
|
RUNNING_SERVICE_ID: "valpay.runningServiceId",
|
|
16
16
|
LAST_TRANSACTION: "valpay.lastTransaction"
|
|
17
|
-
},
|
|
17
|
+
}, L = (e) => localStorage.setItem(I.SALE_ID, e), R = () => localStorage.getItem(I.SALE_ID), z = (e) => localStorage.setItem(I.TERMINAL_ID, e), B = () => localStorage.getItem(I.TERMINAL_ID), V = (e) => sessionStorage.setItem(I.RUNNING_SERVICE_ID, e), H = () => sessionStorage.removeItem(I.RUNNING_SERVICE_ID), de = () => sessionStorage.getItem(I.RUNNING_SERVICE_ID), U = (e, t) => localStorage.setItem(I.LAST_TRANSACTION, JSON.stringify({
|
|
18
18
|
serviceId: e,
|
|
19
19
|
messageCategory: t
|
|
20
|
-
})),
|
|
21
|
-
let e = localStorage.getItem(
|
|
20
|
+
})), fe = () => {
|
|
21
|
+
let e = localStorage.getItem(I.LAST_TRANSACTION);
|
|
22
22
|
if (!e) return null;
|
|
23
23
|
try {
|
|
24
24
|
let t = JSON.parse(e);
|
|
@@ -29,45 +29,45 @@ var L = {
|
|
|
29
29
|
} catch {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
|
-
},
|
|
33
|
-
let e =
|
|
32
|
+
}, pe = 5e3, W = 1e3, G = 3e4, me = 18e4, he = 6e4, K = 12e4, ge = /* @__PURE__ */ new Set(["DeviceOut", "UnreachableHost"]), _e = (e) => e === "InProgress" || ge.has(e ?? ""), ve = () => {
|
|
33
|
+
let e = W;
|
|
34
34
|
return {
|
|
35
35
|
next() {
|
|
36
|
-
let t = Math.min(e,
|
|
37
|
-
return e = Math.min(e * 2,
|
|
36
|
+
let t = Math.min(e, G) + Math.floor(Math.random() * 500);
|
|
37
|
+
return e = Math.min(e * 2, G), t;
|
|
38
38
|
},
|
|
39
39
|
reset() {
|
|
40
|
-
e =
|
|
40
|
+
e = W;
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
},
|
|
43
|
+
}, ye = (e) => {
|
|
44
44
|
if (!e) return {};
|
|
45
45
|
try {
|
|
46
46
|
let t = JSON.parse(atob(e));
|
|
47
47
|
if (t && typeof t == "object") return Object.fromEntries(Object.entries(t).map(([e, t]) => [e, String(t)]));
|
|
48
48
|
} catch {}
|
|
49
49
|
return e.includes("=") ? Object.fromEntries(new URLSearchParams(e).entries()) : {};
|
|
50
|
-
},
|
|
51
|
-
let t =
|
|
50
|
+
}, q = (e) => {
|
|
51
|
+
let t = ye(e.AdditionalResponse);
|
|
52
52
|
return t.refusalReason || t.message || e.ErrorCondition;
|
|
53
|
-
},
|
|
53
|
+
}, J = (e) => {
|
|
54
54
|
let t = e?.SaleToPOIRequest?.EventNotification;
|
|
55
55
|
if (!t) return;
|
|
56
56
|
let n = t.EventDetails;
|
|
57
57
|
if (!n) return `Payment failed: ${t.EventToNotify}`;
|
|
58
58
|
let r = decodeURIComponent(String(n).replace(/\+/g, " ")), i = r.match(/message=(.+)/);
|
|
59
59
|
return i ? i[1] : r;
|
|
60
|
-
},
|
|
61
|
-
if (!
|
|
60
|
+
}, Y = (e, t = "Failed to process payment") => F(e) && (J(e.response?.data) || e.response?.data?.message || e.message) || t, X = (e) => {
|
|
61
|
+
if (!F(e)) return !1;
|
|
62
62
|
let t = e.response?.status;
|
|
63
63
|
return t === void 0 || t === 408 || m(t);
|
|
64
|
-
}, Q = () => Date.now().toString().slice(-
|
|
64
|
+
}, Z = 0, Q = () => (Z = (Z + 1) % 36, `${Date.now().toString().slice(-9)}${Z.toString(36)}`), be = (e = /* @__PURE__ */ new Date()) => e.toISOString(), $ = s.child({ gateway: n.ADYEN }), xe = class {
|
|
65
65
|
terminalApi;
|
|
66
66
|
config;
|
|
67
67
|
constructor(e) {
|
|
68
|
-
this.terminalApi =
|
|
68
|
+
this.terminalApi = ue.create({
|
|
69
69
|
baseURL: e.apiBaseUrl,
|
|
70
|
-
timeout:
|
|
70
|
+
timeout: he,
|
|
71
71
|
transitional: { clarifyTimeoutError: !0 }
|
|
72
72
|
}), this.config = e;
|
|
73
73
|
}
|
|
@@ -75,7 +75,7 @@ var L = {
|
|
|
75
75
|
return !e || !t ? {
|
|
76
76
|
success: !1,
|
|
77
77
|
message: "Both saleId and terminalId are required for pairing"
|
|
78
|
-
} : (
|
|
78
|
+
} : (L(e), z(t), $.info(a.PairOk, "Terminal paired", {
|
|
79
79
|
saleId: e,
|
|
80
80
|
terminalId: t
|
|
81
81
|
}), {
|
|
@@ -84,10 +84,10 @@ var L = {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
unpair() {
|
|
87
|
-
|
|
87
|
+
L(""), z(""), $.info(a.Unpair, "Terminal unpaired");
|
|
88
88
|
}
|
|
89
89
|
isPaired() {
|
|
90
|
-
let e =
|
|
90
|
+
let e = R(), t = B();
|
|
91
91
|
return !!e && !!t;
|
|
92
92
|
}
|
|
93
93
|
async getConnectedTerminals(e, t) {
|
|
@@ -102,7 +102,7 @@ var L = {
|
|
|
102
102
|
} catch (e) {
|
|
103
103
|
return {
|
|
104
104
|
success: !1,
|
|
105
|
-
message:
|
|
105
|
+
message: F(e) ? e.response?.data?.message || e.message : "Failed to fetch connected terminals"
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -121,10 +121,10 @@ var L = {
|
|
|
121
121
|
success: !1,
|
|
122
122
|
message: "Currency is required"
|
|
123
123
|
};
|
|
124
|
-
let i =
|
|
124
|
+
let i = R(), o = B();
|
|
125
125
|
r = Q();
|
|
126
|
-
let s =
|
|
127
|
-
|
|
126
|
+
let s = be();
|
|
127
|
+
V(r), U(r, "Payment"), $.child({ transactionId: r }).info(a.PurchaseStart, "Payment request sent", {
|
|
128
128
|
amount: e,
|
|
129
129
|
currency: t,
|
|
130
130
|
tipAmount: n?.tipAmount,
|
|
@@ -144,7 +144,7 @@ var L = {
|
|
|
144
144
|
PaymentRequest: {
|
|
145
145
|
SaleData: {
|
|
146
146
|
SaleTransactionID: {
|
|
147
|
-
TransactionID:
|
|
147
|
+
TransactionID: P(),
|
|
148
148
|
TimeStamp: s
|
|
149
149
|
},
|
|
150
150
|
SaleToAcquirerData: n?.isTipEnabled ? "tenderOption=AskGratuity" : void 0
|
|
@@ -157,17 +157,17 @@ var L = {
|
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
159
|
merchantAccount: this.config.merchantAccount
|
|
160
|
-
}, l = await this.terminalApi.post("/sync", c, { timeout:
|
|
160
|
+
}, l = await this.terminalApi.post("/sync", c, { timeout: K });
|
|
161
161
|
if ("SaleToPOIRequest" in l.data) {
|
|
162
|
-
let e =
|
|
162
|
+
let e = J(l.data);
|
|
163
163
|
return $.child({ transactionId: r }).error(a.PurchaseFailed, e ?? "Payment was rejected"), {
|
|
164
164
|
success: !1,
|
|
165
165
|
message: e
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
let u = l.data?.SaleToPOIResponse?.PaymentResponse?.Response, d = l.data?.SaleToPOIResponse?.PaymentResponse?.PaymentResult?.AmountsResp?.TipAmount;
|
|
169
|
-
|
|
170
|
-
let f = u?.Result === "Success", p = f ? "Payment completed successfully" : u &&
|
|
169
|
+
H();
|
|
170
|
+
let f = u?.Result === "Success", p = f ? "Payment completed successfully" : u && q(u) || "Payment failed", m = $.child({ transactionId: r });
|
|
171
171
|
return f ? m.info(a.PurchaseOk, p, { tipAmount: d }) : m.warn(a.PurchaseDeclined, p, { errorCondition: u?.ErrorCondition }), {
|
|
172
172
|
success: f,
|
|
173
173
|
data: l.data,
|
|
@@ -176,8 +176,8 @@ var L = {
|
|
|
176
176
|
message: p
|
|
177
177
|
};
|
|
178
178
|
} catch (e) {
|
|
179
|
-
if (
|
|
180
|
-
let t =
|
|
179
|
+
if (H(), r && X(e)) return $.child({ transactionId: r }).warn(a.PollRetry, "Payment response lost, recovering status", { error: e }), this.getTransactionStatus(r, "Payment");
|
|
180
|
+
let t = Y(e);
|
|
181
181
|
return $.child({ transactionId: r }).error(a.PurchaseFailed, t, { error: e }), {
|
|
182
182
|
success: !1,
|
|
183
183
|
message: t
|
|
@@ -222,10 +222,10 @@ var L = {
|
|
|
222
222
|
success: !1,
|
|
223
223
|
message: "Currency is required"
|
|
224
224
|
};
|
|
225
|
-
let i =
|
|
225
|
+
let i = R(), o = B();
|
|
226
226
|
r = Q();
|
|
227
|
-
let s =
|
|
228
|
-
|
|
227
|
+
let s = be();
|
|
228
|
+
V(r), U(r, n?.originalTransactionId ? "Reversal" : "Payment"), $.child({ transactionId: r }).info(a.RefundStart, `${n?.originalTransactionId ? "Referenced" : "Unreferenced"} refund request sent`, {
|
|
229
229
|
amount: e,
|
|
230
230
|
currency: t,
|
|
231
231
|
isReferenced: !!n?.originalTransactionId,
|
|
@@ -252,7 +252,7 @@ var L = {
|
|
|
252
252
|
},
|
|
253
253
|
SaleData: {
|
|
254
254
|
SaleTransactionID: {
|
|
255
|
-
TransactionID:
|
|
255
|
+
TransactionID: P(),
|
|
256
256
|
TimeStamp: s
|
|
257
257
|
},
|
|
258
258
|
SaleToAcquirerData: `currency=${t}`
|
|
@@ -275,7 +275,7 @@ var L = {
|
|
|
275
275
|
},
|
|
276
276
|
PaymentRequest: {
|
|
277
277
|
SaleData: { SaleTransactionID: {
|
|
278
|
-
TransactionID:
|
|
278
|
+
TransactionID: P(),
|
|
279
279
|
TimeStamp: s
|
|
280
280
|
} },
|
|
281
281
|
PaymentTransaction: { AmountsReq: {
|
|
@@ -286,17 +286,17 @@ var L = {
|
|
|
286
286
|
}
|
|
287
287
|
},
|
|
288
288
|
merchantAccount: this.config.merchantAccount
|
|
289
|
-
}, u = await this.terminalApi.post("/sync", l, { timeout:
|
|
289
|
+
}, u = await this.terminalApi.post("/sync", l, { timeout: K });
|
|
290
290
|
if ("SaleToPOIRequest" in u.data) {
|
|
291
|
-
let e =
|
|
291
|
+
let e = J(u.data);
|
|
292
292
|
return $.child({ transactionId: r }).error(a.RefundFailed, e ?? "Refund was rejected"), {
|
|
293
293
|
success: !1,
|
|
294
294
|
message: e
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
let d = this.normalizeRefundResponse(u.data), f = d.SaleToPOIResponse?.PaymentResponse?.Response.Result;
|
|
298
|
-
|
|
299
|
-
let p = f === "Success", m = p ? "Refund completed successfully" :
|
|
298
|
+
H();
|
|
299
|
+
let p = f === "Success", m = p ? "Refund completed successfully" : q(d.SaleToPOIResponse.PaymentResponse.Response) || "Refund failed", h = $.child({ transactionId: r });
|
|
300
300
|
return p ? h.info(a.RefundOk, m) : h.warn(a.RefundDeclined, m), {
|
|
301
301
|
success: p,
|
|
302
302
|
data: d,
|
|
@@ -304,8 +304,8 @@ var L = {
|
|
|
304
304
|
message: m
|
|
305
305
|
};
|
|
306
306
|
} catch (e) {
|
|
307
|
-
if (
|
|
308
|
-
let t =
|
|
307
|
+
if (H(), r && X(e)) return $.child({ transactionId: r }).warn(a.PollRetry, "Refund response lost, recovering status", { error: e }), this.getTransactionStatus(r, n?.originalTransactionId ? "Reversal" : "Payment");
|
|
308
|
+
let t = Y(e, "Failed to process refund");
|
|
309
309
|
return $.child({ transactionId: r }).error(a.RefundFailed, t, { error: e }), {
|
|
310
310
|
success: !1,
|
|
311
311
|
message: t
|
|
@@ -320,9 +320,9 @@ var L = {
|
|
|
320
320
|
MessageClass: "Service",
|
|
321
321
|
MessageCategory: "Payment",
|
|
322
322
|
MessageType: "Response",
|
|
323
|
-
SaleID: t?.MessageHeader?.SaleID ??
|
|
323
|
+
SaleID: t?.MessageHeader?.SaleID ?? R() ?? "",
|
|
324
324
|
ServiceID: t?.MessageHeader?.ServiceID ?? e.MessageReference?.ServiceID ?? "",
|
|
325
|
-
POIID: t?.MessageHeader?.POIID ??
|
|
325
|
+
POIID: t?.MessageHeader?.POIID ?? B() ?? ""
|
|
326
326
|
};
|
|
327
327
|
if (n.PaymentResponse) return { SaleToPOIResponse: {
|
|
328
328
|
MessageHeader: r,
|
|
@@ -341,7 +341,7 @@ var L = {
|
|
|
341
341
|
success: !1,
|
|
342
342
|
message: "Please pair your payment terminal before processing payments."
|
|
343
343
|
};
|
|
344
|
-
let n =
|
|
344
|
+
let n = R(), r = B(), i = () => ({
|
|
345
345
|
SaleToPOIRequest: {
|
|
346
346
|
MessageHeader: {
|
|
347
347
|
ProtocolVersion: "3.0",
|
|
@@ -363,15 +363,15 @@ var L = {
|
|
|
363
363
|
}
|
|
364
364
|
},
|
|
365
365
|
merchantAccount: this.config.merchantAccount
|
|
366
|
-
}, o = Date.now() +
|
|
366
|
+
}), o = Date.now() + me, s = ve(), c = $.child({ transactionId: e }), l = 0;
|
|
367
367
|
for (c.debug(a.PollTick, `Querying ${t} status`, { messageCategory: t }); Date.now() < o;) {
|
|
368
368
|
let t;
|
|
369
369
|
try {
|
|
370
|
-
let n = await this.terminalApi.post("/sync", i);
|
|
370
|
+
let n = await this.terminalApi.post("/sync", i());
|
|
371
371
|
if ("SaleToPOIRequest" in n.data) return {
|
|
372
372
|
success: !1,
|
|
373
373
|
serviceId: e,
|
|
374
|
-
message:
|
|
374
|
+
message: J(n.data)
|
|
375
375
|
};
|
|
376
376
|
if (!("TransactionStatusResponse" in n.data.SaleToPOIResponse)) return {
|
|
377
377
|
success: !1,
|
|
@@ -380,8 +380,8 @@ var L = {
|
|
|
380
380
|
};
|
|
381
381
|
t = n.data.SaleToPOIResponse.TransactionStatusResponse, s.reset();
|
|
382
382
|
} catch (t) {
|
|
383
|
-
if (!
|
|
384
|
-
let n =
|
|
383
|
+
if (!X(t)) {
|
|
384
|
+
let n = Y(t);
|
|
385
385
|
return c.error(a.PollTimeout, "Non-recoverable status-query error, failing fast", { error: t }), {
|
|
386
386
|
success: !1,
|
|
387
387
|
serviceId: e,
|
|
@@ -397,16 +397,16 @@ var L = {
|
|
|
397
397
|
continue;
|
|
398
398
|
}
|
|
399
399
|
let n = t.Response.ErrorCondition, r = t.Response.Result !== "Success";
|
|
400
|
-
if (r &&
|
|
400
|
+
if (r && _e(n)) {
|
|
401
401
|
if (Date.now() + 5e3 >= o) break;
|
|
402
402
|
l += 1, c.debug(a.PollTick, "Transaction still in progress", {
|
|
403
403
|
pollCount: l,
|
|
404
404
|
errorCondition: n
|
|
405
|
-
}), await f(
|
|
405
|
+
}), await f(pe);
|
|
406
406
|
continue;
|
|
407
407
|
}
|
|
408
408
|
if (r && n === "NotFound") {
|
|
409
|
-
let n =
|
|
409
|
+
let n = q(t.Response) ?? "No transaction found for the given ServiceID";
|
|
410
410
|
return c.warn(a.PurchaseFailed, "Terminal has no record of the transaction — safe to resubmit", { pollCount: l }), {
|
|
411
411
|
success: !1,
|
|
412
412
|
notFound: !0,
|
|
@@ -418,9 +418,9 @@ var L = {
|
|
|
418
418
|
if (!u) return {
|
|
419
419
|
success: !1,
|
|
420
420
|
serviceId: e,
|
|
421
|
-
message:
|
|
421
|
+
message: q(t.Response) ?? "No transaction found for the given ServiceID"
|
|
422
422
|
};
|
|
423
|
-
let d = u.SaleToPOIResponse.PaymentResponse, p = d.Response.Result === "Success", m = p ? "Transaction completed successfully" :
|
|
423
|
+
let d = u.SaleToPOIResponse.PaymentResponse, p = d.Response.Result === "Success", m = p ? "Transaction completed successfully" : q(d.Response) || "Transaction failed";
|
|
424
424
|
return p ? c.info(a.PurchaseOk, m, { pollCount: l }) : c.warn(a.PurchaseDeclined, m, {
|
|
425
425
|
pollCount: l,
|
|
426
426
|
errorCondition: n
|
|
@@ -439,7 +439,7 @@ var L = {
|
|
|
439
439
|
};
|
|
440
440
|
}
|
|
441
441
|
async getLastTransactionStatus() {
|
|
442
|
-
let e =
|
|
442
|
+
let e = fe();
|
|
443
443
|
return e ? this.getTransactionStatus(e.serviceId, e.messageCategory) : {
|
|
444
444
|
success: !1,
|
|
445
445
|
message: "No transaction found."
|
|
@@ -451,12 +451,12 @@ var L = {
|
|
|
451
451
|
success: !1,
|
|
452
452
|
message: "Please pair your payment terminal before processing payments."
|
|
453
453
|
};
|
|
454
|
-
let e =
|
|
454
|
+
let e = de();
|
|
455
455
|
if (!e) return {
|
|
456
456
|
success: !1,
|
|
457
457
|
message: "No running transaction to cancel"
|
|
458
458
|
};
|
|
459
|
-
let t =
|
|
459
|
+
let t = R(), n = B(), r = {
|
|
460
460
|
SaleToPOIRequest: {
|
|
461
461
|
MessageHeader: {
|
|
462
462
|
ProtocolVersion: "3.0",
|
|
@@ -478,7 +478,7 @@ var L = {
|
|
|
478
478
|
},
|
|
479
479
|
merchantAccount: this.config.merchantAccount
|
|
480
480
|
}, i = await this.terminalApi.post("/sync", r), a = i.data.SaleToPOIResponse.AbortResponse.Response.Result;
|
|
481
|
-
return a === "Success" &&
|
|
481
|
+
return a === "Success" && H(), {
|
|
482
482
|
success: a === "Success",
|
|
483
483
|
data: i.data,
|
|
484
484
|
message: a === "Success" ? "Payment cancellation successful" : i.data.SaleToPOIResponse.AbortResponse.Response.ErrorCondition || "Payment cancellation failed"
|
|
@@ -486,73 +486,73 @@ var L = {
|
|
|
486
486
|
} catch (e) {
|
|
487
487
|
return {
|
|
488
488
|
success: !1,
|
|
489
|
-
message:
|
|
489
|
+
message: F(e) ? e.response?.data?.message || e.message : "Failed to cancel payment"
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
494
|
//#endregion
|
|
495
495
|
//#region src/library/valpay/valpay.mapper.ts
|
|
496
|
-
function
|
|
496
|
+
function Se(e) {
|
|
497
497
|
let t = new URLSearchParams(e.Text), n = t.get("name"), r = t.get("value");
|
|
498
498
|
return n ? r ? `${n}: ${r}` : n : null;
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function Ce(e) {
|
|
501
501
|
let t = [];
|
|
502
502
|
for (let n of e.OutputContent.OutputText) {
|
|
503
|
-
let e =
|
|
503
|
+
let e = Se(n);
|
|
504
504
|
e === null ? t.length > 0 && t[t.length - 1] !== "" && t.push("") : t.push(e);
|
|
505
505
|
}
|
|
506
506
|
for (; t[0] === "";) t.shift();
|
|
507
507
|
for (; t[t.length - 1] === "";) t.pop();
|
|
508
508
|
return t.join("\n");
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function we(e) {
|
|
511
511
|
let t = {};
|
|
512
512
|
if (!("SaleToPOIResponse" in e)) return t;
|
|
513
513
|
let n = e.SaleToPOIResponse?.PaymentResponse?.PaymentReceipt;
|
|
514
514
|
if (!n) return t;
|
|
515
515
|
for (let e of n) {
|
|
516
|
-
let n =
|
|
516
|
+
let n = Ce(e);
|
|
517
517
|
n && (e.RequiredSignatureFlag ? t.signature = n : e.DocumentQualifier === "CashierReceipt" ? t.merchant = n : t.customer = n);
|
|
518
518
|
}
|
|
519
519
|
return t;
|
|
520
520
|
}
|
|
521
|
-
function
|
|
522
|
-
if (e.success) return
|
|
521
|
+
function Te(e) {
|
|
522
|
+
if (e.success) return y.Approved;
|
|
523
523
|
switch (e.data && "SaleToPOIResponse" in e.data ? e.data.SaleToPOIResponse.PaymentResponse.Response.ErrorCondition : void 0) {
|
|
524
524
|
case "Cancel":
|
|
525
|
-
case "Aborted": return
|
|
525
|
+
case "Aborted": return y.Cancelled;
|
|
526
526
|
case "Refusal":
|
|
527
527
|
case "Refused":
|
|
528
528
|
case "InvalidCard":
|
|
529
529
|
case "NotAllowed":
|
|
530
530
|
case "WrongPIN":
|
|
531
|
-
case "Busy": return
|
|
531
|
+
case "Busy": return y.Declined;
|
|
532
532
|
case "TimedOut":
|
|
533
|
-
case "Communication timeout": return
|
|
534
|
-
default: return
|
|
533
|
+
case "Communication timeout": return y.Timeout;
|
|
534
|
+
default: return y.Failed;
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function Ee(e) {
|
|
538
538
|
let t = e.data && "SaleToPOIResponse" in e.data ? e.data.SaleToPOIResponse.PaymentResponse : void 0, n = t?.PaymentResult?.AmountsResp, r = t?.PaymentResult?.PaymentInstrumentData?.CardData;
|
|
539
|
-
return
|
|
540
|
-
status:
|
|
539
|
+
return ee({
|
|
540
|
+
status: Te(e),
|
|
541
541
|
transactionId: t?.POIData?.POITransactionID.TransactionID ?? null,
|
|
542
542
|
amount: n ? g(n.AuthorizedAmount) : null,
|
|
543
543
|
tipAmount: n?.TipAmount === void 0 ? null : g(n.TipAmount),
|
|
544
544
|
maskedCard: r?.MaskedPan ?? null,
|
|
545
545
|
cardScheme: h(r?.PaymentBrand),
|
|
546
|
-
receipts: e.data ?
|
|
546
|
+
receipts: e.data ? we(e.data) : {},
|
|
547
547
|
message: e.message,
|
|
548
548
|
raw: e.data ?? null
|
|
549
549
|
});
|
|
550
550
|
}
|
|
551
551
|
//#endregion
|
|
552
552
|
//#region src/library/valpay/useValpay.ts
|
|
553
|
-
var
|
|
553
|
+
var De = ({ merchantAccount: n }) => {
|
|
554
554
|
r();
|
|
555
|
-
let a = new
|
|
555
|
+
let a = new xe({
|
|
556
556
|
currencyCode: t.value,
|
|
557
557
|
environment: e.value,
|
|
558
558
|
merchantAccount: n,
|
|
@@ -566,12 +566,12 @@ var Ee = ({ merchantAccount: n }) => {
|
|
|
566
566
|
}, s = () => {
|
|
567
567
|
a.unpair();
|
|
568
568
|
}, c = () => a.isPaired(), l = async (e, n, r) => {
|
|
569
|
-
let i = _(n), o = r?.tipAmount === void 0 ? void 0 : _(r.tipAmount), s =
|
|
569
|
+
let i = _(n), o = r?.tipAmount === void 0 ? void 0 : _(r.tipAmount), s = v({
|
|
570
570
|
message: `${e} of ${p(n, t.value)}${r?.tipAmount === void 0 ? "" : ` (+ ${p(r.tipAmount, t.value)} tip)`} in progress...`,
|
|
571
571
|
onCancel: () => {
|
|
572
572
|
s.progress(`Trying to cancel ${e.toLowerCase()}...`), a.cancelPayment();
|
|
573
573
|
}
|
|
574
|
-
}), c =
|
|
574
|
+
}), c = Ee(e === "Purchase" ? await a.makePayment(i, t.value, {
|
|
575
575
|
tipAmount: o,
|
|
576
576
|
isTipEnabled: r?.isTipEnabled
|
|
577
577
|
}) : await a.makeRefund(i, t.value, { originalTransactionId: r?.originalTransactionId }));
|
|
@@ -583,10 +583,10 @@ var Ee = ({ merchantAccount: n }) => {
|
|
|
583
583
|
isPaired: c,
|
|
584
584
|
purchase: (e, t) => l("Purchase", e, t),
|
|
585
585
|
refund: (e, t) => l("Refund", e, t),
|
|
586
|
-
getLastTransaction: async () =>
|
|
586
|
+
getLastTransaction: async () => Ee(await a.getLastTransactionStatus()),
|
|
587
587
|
raw: a
|
|
588
588
|
};
|
|
589
|
-
},
|
|
589
|
+
}, Oe = { class: "text-center" }, ke = { class: "mb-6" }, Ae = { class: "!mb-2 text-sm text-gray-500 dark:text-gray-300" }, je = { class: "!mb-2 text-sm text-gray-500 dark:text-gray-300" }, Me = { class: "mb-6 text-sm text-gray-500 dark:text-gray-300" }, Ne = { class: "!space-x-3" }, Pe = { key: 1 }, Fe = { class: "gap-3 flex items-center justify-end" }, Ie = /* @__PURE__ */ te({
|
|
590
590
|
__name: "PairValpay",
|
|
591
591
|
props: {
|
|
592
592
|
merchantId: {},
|
|
@@ -598,19 +598,19 @@ var Ee = ({ merchantAccount: n }) => {
|
|
|
598
598
|
"The terminal should be configured in your Adyen merchant account.",
|
|
599
599
|
"Click 'Fetch Terminals' to retrieve available terminals from your merchant account.",
|
|
600
600
|
"Enter your Sale ID (POS system identifier) and select a terminal to pair."
|
|
601
|
-
], n = e, { raw: r, pair: i, unpair: a } =
|
|
601
|
+
], n = e, { raw: r, pair: i, unpair: a } = De({ merchantAccount: String(n.merchantId) }), s = re("valpay.pairConfig", {
|
|
602
602
|
isPaired: !1,
|
|
603
603
|
lastPairedDate: "",
|
|
604
604
|
saleId: "",
|
|
605
605
|
terminalId: ""
|
|
606
|
-
}), f =
|
|
606
|
+
}), f = E([]), p = E(null), m = E(""), h = E(!1), g = E(!s.value.isPaired), _ = () => {
|
|
607
607
|
g.value = !1;
|
|
608
|
-
},
|
|
608
|
+
}, ee = () => {
|
|
609
609
|
s.value.isPaired = !1, a();
|
|
610
|
-
},
|
|
610
|
+
}, v = async () => {
|
|
611
611
|
try {
|
|
612
|
-
if (
|
|
613
|
-
|
|
612
|
+
if (ie.show(), !m.value || !p.value) {
|
|
613
|
+
A.create({
|
|
614
614
|
title: "Validation Error",
|
|
615
615
|
message: "Both Sale ID and Terminal ID are required."
|
|
616
616
|
});
|
|
@@ -621,41 +621,41 @@ var Ee = ({ merchantAccount: n }) => {
|
|
|
621
621
|
terminalId: p.value
|
|
622
622
|
});
|
|
623
623
|
if (!e.success) {
|
|
624
|
-
|
|
624
|
+
A.create({
|
|
625
625
|
title: "Pairing Failed!",
|
|
626
626
|
message: e.message ?? "Failed to pair terminal."
|
|
627
627
|
});
|
|
628
628
|
return;
|
|
629
629
|
}
|
|
630
|
-
s.value.isPaired = !0, s.value.lastPairedDate = /* @__PURE__ */ new Date(), s.value.saleId = m.value, s.value.terminalId = p.value,
|
|
630
|
+
s.value.isPaired = !0, s.value.lastPairedDate = /* @__PURE__ */ new Date(), s.value.saleId = m.value, s.value.terminalId = p.value, j.create({
|
|
631
631
|
type: "positive",
|
|
632
632
|
message: "Terminal paired successfully!"
|
|
633
633
|
});
|
|
634
634
|
} catch (e) {
|
|
635
|
-
|
|
635
|
+
A.create({
|
|
636
636
|
title: "Pairing Failed!",
|
|
637
637
|
message: e instanceof Error ? e.message : "Failed to pair terminal."
|
|
638
638
|
});
|
|
639
639
|
} finally {
|
|
640
|
-
|
|
640
|
+
ie.hide();
|
|
641
641
|
}
|
|
642
|
-
},
|
|
642
|
+
}, y = async () => {
|
|
643
643
|
try {
|
|
644
644
|
h.value = !0;
|
|
645
645
|
let e = await r.getConnectedTerminals(n.merchantId, n.accountId);
|
|
646
646
|
if (!e.success || !e.data) {
|
|
647
|
-
|
|
647
|
+
j.create({
|
|
648
648
|
type: "negative",
|
|
649
649
|
message: e.message || "Failed to fetch terminals"
|
|
650
650
|
});
|
|
651
651
|
return;
|
|
652
652
|
}
|
|
653
|
-
f.value = e.data.uniqueTerminalIds, f.value.length === 0 &&
|
|
653
|
+
f.value = e.data.uniqueTerminalIds, f.value.length === 0 && j.create({
|
|
654
654
|
type: "warning",
|
|
655
655
|
message: "No terminals found in your merchant account"
|
|
656
656
|
});
|
|
657
657
|
} catch {
|
|
658
|
-
|
|
658
|
+
j.create({
|
|
659
659
|
type: "negative",
|
|
660
660
|
message: "An error occurred while fetching terminals"
|
|
661
661
|
});
|
|
@@ -663,45 +663,45 @@ var Ee = ({ merchantAccount: n }) => {
|
|
|
663
663
|
h.value = !1;
|
|
664
664
|
}
|
|
665
665
|
};
|
|
666
|
-
return
|
|
666
|
+
return ne(y), (e, n) => (T(), x("div", null, [O(s).isPaired ? (T(), b(O(N), {
|
|
667
667
|
key: "paired",
|
|
668
668
|
class: "rounded-lg p-8 flex items-center justify-center",
|
|
669
669
|
flat: "",
|
|
670
670
|
bordered: ""
|
|
671
671
|
}, {
|
|
672
|
-
default:
|
|
673
|
-
|
|
674
|
-
name:
|
|
672
|
+
default: k(() => [S("div", Oe, [
|
|
673
|
+
S("div", ke, [w(O(se), {
|
|
674
|
+
name: O(l),
|
|
675
675
|
size: "4rem",
|
|
676
676
|
class: "text-green-500"
|
|
677
677
|
}, null, 8, ["name"])]),
|
|
678
|
-
n[6] ||=
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
678
|
+
n[6] ||= S("h2", { class: "mb-4 text-3xl font-bold" }, "Terminal Connected", -1),
|
|
679
|
+
S("p", Ae, [n[3] ||= C(" Sale ID: ", -1), S("b", null, D(O(s).saleId), 1)]),
|
|
680
|
+
S("p", je, [n[4] ||= C(" Terminal ID: ", -1), S("b", null, D(O(s).terminalId), 1)]),
|
|
681
|
+
S("p", Me, [n[5] ||= C(" Last paired: ", -1), S("b", null, D(new Date(O(s).lastPairedDate).toLocaleString()), 1)]),
|
|
682
|
+
S("div", Ne, [w(O(M), {
|
|
683
683
|
color: "primary",
|
|
684
684
|
unelevated: "",
|
|
685
685
|
"no-caps": "",
|
|
686
|
-
"icon-left":
|
|
686
|
+
"icon-left": O(o),
|
|
687
687
|
label: "Re-pair Terminal",
|
|
688
|
-
onClick:
|
|
688
|
+
onClick: ee
|
|
689
689
|
}, null, 8, ["icon-left"])])
|
|
690
690
|
])]),
|
|
691
691
|
_: 1
|
|
692
|
-
})) : (
|
|
692
|
+
})) : (T(), x("div", Pe, [g.value ? (T(), b(d, {
|
|
693
693
|
key: 0,
|
|
694
694
|
onNext: _,
|
|
695
695
|
steps: t
|
|
696
|
-
})) : (
|
|
696
|
+
})) : (T(), b(O(N), {
|
|
697
697
|
key: 1,
|
|
698
698
|
flat: "",
|
|
699
699
|
bordered: ""
|
|
700
700
|
}, {
|
|
701
|
-
default:
|
|
702
|
-
default:
|
|
703
|
-
default:
|
|
704
|
-
|
|
701
|
+
default: k(() => [w(O(ae), null, {
|
|
702
|
+
default: k(() => [n[7] ||= S("h3", { class: "mb-3 !text-xl font-semibold" }, "Pairing configuration", -1), w(O(oe), { onSubmit: v }, {
|
|
703
|
+
default: k(() => [
|
|
704
|
+
w(O(ce), {
|
|
705
705
|
label: "POS ID",
|
|
706
706
|
dense: "",
|
|
707
707
|
outlined: "",
|
|
@@ -712,7 +712,7 @@ var Ee = ({ merchantAccount: n }) => {
|
|
|
712
712
|
class: "mb-4",
|
|
713
713
|
"no-error-icon": ""
|
|
714
714
|
}, null, 8, ["modelValue", "rules"]),
|
|
715
|
-
|
|
715
|
+
w(O(le), {
|
|
716
716
|
label: "Select Terminal",
|
|
717
717
|
dense: "",
|
|
718
718
|
outlined: "",
|
|
@@ -731,28 +731,28 @@ var Ee = ({ merchantAccount: n }) => {
|
|
|
731
731
|
"options",
|
|
732
732
|
"rules"
|
|
733
733
|
]),
|
|
734
|
-
|
|
735
|
-
|
|
734
|
+
S("div", Fe, [
|
|
735
|
+
w(O(M), {
|
|
736
736
|
flat: "",
|
|
737
737
|
"no-caps": "",
|
|
738
|
-
"icon-left":
|
|
738
|
+
"icon-left": O(o),
|
|
739
739
|
label: "Fetch Terminals",
|
|
740
|
-
onClick:
|
|
740
|
+
onClick: y,
|
|
741
741
|
loading: h.value
|
|
742
742
|
}, null, 8, ["icon-left", "loading"]),
|
|
743
|
-
|
|
743
|
+
w(O(M), {
|
|
744
744
|
flat: "",
|
|
745
745
|
"no-caps": "",
|
|
746
746
|
label: "Back",
|
|
747
|
-
"icon-left":
|
|
747
|
+
"icon-left": O(c),
|
|
748
748
|
onClick: n[2] ||= (e) => g.value = !0
|
|
749
749
|
}, null, 8, ["icon-left"]),
|
|
750
|
-
|
|
750
|
+
w(O(M), {
|
|
751
751
|
type: "submit",
|
|
752
752
|
color: "primary",
|
|
753
753
|
unelevated: "",
|
|
754
754
|
"no-caps": "",
|
|
755
|
-
"icon-right":
|
|
755
|
+
"icon-right": O(u),
|
|
756
756
|
label: "Pair Device"
|
|
757
757
|
}, null, 8, ["icon-right"])
|
|
758
758
|
])
|
|
@@ -766,4 +766,4 @@ var Ee = ({ merchantAccount: n }) => {
|
|
|
766
766
|
}
|
|
767
767
|
});
|
|
768
768
|
//#endregion
|
|
769
|
-
export {
|
|
769
|
+
export { De as n, xe as r, Ie as t };
|
package/dist/valpay.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./valpay-
|
|
1
|
+
import { n as e, r as t, t as n } from "./valpay-MfJgW2Rh.js";
|
|
2
2
|
export { n as PairValpay, t as ValpayAPI, e as useValpay };
|