fix
This commit is contained in:
@@ -21,6 +21,12 @@ import {
|
||||
setEmbedScanErrorForwarder,
|
||||
} from "./services/embedScanBridge";
|
||||
import { unlockScanBeep, installScanBeepGestureUnlock } from "./services/web";
|
||||
import {
|
||||
setEmbedPaymentDialogTarget,
|
||||
clearEmbedPaymentDialogTarget,
|
||||
resolveDelegatedPaymentDialog,
|
||||
handleEmbedPaymentDialogOnChild,
|
||||
} from "./services/payment/embedPaymentDialog";
|
||||
|
||||
const EMBED_SOURCE = "IScanEmbed";
|
||||
const EMBED_V = 1;
|
||||
@@ -253,6 +259,20 @@ function embedChildOnMessage(ev) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (data.kind === "paymentDialog") {
|
||||
handleEmbedPaymentDialogOnChild(data, (ok, result, error) => {
|
||||
window.parent.postMessage({
|
||||
source: EMBED_SOURCE,
|
||||
v: EMBED_V,
|
||||
kind: "paymentDialogResult",
|
||||
id: data.id,
|
||||
ok,
|
||||
result,
|
||||
error,
|
||||
}, "*");
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (data.kind === "invokeResult") {
|
||||
const pending = pendingInvokes[data.id];
|
||||
if (!pending) {
|
||||
@@ -336,6 +356,10 @@ function embedInvoke(methodKey, params) {
|
||||
function handleEmbedHostInvoke(lib, ev) {
|
||||
const data = ev.data;
|
||||
const { id, methodKey, params } = data;
|
||||
const shouldDelegatePaymentDialog = methodKey === "requestPayment" || methodKey === "closePaymentDialog";
|
||||
if (shouldDelegatePaymentDialog && ev.source) {
|
||||
setEmbedPaymentDialogTarget(ev.source);
|
||||
}
|
||||
const hydrated = hydrateEmbedParams(params || [], ev.source, ev.origin);
|
||||
Promise.resolve()
|
||||
.then(() => _exec(lib, methodKey, ...hydrated))
|
||||
@@ -376,6 +400,11 @@ function handleEmbedHostInvoke(lib, ev) {
|
||||
},
|
||||
ev.origin
|
||||
);
|
||||
})
|
||||
.then(() => {
|
||||
if (shouldDelegatePaymentDialog) {
|
||||
clearEmbedPaymentDialogTarget();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -435,6 +464,10 @@ export function installEmbedHost(lib) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (data.kind === "paymentDialogResult") {
|
||||
resolveDelegatedPaymentDialog(data);
|
||||
return;
|
||||
}
|
||||
if (data.kind !== "invoke") {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user