Stripe integration flow
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user