Learn how to take online payments using Anvil and Stripe (written version below).
Find out more about accepting payments online - check out the Stripe section of the Anvil reference manual.
Prefer reading to watching? Here’s a written version.
We enable the Stripe Service:
We then log in to an existing Stripe account. If you don’t have an account, don’t worry - Stripe accounts are free and signup takes a few minutes.
The Stripe Service is in Test Mode when you start it up, which means the service doesn’t actually charge anybody’s account.
Write some code | 0:42 - 1:06
def button_1_click(self, **event_args): """This method is called when the button is clicked.""" c = stripe.checkout.charge(currency="GBP", amount=100) print(c)
Get paid | 1:06 - 1:49
Let’s try it out - when the user clicks on the Button, they are presented with a payment dialog.
We make a payment from card number
4242 4242 4242 4242. This is a test card that only works in test mode.
The Output Console shows the return value of the
charge function - it contains all available information about
the transaction. You could use this to audit your transactions and run analytics. It includes a URL that allows
you to look up the transaction in the Stripe dashboard later.
See the Stripe Service used in a production-scale app. We built an app to take online parking meter payments in just 90 minutes. You can read about how it works and clone the app into your own Anvil account.
If you’d like to learn the basics of Anvil, start with the Hello, World! tutorial.