Highlights:
- Set up coupon system for Stripe payments
- Figured out how to debug with Flask (with debug toolbar, console messages, etc.)
- Used AJAX to check if coupon exists, then applies coupon
- Linked successful payment route to a confirmation page
- Resolved a number of formatting issues.
Issues I faced:
- Issue: I didn’t know how to debug in my Flask environment. I’m no longer working in a typical Python environment (I’m not using Jupyter Notebook here.) For example, when I made print statements, I wasn’t sure where I could see them. Do I get the messages in the terminal? In the Safari Inspector tool console?
- Solution: I found online that you can install a flask debugger toolbar - the flask_debugtoolbar. You have to pip install it and import it in the python code. You also have to do some command line prompts. See the docs here: https://flask-debugtoolbar.readthedocs.io/en/latest/
- In the pic below, you can see I got a debugging toolbar on the right side of the browser. Some of the messages go towards the Logging section. You can also see your GET / POST data in the Request Var section.
- Question: When a customer subscribes via Stripe, can I check if they are an existing customer? Check if they are already subscribed to me?
- Answer: Probably. We get the email address they type in. We can check that against our database.
- Question: If an existing customer accidentally pays again, can I cancel their payment?
- Answer: Maybe just refund them?
- Question: What data do I need to initially save in my database?
- Answer: Maybe start with their email address, name, date/time of payment, source?
- Issue: How do I add a coupon functionality to the Stripe Checkout widget?
- Solution: There’s no capability for Stripe Checkout. One option, which I’ll pursue in the next version, is to use a separate page and lay out Stripe Elements, where you can control the layout of the payment form. The quicker solution here is to ask for coupon details outside of the payment widget, then apply that to the final price paid.
- Issue: There are a couple of different environments / packages I have to work across: HTML, Javascript / jQuery, AJAX, Python, Flask. It’s taking a long time to learn how each one works.