Fix LS close overlay event

This commit is contained in:
gbuomprisco
2024-12-23 08:31:40 +08:00
parent aa06f57454
commit b5a8a0a4d3

View File

@@ -6,7 +6,7 @@ interface LemonSqueezyWindow extends Window {
createLemonSqueezy: () => void;
LemonSqueezy: {
Setup: (options: {
eventHandler: (event: { event: string }) => void;
eventHandler: (event: { event: string } | string) => void;
}) => void;
Refresh: () => void;
Url: {
@@ -43,6 +43,14 @@ function useLoadScript(
if (onClose) {
win.LemonSqueezy.Setup({
eventHandler: (event) => {
if (typeof event === 'string') {
if (event === 'close') {
onClose();
}
return;
}
if (event.event === 'PaymentMethodUpdate.Closed') {
onClose();
}