Integrating Stripe Payment Processing with Streamlit

Hello everyone!

I have implemented Google OAuth 2.0 with Streamlit, and now I want to use Stripe as a payment processor.

Are there any people here who have implemented a payment processor with Streamlit? Not necessarily Stripe, although that would be great, considering it’s my current implementation.

I would like to know how you managed the payment states provided by Stripe. How can I capture the information whether a payment has been made or not? I’m a bit stuck at this stage. Perhaps you can guide me towards some specific resources for Streamlit. Thank you very much!

1 Like

Hey @Cosmin_Andrei,

You can definitely integrate Stripe with Streamlit via the Stripe API – have you checked out Stripe’s API docs? I’d imagine that after a payment has been completed, you’d want to store that info using session state.

1 Like

Hi @Caroline I’m looking to do something similar to @Cosmin_Andrei with Stripe. Is there a step by step tutorial available somewhere demonstrating how to do something like this:

  1. User uploads a file or types in a URL link etc. and hits Submit button
  2. User goes through Stripe payment workflow
  3. Upon notification of successful payment, Streamlit displays a custom response based on the file or URL the user input

Hey @jaypinho and @Cosmin_Andrei,

@Tyler actually released a Streamlit component that allows you to create a Stripe paywall for your app – check it out!

Tweet / GitHub

2 Likes

Thanks @Caroline ! @Tyler was super helpful as I was building a custom implementation for my Streamlit app.

For anyone curious, my requirements were:

  1. I needed to accept one-off (not subscription) variable-priced (meaning they’re not set prices known in advance) payments via Stripe
  2. I needed Stripe to redirect back to the app upon payment completion so that the product can be delivered after the app has verified that the payment went through

For me the best solution turned out to be Stripe Checkout. Its API allows you to generate a Checkout session at any price, store arbitrary metadata in the Checkout object, and specify a redirect URL upon successful payment.

So what my app now does is:

  1. User puts in a podcast URL they want to summarize
  2. App calculates a price and generates a Stripe Checkout session with a custom transaction ID (which is included in the Checkout metadata object)
  3. User fills out the Stripe payment form
  4. Stripe redirects back to the app with a query param that includes the transaction ID
  5. App hits Stripe API to find Checkout session with matching transaction_id in the metadata object
  6. If it matches, app summarizes the episode

App is here if anyone’s curious: https://podcast.streamlit.app/

5 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.