X
In the last article, I made a one time charge with the stripe api. I only used the card information, I didn't save any of the user's info. This time I'm going to create a charge with some of the user's details such as email, to send them a receipt of the purchase & the user's address info. By taking the user's address stripe will do a security check to see if the address info matches the card's info.
The second parameter of the stripe.createToken method is data object that takes the user's name & address info. We're going to use this method like we did in the last article except we're going to fill out the user's billing details.
On the server, we're going to retrieve the token from the client using the Stripe.tokens.retrieve() method. This gives us access to the user's address info & allows us to fill out the shipping information when I create the charge.
This method only takes one parameter the id of the token you want to get. In this case it's the token we made on the client & passed to the server.
Now I can fill out the email & shipping info with what the user gave me. Their is a receipt_email property in the stripe.create.charge() data object that will send you an email of the transaction when filled out. Their is also a shipping address object that will take your shipping address info.
When stripe creates the charge it will check the billing details, if any, with card number, zipcode & cvc code to see if the card is valid. Just a nice little security verification added by stripe.
You can see a finished project here.