diff --git a/src/client/Cosmetics.ts b/src/client/Cosmetics.ts index 01a4a5de0..bfd991c4a 100644 --- a/src/client/Cosmetics.ts +++ b/src/client/Cosmetics.ts @@ -41,9 +41,8 @@ export async function handlePurchase(priceId: string) { }, body: JSON.stringify({ priceId: priceId, - - successUrl: `${window.location.href}purchase-success`, - cancelUrl: `${window.location.href}purchase-cancel`, + successUrl: `${window.location.origin}#purchase-completed=true`, + cancelUrl: `${window.location.origin}#purchase-completed=false`, }), }, ); diff --git a/src/client/Main.ts b/src/client/Main.ts index 732a58c12..03d04c777 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -423,8 +423,25 @@ class Client { private handleHash() { const { hash } = window.location; + + const alertAndStrip = (message: string) => { + alert(message); + history.replaceState( + null, + "", + window.location.pathname + window.location.search, + ); + }; + if (hash.startsWith("#")) { const params = new URLSearchParams(hash.slice(1)); + if (params.get("purchase-completed") === "true") { + alertAndStrip("purchase succeeded"); + return; + } else if (params.get("purchase-completed") === "false") { + alertAndStrip("purchase failed"); + return; + } const lobbyId = params.get("join"); if (lobbyId && ID.safeParse(lobbyId).success) { this.joinModal.open(lobbyId);