Alert on payment success or failure. (#1705)

## Description:

Alert on payment success or failure.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I have read and accepted the CLA agreement (only required once).

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
This commit is contained in:
evanpelle
2025-08-04 20:06:55 -07:00
committed by GitHub
parent b5ac552029
commit fe948cb65e
2 changed files with 19 additions and 3 deletions
+2 -3
View File
@@ -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`,
}),
},
);
+17
View File
@@ -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);