#AlexT17

1 messages ยท Page 1 of 1 (latest)

west bobcatBOT
cerulean berry
#

What does it say in the browser console?

coarse granite
#

If I look in the Stripe portal for our account I can see the failed API attempts and the error message but it doesn't appear in the label text I have on the web page. I click on the submit button and nothing happens in the UI.

#

I'm forcing an error by attempting to set up an intent which has already succeeded.

cerulean berry
#

What does it say in the browser console though?

coarse granite
cerulean berry
#

Does that help at all? I'm seeing a ReferenceError error isn't defined in your code

coarse granite
#

I did wonder if it was a problem with the users so I cleared them down and created another one. Tried it again using card number 4000000000009995 with a new user and had the same problem. Should this not display an error? Using card 4000002500003155 works fine via additional authentication.

cerulean berry
#

It's a problem with your error handling. When you click the error is not defined error in the console, which line of code is it pointing to? Are there any more errors out of view that aren't in the above screenshot?

coarse granite
#

Ok, I'm not very knowledgeable with javascript so thought that this....
.then(function (result) {
if (result.error) {
const messageContainer = document.querySelector('#error-message');
messageContainer.textContent = error.message;
}
});
....was supposed to catch any errors and display them?

#

Ran the page again and these are all the console entries for the page.

#

If I fill in the fields with a card which is going to fail and submit I get this in the console.

velvet junco
#

Hello ๐Ÿ‘‹
Taking a look

coarse granite
#

Hi, thanks.

velvet junco
#

out of curiosity, what is the API error message you're seeing on the dashboard?

coarse granite
#

Which is what I'd expect to see appearing on the screen.

#

Appreciate it's not a flow you would normally follow once an intent is created but I'm trying to break the code to find weak points.

velvet junco
#

Gotcha... hmm the error in the console is quite abstract

coarse granite
#

I was hoping to be able to display something like "You already have a payment method set up" as an error, or something similar. At the moment there

#

there's no response from the UI at all.

velvet junco
#

give me just a second, trying to see if I can reproduce this

coarse granite
#

I'm debugging the code on my local machine rather than a server. It will get changed before publishing.

velvet junco
#

can you try removing window.location.href = and only set the URL

#

try http instead of https (unless you have an SSL cert for localhost)

coarse granite
#

Sorry, if you mean the window.location.... that's already been removed so ignore.

velvet junco
#

gotcha

coarse granite
#

We have an SSL cert

#

Works great if the process succeeds, just not when there's an error so I think the https is ok.

velvet junco
#

ah could you change following
messageContainer.textContent = error.message; code to

messageContainer.textContent = result.error.message;

coarse granite
#

Let me try it.

velvet junco
#

yup looks like that was the issue
Your code works on my end

coarse granite
#

Yep, it's not getting stuck now but it's also not erroring and stopping a user setting multiple setup intents using the same card. Is that right?

velvet junco
#

yeah I don't think the API checks if there's already a card setup

#

You would want to check this on your end

coarse granite
#

Do I need to do that check in my code then as my test user now has three identical cards associated with their account.

#

What happens with this situation when a payment intent is set up? I'm guessing each of the three cards has a unique stripe ID?

velvet junco
#

What happens with this situation when a payment intent is set up? I'm guessing each of the three cards has a unique stripe ID?
Yes that's correct.
We have a video guide on how you can deduplicate payment methods
https://www.youtube.com/watch?v=MvMmOWWHjVo

coarse granite
#

Great, thanks for all your help in sorting this.

velvet junco
#

NP! ๐Ÿ™‚ Glad I could help

#

Good Luck