Implemented Stripe Embedded Checkout Component;
Inclusion of .env files;
This commit is contained in:
@@ -2,10 +2,16 @@ from flask import Flask
|
||||
from flask_session import Session
|
||||
from backend.blueprints.utils import logged_in_user
|
||||
from flask_cors import CORS
|
||||
import os
|
||||
|
||||
print("Environment variables:")
|
||||
print(f"FLASK_SECRET_KEY: {os.getenv('FLASK_SECRET_KEY')}")
|
||||
print(f"STRIPE_SECRET_KEY: {os.getenv('STRIPE_SECRET_KEY')}")
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
app.config["SECRET_KEY"] = ""
|
||||
app.config["SECRET_KEY"] = os.getenv("FLASK_SECRET_KEY")
|
||||
app.config["SESSION_PERMANENT"] = False
|
||||
app.config["SESSION_TYPE"] = "filesystem"
|
||||
#! ↓↓↓ For development purposes only
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from flask import render_template, Blueprint
|
||||
from flask import Blueprint
|
||||
|
||||
main_bp = Blueprint("app", __name__)
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from flask import render_template, Blueprint, request, jsonify
|
||||
|
||||
import stripe
|
||||
from flask import Blueprint, request, jsonify
|
||||
import os, stripe
|
||||
|
||||
stripe_bp = Blueprint("stripe", __name__)
|
||||
|
||||
stripe.api_key = 'sk_test_51QikGlGk6yuk3uA8muEMPjMhUvbZWZiMCYQArZRXcFVn26hbt1kTz5yUVWkk3RQlltArbAXmVmkfEHU2z1Ch5Obv00Y03oT127'
|
||||
stripe.api_key = os.getenv("STRIPE_SECRET_KEY")
|
||||
|
||||
@stripe_bp.route('/create-checkout-session', methods=['POST'])
|
||||
def create_checkout_session():
|
||||
print("Creating checkout session")
|
||||
try:
|
||||
session = stripe.checkout.Session.create(
|
||||
ui_mode = 'embedded',
|
||||
@@ -32,7 +32,3 @@ def session_status():
|
||||
session = stripe.checkout.Session.retrieve(request.args.get('session_id'))
|
||||
|
||||
return jsonify(status=session.status, customer_email=session.customer_details.email)
|
||||
|
||||
@stripe_bp.route('/checkout', methods=['GET'])
|
||||
def checkout():
|
||||
return render_template("checkout.html")
|
||||
Reference in New Issue
Block a user