abigail Posted June 30, 2015 Share Posted June 30, 2015 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. Link to comment Share on other sites More sharing options...
abigail Posted June 30, 2015 Author Share Posted June 30, 2015 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. Link to comment Share on other sites More sharing options...
Larry Posted July 2, 2015 Share Posted July 2, 2015 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. Link to comment Share on other sites More sharing options...
abigail Posted July 2, 2015 Author Share Posted July 2, 2015 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. Link to comment Share on other sites More sharing options...
Larry Posted July 3, 2015 Share Posted July 3, 2015 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. Link to comment Share on other sites More sharing options...
abigail Posted July 3, 2015 Author Share Posted July 3, 2015 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. Link to comment Share on other sites More sharing options...
Larry Posted July 3, 2015 Share Posted July 3, 2015 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. Link to comment Share on other sites More sharing options...
abigail Posted July 3, 2015 Author Share Posted July 3, 2015 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. Link to comment Share on other sites More sharing options...
Larry Posted July 4, 2015 Share Posted July 4, 2015 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. Link to comment Share on other sites More sharing options...
abigail Posted July 7, 2015 Author Share Posted July 7, 2015 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. Link to comment Share on other sites More sharing options...
Recommended Posts