Anvil: Web Apps with Nothing but Python Transcripts
Chapter: Ecommerce and accepting payments
Lecture: Concept: Charging credit cards with Stripe and Anvil

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's just quickly review how we charged a credit card with Stripe Checkout inside Anvil. We had a button we clicked called Go Pro
0:09 or something like that and we're going to go to Stripe Checkout and call charge. We pass the amount in cents
0:16 and we're passing United States dollars, so $9.99. We set the title of the thing that came up that we're buying to be Fitnessd
0:25 and then the description to be a pro account at Fitnessd. And, then we check if this dictionary that we get back
0:31 that we're calling charge has a result. And, if the result is called succeeded then we flip the user to pro in the database.
0:40 Here, we're actually just resetting the UI in ours we just reloaded it which triggered the UI to be reset. Then, we said, well maybe else we'll try
0:48 to log a failed charge. I don't know, but in reality most of the time this is an exception, so we have to say try and then except
0:56 and then we check for either a cancellation or a true error. And, that's it. As long as you have a Stripe account you can start taking money.
1:02 Stripe is great. They send you money. They didn't hang on to it for a long time. There's about a two-day latency from the time
1:09 that the money piles up in your account until it is received in your bank. Really nice, modern credit card processors.
1:16 Great option here to integrate with your apps.


Talk Python's Mastodon Michael Kennedy's Mastodon