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
0:02 with Stripe Checkout inside Anvil.
0:05 We had a button we clicked called Go Pro
0:08 or something like that
0:10 and we're going to go to Stripe Checkout and call charge.
0:13 We pass the amount in cents
0:15 and we're passing United States dollars, so $9.99.
0:20 We set the title of the thing that came up
0:22 that we're buying to be Fitnessd
0:24 and then the description to be a pro account at Fitnessd.
0:27 And, then we check if this dictionary that we get back
0:30 that we're calling charge has a result.
0:32 And, if the result is called succeeded
0:34 then we flip the user to pro in the database.
0:39 Here, we're actually just resetting the UI
0:42 in ours we just reloaded it
0:43 which triggered the UI to be reset.
0:46 Then, we said, well maybe else we'll try
0:47 to log a failed charge.
0:49 I don't know, but in reality most of the time
0:52 this is an exception, so we have to say try and then except
0:55 and then we check for either a cancellation or a true error.
0:58 And, that's it.
0:59 As long as you have a Stripe account
1:00 you can start taking money.
1:01 Stripe is great.
1:03 They send you money. They didn't hang on to it for a long time.
1:06 There's about a two-day latency from the time
1:08 that the money piles up in your account
1:10 until it is received in your bank.
1:12 Really nice, modern credit card processors.
1:15 Great option here to integrate with your apps.