tevrocsdk 0.1.40 → 0.1.42
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 +516 -516
- package/package.json +20 -20
- package/tevroc-sdk.esm.js +5 -48
- package/tevroc-sdk.min.js +31 -31
- package/tevroc-sdk.umd.js +5 -48
package/tevroc-sdk.umd.js
CHANGED
|
@@ -26284,7 +26284,7 @@ var Tevroc = (() => {
|
|
|
26284
26284
|
if (i4 !== -1) googleListeners.splice(i4, 1);
|
|
26285
26285
|
};
|
|
26286
26286
|
}
|
|
26287
|
-
var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener,
|
|
26287
|
+
var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, closeAllTauriWebviews, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
|
|
26288
26288
|
var init_useGoogleAuth = __esm({
|
|
26289
26289
|
"src/services/useGoogleAuth.js"() {
|
|
26290
26290
|
init_esm3();
|
|
@@ -26296,8 +26296,6 @@ var Tevroc = (() => {
|
|
|
26296
26296
|
authWindowRef = null;
|
|
26297
26297
|
authCleanupTimer = null;
|
|
26298
26298
|
authMessageListener = null;
|
|
26299
|
-
authTauriUnlisten = null;
|
|
26300
|
-
authHandled = false;
|
|
26301
26299
|
closeAllTauriWebviews = async () => {
|
|
26302
26300
|
if (!isTauri) return;
|
|
26303
26301
|
try {
|
|
@@ -26334,14 +26332,6 @@ var Tevroc = (() => {
|
|
|
26334
26332
|
window.removeEventListener("message", authMessageListener);
|
|
26335
26333
|
authMessageListener = null;
|
|
26336
26334
|
}
|
|
26337
|
-
if (authTauriUnlisten) {
|
|
26338
|
-
try {
|
|
26339
|
-
await authTauriUnlisten();
|
|
26340
|
-
} catch (e2) {
|
|
26341
|
-
console.warn("Error removing Tauri auth listener:", e2);
|
|
26342
|
-
}
|
|
26343
|
-
authTauriUnlisten = null;
|
|
26344
|
-
}
|
|
26345
26335
|
if (authWindowRef) {
|
|
26346
26336
|
const currentAuthWindow = authWindowRef;
|
|
26347
26337
|
authWindowRef = null;
|
|
@@ -26375,8 +26365,6 @@ var Tevroc = (() => {
|
|
|
26375
26365
|
};
|
|
26376
26366
|
handleCallback = async (url) => {
|
|
26377
26367
|
try {
|
|
26378
|
-
if (authHandled) return;
|
|
26379
|
-
authHandled = true;
|
|
26380
26368
|
await cleanupAuthWindow();
|
|
26381
26369
|
if (!url?.includes("token=")) return;
|
|
26382
26370
|
const params = new URLSearchParams(url.split("?")[1]);
|
|
@@ -26458,17 +26446,6 @@ var Tevroc = (() => {
|
|
|
26458
26446
|
win.once("tauri://error", (e2) => {
|
|
26459
26447
|
console.error("Auth window error:", e2);
|
|
26460
26448
|
});
|
|
26461
|
-
try {
|
|
26462
|
-
const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
|
|
26463
|
-
authTauriUnlisten = await listen2("google-auth", async (event) => {
|
|
26464
|
-
const token = event?.payload?.token;
|
|
26465
|
-
if (!token) return;
|
|
26466
|
-
const callbackUrl = `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${encodeURIComponent(token)}`;
|
|
26467
|
-
await handleCallback(callbackUrl);
|
|
26468
|
-
});
|
|
26469
|
-
} catch (e2) {
|
|
26470
|
-
console.warn("Tauri google-auth listener install failed:", e2);
|
|
26471
|
-
}
|
|
26472
26449
|
return;
|
|
26473
26450
|
}
|
|
26474
26451
|
const isLocalhost = true;
|
|
@@ -26601,38 +26578,19 @@ var Tevroc = (() => {
|
|
|
26601
26578
|
externalCallback
|
|
26602
26579
|
);
|
|
26603
26580
|
});
|
|
26604
|
-
await listen2("payment-result", async (event) => {
|
|
26605
|
-
if (paymentWindowRef) {
|
|
26606
|
-
try {
|
|
26607
|
-
await paymentWindowRef.close();
|
|
26608
|
-
paymentWindowRef = null;
|
|
26609
|
-
} catch (e2) {
|
|
26610
|
-
console.warn("Error closing Tauri payment window:", e2);
|
|
26611
|
-
}
|
|
26612
|
-
}
|
|
26613
|
-
const payload = event?.payload || {};
|
|
26614
|
-
const params = new URLSearchParams();
|
|
26615
|
-
if (payload.status) params.set("status", payload.status);
|
|
26616
|
-
if (payload.mode) params.set("mode", payload.mode);
|
|
26617
|
-
if (payload.app) params.set("app", payload.app);
|
|
26618
|
-
if (payload.checkoutId) params.set("checkoutId", payload.checkoutId);
|
|
26619
|
-
const url = `?${params.toString()}`;
|
|
26620
|
-
handlePaymentCallback(url, externalCallback);
|
|
26621
|
-
});
|
|
26622
26581
|
}
|
|
26623
26582
|
};
|
|
26624
26583
|
createPayment = async (amountZAR, {
|
|
26625
26584
|
appId = "tevrocsoft",
|
|
26626
26585
|
serviceUrl = "https://tevrocsoftapi.netlify.app",
|
|
26627
26586
|
payAccount = "default",
|
|
26628
|
-
companyId,
|
|
26629
26587
|
externalCallback = () => {
|
|
26630
26588
|
}
|
|
26631
26589
|
} = {}) => {
|
|
26632
26590
|
await initializePayment(externalCallback);
|
|
26633
26591
|
const cents = Math.round(Number(amountZAR) * 100);
|
|
26634
26592
|
const basePaymentUrl = `${serviceUrl.replace(/\/$/, "")}/yoco-pay`;
|
|
26635
|
-
const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}&account=${payAccount}
|
|
26593
|
+
const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}&account=${payAccount}`;
|
|
26636
26594
|
console.log(basePaymentUrl, paymentUrl);
|
|
26637
26595
|
if (isCapacitor) {
|
|
26638
26596
|
await Browser2.open({
|
|
@@ -26641,7 +26599,7 @@ var Tevroc = (() => {
|
|
|
26641
26599
|
return;
|
|
26642
26600
|
}
|
|
26643
26601
|
if (isTauri) {
|
|
26644
|
-
const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}&account=${payAccount}
|
|
26602
|
+
const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}&account=${payAccount}`;
|
|
26645
26603
|
const win = new WebviewWindow("payment", {
|
|
26646
26604
|
url,
|
|
26647
26605
|
title: "Complete Payment",
|
|
@@ -26661,7 +26619,7 @@ var Tevroc = (() => {
|
|
|
26661
26619
|
}
|
|
26662
26620
|
const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
|
|
26663
26621
|
const mode = isLocalhost ? "localhost" : "netlify";
|
|
26664
|
-
const finalUrl = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}
|
|
26622
|
+
const finalUrl = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}`;
|
|
26665
26623
|
try {
|
|
26666
26624
|
const popup = window.open(finalUrl, "yocoPayment", "width=500,height=650");
|
|
26667
26625
|
if (!popup) {
|
|
@@ -41499,13 +41457,12 @@ var Tevroc = (() => {
|
|
|
41499
41457
|
}
|
|
41500
41458
|
function createPaymentApi(client) {
|
|
41501
41459
|
return {
|
|
41502
|
-
create: async ({ amountZAR, appId = "tevrocsoft", mode = "web", account = "default",
|
|
41460
|
+
create: async ({ amountZAR, appId = "tevrocsoft", mode = "web", account = "default", externalCallback = void 0 } = {}) => {
|
|
41503
41461
|
return await createPayment(amountZAR, {
|
|
41504
41462
|
appId,
|
|
41505
41463
|
serviceUrl: client.serviceUrl,
|
|
41506
41464
|
mode,
|
|
41507
41465
|
payAccount: account,
|
|
41508
|
-
companyId,
|
|
41509
41466
|
externalCallback
|
|
41510
41467
|
});
|
|
41511
41468
|
},
|