improve checkout flow

This commit is contained in:
evanpelle
2025-07-12 10:22:24 -07:00
parent b07a59685e
commit fd947ba2a9
2 changed files with 15 additions and 2 deletions
+2 -2
View File
@@ -109,8 +109,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=success`,
cancelUrl: `${window.location.origin}?purchase=cancel`,
}),
},
);
+13
View File
@@ -367,6 +367,7 @@ class Client {
// Attempt to join lobby
this.handleHash();
this.handlePayment();
const onHashUpdate = () => {
// Reset the UI to its initial state
@@ -409,6 +410,18 @@ class Client {
}
}
private handlePayment() {
const params = new URLSearchParams(window.location.search);
const purchase = params.get("purchase");
if (purchase === "success") {
alert("purchase succeeded");
history.replaceState(null, "", window.location.pathname);
} else if (purchase === "cancel") {
alert("purchase failed");
history.replaceState(null, "", window.location.pathname);
}
}
private async handleJoinLobby(event: CustomEvent<JoinLobbyEvent>) {
const lobby = event.detail;
console.log(`joining lobby ${lobby.gameID}`);