mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:10:42 +00:00
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:
@@ -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`,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user