feat: open checkout page

This commit is contained in:
Zamitto 2024-10-21 15:30:38 -03:00
parent 6ef1135ba2
commit 21fecb2c4e
6 changed files with 32 additions and 8 deletions

View file

@ -0,0 +1,22 @@
import { shell } from "electron";
import { registerEvent } from "../register-event";
import { userAuthRepository } from "@main/repository";
import { HydraApi } from "@main/services";
const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
const userAuth = await userAuthRepository.findOne({ where: { id: 1 } });
if (!userAuth) {
return;
}
const paymentToken = await HydraApi.post("/auth/payment", {
refreshToken: userAuth.refreshToken,
}).then((response) => response.accessToken);
shell.openExternal(
"https://checkout.hydralauncher.gg/?token=" + paymentToken
);
};
registerEvent("openCheckout", openCheckout);