Jump to content
Larry Ullman's Book Forums

Recommended Posts

In a previous post I mentioned this but I start new topic now.

The issue is I cannot get the name and address information to Stripe.

By email Stripe support thought my form was correct and asked how my javascript is passing in the data.

(I am using your code.)

So I looked at buy.js and it appears this is where I should include those fields, so I tried that but now my charge does not go though correctly.

And if there is any error reported from this buy.js script, it flashes on the screen and then scrolls off (more accurately is covered up).

I have seen these errors flash on the screen before and I would like to know how I can keep those errors showing.

This time I don't see anything flash but the charge does not come through because my form shows again and my debugging line does not print the charge information.

Here is my code where I get the values:

var name = $('.name').val(), address_line1 = $('.address_line1').val(), address_line2 = $('.address_line2').val(), address_city = $('.address_city').val(),address_state = $('.address_state').val(), address_zip = $('.address_zip').val(), address_country = $('.address_country').val();

And here is the code where I create the token:

Stripe.card.createToken({
  number: ccNum,
  cvc: cvcNum,
  exp_month: expMonth,
  exp_year: expYear,
  name: name, 
  address_line1: address_line1, 
  address_line2: address_line2, 
  address_city: address_city, 
  address_state: address_state, 
  address_zip: address_zip, 
  address_country: address_country 
}, 
stripeResponseHandler);

And also, if this where I pass through this information, should I also do a validate check on them.

Share this post


Link to post
Share on other sites

When I ran it again, the charge goes through successfully but no name/address information goes through.

One of the Stripe support people asked me to send him my code.

Share this post


Link to post
Share on other sites

You can send your code to Stripe. Or you can debug this yourself using the browser's developer tools or Firebug, setting a breakpoint to stop the submission of the form and inspect the values of the variables. And, again, your Stripe logs will show both the values sent to Stripe in the request and the response Stripe gave. 

Share this post


Link to post
Share on other sites

I already know the values are being set in the form.

I think I am passing them to Stripe correctly but there is no data there, even at the dashboard.

I already sent my code to Stripe but I have not heard anything back yet.

Share this post


Link to post
Share on other sites

Okay, if there's no data in your Stripe logs, and you're sure you're looking at the right requests, then the problem is in your JavaScript. Again, the best way to debug this is to use breakpoints to halt the execution of the JavaScript. You can also open the developer tools and look at the network requests to view the particulars of the Ajax request to Stripe, including the data sent there. 

Share this post


Link to post
Share on other sites

Here is the thing. I really don't know javascript.

Maybe I will have to learn it now.

But why should there be a problem with the javascript to begin with?

I didn't write any of that javascript. buy.js is from you and the rest of it is from Stripe.

Share this post


Link to post
Share on other sites

Ah, well if you don't know JavaScript, you'll probably have a harder time customizing this. As for why there's a problem, it's because you're customizing it. The JavaScript from Stripe works, period. My JavaScript is in buy.js, and it works fine, too, for what it does. But you're changing the code to make it do additional things, specifically send additional values in the token request. So there isn't a problem in the JavaScript to begin with, but it sounds like there's a problem in the JavaScript you've edited. 

Share this post


Link to post
Share on other sites

Maybe you can point out that error:

// Get the values:
  var ccNum = $('.card-number').val(), cvcNum = $('.card-cvc').val(), expMonth = $('.card-expiry-month').val(), expYear = $('.card-expiry-year').val();
// added by arlene
  var name = $('.name').val(), address_line1 = $('.address_line1').val(), address_line2 = $('.address_line2').val(), address_city = $('.address_city').val(), address_state = $('.address_state').val(), address_zip = $('.address_zip').val(), address_country = $('.address_country').val();

and

// name and address fields added by arlene
// Get the Stripe token:
Stripe.card.createToken({
  number: ccNum,
  cvc: cvcNum,
  exp_month: expMonth,
  exp_year: expYear,
  name: name, 
  address_line1: address_line1, 
  address_line2: address_line2, 
  address_city: address_city, 
  address_state: address_state, 
  address_zip: address_zip, 
  address_country: address_country 
}, stripeResponseHandler);

}

I should also mention that Stripe tech support said my form needed to have class="address_line1", which I added but that still did not get the data through.

Share this post


Link to post
Share on other sites

I don't see any obvious error here, although you haven't shared the form itself. Your best bet is to see the JavaScript error as it runs in the browser. You can use Firebug or the developer tools to do that. Again, the developer tools will also show you your network requests. If the form submission is not allowing you to see the JavaScript error, you should stop the submission of the form by commenting out that line in your code. 

 

I think you'll be much happier and much less frustrated if you use this as an opportunity to pick up the basics of debugging JavaScript using browser tools. 

 

Also, a clumsy shortcut is mentioned here: https://stripe.com/docs/stripe.js You can pass a reference to the form element to createToken and Stripe will automatically find the relevant values. 

Share this post


Link to post
Share on other sites

I found out from Stripe tech support said:

Checkout doesn't collect address data, so you will need to use a custom Stripe.js integration in order to collect that information.

Which they really should do to help us defend against scammers.

But anyway, when I first started asking you both about this question, I was not using Checkout and the information you provide below is exactly what was not working for me. I did not try to do it with a form in the token, however.

But I want to stick with Checkout so I will leave the manual version unsolved.

 

Also, a clumsy shortcut is mentioned here: https://stripe.com/docs/stripe.js You can pass a reference to the form element to createToken and Stripe will automatically find the relevant values. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...