#rfrisch43

1 messages · Page 1 of 1 (latest)

lunar ospreyBOT
fervent prism
#

Hello

karmic raft
#

hello!

fervent prism
#

Hmm it should error if you attempt to do this in live mode.

#

We force TLS for Stripe.js

karmic raft
#

Hmm..yes, I would assume that is the case. Is there any way for me to test this locally? In development, I do something like this:

` stripe.createToken(card)
.then(function(result) {
if (result.error) {
errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
manage_submit_btn(false)
} else {
hiddenInput = document.createElement('input');
form = $('.submission_form')[0];
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeToken');
hiddenInput.setAttribute('value', result.token.id);
form.appendChild(hiddenInput);
manage_form_submission()
}
});

#

Which lets my submit the form, but I them get an SSL error trying to complete the charge.

#

Correction: I'm getting the SSL error in production after a successful form submission.

fervent prism
#

Yeah I don't think you can test this locally. I'm confused though, why are you worried about catching this error?

karmic raft
#

I'm sure I'm missing something but it appears that that the token doesnt get set but the form still gets submitted which is causing other errors on the server side.

fervent prism
#

What do you mean by "the token doesn't get set"?

#

stripe.createToken just creates a Token in your account

#

But you must then handle it from your server

karmic raft
#

Let me ask it a different way. If createToken returns result.error do I need to still call event.preventDefault() to stop the form from submitting?

fervent prism
#

It should error after the form is already submitted, no?

#

Like stripe.createToken is within your submit handler, right?

karmic raft
#

yes, its in the submit handler but the form is still submitting even when createToken returns an error which then causes other issues since the token would not have been created or added to the form.

#

I think i just need to call event.preventDefault() when result.error is returned.

#

to stop the form from submitting with no token (which then causes other issues with form submission on the server side)

#

I was just hoping for a way to test this locally.

tulip night
#

Yes if you depend on the token in your form submission you'll need to manage the error cases

karmic raft
#

thx