#infiniluxe

1 messages · Page 1 of 1 (latest)

proven yarrowBOT
vague latch
#

👋 happy to help

stray egret
#

I do not have logs error

rain snow
#

would you have a bit more context then like the exact code you're using, the guide you're following, details of what result/value you're expecting to see and what you see instead?

stray egret
#

function createToken() {
const stripe = Stripe(
"pk_test_"
);
const myForm = document.querySelector(".my-form");
myForm.addEventListener("submit", handleForm);

function handleForm(event) {
event.preventDefault();

stripe.createToken("account", {
  business_type: "company",
  tos_shown_and_accepted: true,
}).then((result) => {
  if (result.token) {
    const tokenAccountInput = document.querySelector("#token-account");
    tokenAccountInput.removeAttribute("disabled");
    tokenAccountInput.value = result.token.id;
  } else {
    alert("Error token.");
  }
});

}

}

function SendToXano() {
const xano_input = {
email: document.getElementById("email").value,
password: document.getElementById("password").value,
token: document.getElementById("token-account").value,
};
fetch("[YOUR XANO SIGNUP ENDPOINT URL HERE]", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(xano_input),
})
.then((res) => res.json())
.then((json) => {
const xanoResponse = json;
console.log(xanoResponse);
const hasKey = Object.keys(xanoResponse).includes("authToken");
console.log(hasKey);
if (hasKey === false) {
alert("L'utilisateur existe déjà.");
} else {
alert("Nous avons un authToken !");
const authToken = xanoResponse.authToken;
localStorage.setItem("authToken", authToken);
location.href = "[WHERE TO REDIRECT THE USER AFTER SIGNUP]";
}
});
}

#

I removed the link and api

rain snow
#

thanks. And where excatly in this code does the issue arise?

stray egret
#

In my console I get a "thanks. And where excatly in this code does the issue arise?"

#

An invalid form control with name='token-account' is not focusable.

stone mountain
#

Could you please share a screenshot?

stray egret
rain snow
#

sounds like you don't have an element with the ID token-account in your HTML. Or if you do generally, you don't have it at the time that you're running that code(for example if it doesn't exist in the DOM at the time you call createToken).

It's hard for us to help, we don't have as much access to your code and HTML set up as you do. Does the above make sense?

stray egret
#

i'm on webflow for the front end and slater for the front end code and xano for the back end. i'd have to wait for the response from token stripe to continue my javascript code. if i understand correctly
?

rain snow
#

I don't know what slater or xano are, sorry.

But depending on what you're trying to do, sometimes you need to create an AccountToken on the frontend and then submit it to your backend yes, such as if you're using Stripe Connect with a French platform and this is the flow where you let the end-user sign up for a Stripe account on your platform.

stray egret
#

yes I'm doing a french platform with stripeConnect and it asks me for the token. yes my request is frontend for the token.

rain snow
#

sounds good! I can try to help but I don't really understand what exact problem you've run into and where in your code you're stuck.

#

I'd add some logs/debugging and try to figure out something like which exact line of code does something you don't expect or is throwing an error.

stray egret
rain snow
#

well it's because you have a hidden field for the token, but you mark it as required

stray egret
#

I don't have a token-account

#

You just got a form submission!

Form
my-form

Site
sejour serein

Submitted content
Email One 2: seillier.alexandre@orange.fr
token-account:
Password One 2: (removed)

Number of submissions received
1/50 this month
January 1st – January 31st

rain snow
#

so obviously without that there would be no token created.

is there another developer at your company that you could pair with on building this?

stray egret
#

I don't know it's in the webflow platform

#

le code stripe est dans slater

#

the code is functional in slater

rain snow
#

I don't know what that means sorry.

stray egret
#

slater is a code platform for webflow to dev. faster without all the page reloading each time.

rain snow
#

ok.

stray egret
#

I'm going to test the javascript directly on the page

rain snow
#

so going back to what I mentioned earlier : I'd suggest that you add some logs/debugging and try to figure out something like which exact line of code does something you don't expect or is throwing an error.

stray egret
#

yes, I'll do that for sure.