Stripe integration flow

This commit is contained in:
metacryst
2026-03-05 00:29:34 -06:00
parent bdd260c2b5
commit 661bf86a1a
17 changed files with 303 additions and 117 deletions

View File

@@ -27,23 +27,30 @@ let Global = class {
return json
}
async handleStripeOnboarding() {
const params = new URLSearchParams(window.location.search);
const code = params.get("code");
const { returnTo, networkId } = JSON.parse(atob(params.get("state")));
if (code) {
console.log("success!: ", code)
await fetch("/api/stripe/onboarded", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code, networkId })
});
window.location.href = returnTo
} else {
throw new Error("Stripe code is not present!")
}
}
onNavigate = async () => {
console.log("onnavigate", this.getFirstPathSegment())
if(this.getFirstPathSegment() === "stripe") {
const params = new URLSearchParams(window.location.search);
const code = params.get("code");
if (code) {
console.log("success!: ", code)
await fetch("/api/stripe/connect", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code })
});
} else {
throw new Error("Stripe code is not present!")
}
this.handleStripeOnboarding()
}
let selectedNetwork = this.networkFromPath()