Python for Entrepreneurs Transcripts
Chapter: Making money (credit cards and businesses)
Lecture: Concepts: Finalizing the purchase
0:02 We saw that once the Stripe checkout stuff is all done and everything passes
0:08 and the user says "bye", Stripe verifies it,
0:11 then it does a POST back with a token to our own web application.
0:15 And here is the code that ran that basically used the Stripe API
0:20 to do that final checkout to actually process the purchase,
0:24 remember, we get a token but that token is not yet claimed,
0:28 but no purchase has actually happened until we call and create a charge on the Stripe API.
0:33 So here we go, we've got a Stripe token and in this case
0:36 imagine we want to buy a course at Talk Python To Me Training, then,
0:40 we're going to compute the price, remember, in cents,
0:44 we want this in cents, not dollars,
0:47 we are going to set the description, this is going to be what shows up on their credit card,
0:51 what shows up in our records when we download the records from Stripe, things like that,
0:55 so we'll set the description, we have to set our API key to our secret key,
0:59 our private key not, the public one, make sure that use in the live key
1:03 if you want things to be live, you also have to flip a switch on your account
1:07 that says "going to live mode", don't forget that,
1:09 and then we just say stripe.charge.create
1:12 we give it the amount, currency, the token as the source and the description
1:16 and you see we got back a tremendous amount of dictionaries or nested dictionaries
1:22 all sorts of information about fraud, about what the purchase id was and so on,
1:27 so you can store as much or as little of that as like you can get back
1:31 to that information through the Stripe dashboard in your account,
1:34 but sometimes, it's good to have it stored right in your database.
1:38 Hopefully that was not too intimidating, I think adding credit card payments
1:42 to your web app especially using Stripe checkout is really quite straightforward,
1:47 there is a few steps, but with the code that you've got from these samples,
1:51 and the examples, the concepts and so on,
1:54 I think you should be able to get it working no problem,
1:57 so best of luck and fingers crossed for that first credit card purchase to come through.