Subscription with Stripe

In order to set up your Stripe (the best and easiest payment infrastructure in the world), go to Stripe.com and make an account. Once you make an account, you need to make a payment subscription link (which is in test mode by default) and add the link to your app (currently held in streamlit_app.py). If the user to your app logs in and has not already signed up and paid via Stripe, they will be asked to subscribe before they can see the rest of the app.

The subscription link should be added to secrets.toml like this.

stripe_link = 'https://buy.stripe.com/test_...'`

You also need to create an Standard API key, which just like subscription links have test options as well. Store your API key in your secrets file as stripe_api_key and you're off to the races. If you make a restricted API key instead of a Standard key, make sure to add read permission on Customers

Stripe API rest

The API key should be added to secrets.toml like this

stripe_api_key = 'sk_...'`

By default this repo links to creating test subscription links and test api keys (you probably already noticed the 'test' in the Stripe dashboard, the subscription link, and in our example api key). When you launch your app and want folks to pay real money, you will need to create production links and api keys from your Stripe dashboard and use those instead. While you are testing out the Stripe part of your code, you can use Stripe's test cards instead of inputting your own credit card info! To run st-paywall in test mode, add the following to your secrets file.

testing_mode = true

Then, the package will look for the following secrets. Otherwise, it will look for the production api and link secrets. I highly encourage you to start out in test mode!

stripe_api_key_test = 'sk_test_...'`
stripe_link_test = 'https://buy.stripe.com/test_...'`

Once you decide to leave test mode and publish your subscription app, it is a good idea to have Stripe send the user back to your app once they've subscribed. To do this, go to the payment links page, edit your payment link, click 'After payment' and fill out your app's url.

Payment Link After