Python for Entrepreneurs Transcripts
Chapter: Making money (credit cards and businesses)
Lecture: Concepts: Finalizing the purchase

Login or purchase this course to watch this video and the rest of the course contents.
0:02 We saw that once the Stripe checkout stuff is all done and everything passes and the user says "bye", Stripe verifies it,
0:12 then it does a POST back with a token to our own web application. And here is the code that ran that basically used the Stripe API
0:21 to do that final checkout to actually process the purchase, remember, we get a token but that token is not yet claimed,
0:29 but no purchase has actually happened until we call and create a charge on the Stripe API. So here we go, we've got a Stripe token and in this case
0:37 imagine we want to buy a course at Talk Python To Me Training, then, we're going to compute the price, remember, in cents,
0:45 we want this in cents, not dollars, we are going to set the description, this is going to be what shows up on their credit card,
0:52 what shows up in our records when we download the records from Stripe, things like that,
0:56 so we'll set the description, we have to set our API key to our secret key, our private key not, the public one, make sure that use in the live key
1:04 if you want things to be live, you also have to flip a switch on your account that says "going to live mode", don't forget that,
1:10 and then we just say stripe.charge.create we give it the amount, currency, the token as the source and the description
1:17 and you see we got back a tremendous amount of dictionaries or nested dictionaries
1:23 all sorts of information about fraud, about what the purchase id was and so on, so you can store as much or as little of that as like you can get back
1:32 to that information through the Stripe dashboard in your account, but sometimes, it's good to have it stored right in your database.
1:39 Hopefully that was not too intimidating, I think adding credit card payments
1:43 to your web app especially using Stripe checkout is really quite straightforward,
1:48 there is a few steps, but with the code that you've got from these samples, and the examples, the concepts and so on,
1:55 I think you should be able to get it working no problem, so best of luck and fingers crossed for that first credit card purchase to come through.

Talk Python's Mastodon Michael Kennedy's Mastodon