added beginnings of stripe payment for subscriptions
This commit is contained in:
21
ui/static/checkout.js
Normal file
21
ui/static/checkout.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const stripe = Stripe("pk_test_51QikGlGk6yuk3uA8MT3uQrPMpUqJlKzkxfbrfrd34yXolWSbJYEFWm674s2aUydZyjjS0W2oByEJTV0LXMs1pWTk002ioHxQl6");
|
||||
|
||||
initialize();
|
||||
|
||||
// Create a Checkout Session
|
||||
async function initialize() {
|
||||
const fetchClientSecret = async () => {
|
||||
const response = await fetch("/create-checkout-session", {
|
||||
method: "POST",
|
||||
});
|
||||
const { clientSecret } = await response.json();
|
||||
return clientSecret;
|
||||
};
|
||||
|
||||
const checkout = await stripe.initEmbeddedCheckout({
|
||||
fetchClientSecret,
|
||||
});
|
||||
|
||||
// Mount Checkout
|
||||
checkout.mount('#checkout');
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Live Stream</title>
|
||||
{% block header_config %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block main_content %}
|
||||
|
||||
15
ui/templates/checkout.html
Normal file
15
ui/templates/checkout.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block header_config %}
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<script src="{{ url_for('static', filename='checkout.js') }}" defer></script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block main_content %}
|
||||
<!-- Display a payment form -->
|
||||
<div id="checkout">
|
||||
<!-- Checkout will insert the payment form here -->
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user