Skip to content

Commit 6643a73

Browse files
authored
Add files via upload
1 parent c7740df commit 6643a73

File tree

6 files changed

+178
-0
lines changed

6 files changed

+178
-0
lines changed

day96/public/cancel.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Checkout canceled</title>
5+
<link rel="stylesheet" href="style.css">
6+
</head>
7+
<body>
8+
<section>
9+
<p>Forgot to add something to your cart? Shop around then come back to pay!</p>
10+
<p><a href="http://localhost:4242/checkout.html">Return to checkout</a></p>
11+
</section>
12+
</body>
13+
</html>

day96/public/checkout.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Phillip's Product Page</title>
5+
<link rel="stylesheet" href="style.css">
6+
<script src="https://polyfill.io/v3/polyfill.min.js?version=3.52.1&features=fetch"></script>
7+
<script src="https://js.stripe.com/v3/"></script>
8+
</head>
9+
<body>
10+
<section>
11+
<div class="product">
12+
<img src="https://images.pexels.com/photos/2150/sky-space-dark-galaxy.jpg" alt="Phillip's Basic Product Page" />
13+
<div class="description">
14+
<h3>Phillip's Basic Product Page</h3>
15+
<h5>$777.77</h5>
16+
</div>
17+
</div>
18+
<form action="/create-checkout-session" method="POST">
19+
<button type="submit" id="checkout-button">Checkout</button>
20+
</form>
21+
</section>
22+
</body>
23+
</html>

day96/public/style.css

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
body {
2+
display: flex;
3+
justify-content: center;
4+
align-items: center;
5+
background: #242d60;
6+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
7+
'Helvetica Neue', 'Ubuntu', sans-serif;
8+
height: 100vh;
9+
margin: 0;
10+
-webkit-font-smoothing: antialiased;
11+
-moz-osx-font-smoothing: grayscale;
12+
}
13+
section {
14+
background: #ffffff;
15+
display: flex;
16+
flex-direction: column;
17+
width: 400px;
18+
height: 112px;
19+
border-radius: 6px;
20+
justify-content: space-between;
21+
}
22+
.product {
23+
display: flex;
24+
}
25+
.description {
26+
display: flex;
27+
flex-direction: column;
28+
justify-content: center;
29+
}
30+
p {
31+
font-style: normal;
32+
font-weight: 500;
33+
font-size: 14px;
34+
line-height: 20px;
35+
letter-spacing: -0.154px;
36+
color: #242d60;
37+
height: 100%;
38+
width: 100%;
39+
padding: 0 20px;
40+
display: flex;
41+
align-items: center;
42+
justify-content: center;
43+
box-sizing: border-box;
44+
}
45+
img {
46+
border-radius: 6px;
47+
margin: 10px;
48+
width: 54px;
49+
height: 57px;
50+
}
51+
h3,
52+
h5 {
53+
font-style: normal;
54+
font-weight: 500;
55+
font-size: 14px;
56+
line-height: 20px;
57+
letter-spacing: -0.154px;
58+
color: #242d60;
59+
margin: 0;
60+
}
61+
h5 {
62+
opacity: 0.5;
63+
}
64+
button {
65+
height: 36px;
66+
background: #556cd6;
67+
color: white;
68+
width: 100%;
69+
font-size: 14px;
70+
border: 0;
71+
font-weight: 500;
72+
cursor: pointer;
73+
letter-spacing: 0.6;
74+
border-radius: 0 0 6px 6px;
75+
transition: all 0.2s ease;
76+
box-shadow: 0px 4px 5.5px 0px rgba(0, 0, 0, 0.07);
77+
}
78+
button:hover {
79+
opacity: 0.8;
80+
}

day96/public/success.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Thanks for your order!</title>
5+
<link rel="stylesheet" href="style.css">
6+
</head>
7+
<body>
8+
<section>
9+
<p>
10+
We appreciate your business! Your payment has gone through successfully!
11+
</p>
12+
</section>
13+
</body>
14+
</html>

day96/requirements.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
certifi==2021.5.30
2+
chardet==4.0.0
3+
Click==8.0.1
4+
Flask==2.0.1
5+
idna==3.2
6+
itsdangerous==2.0.1
7+
Jinja2==3.0.1
8+
MarkupSafe==2.0.1
9+
requests==2.26.0
10+
stripe==3.0.0
11+
toml==0.10.2
12+
Werkzeug==2.0.1
13+
Werkzeug==2.0.1

day96/server.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from flask import Flask, redirect
2+
import stripe
3+
4+
5+
stripe.api_key = '************************************************************'
6+
7+
app = Flask(__name__,
8+
static_url_path='',
9+
static_folder='public')
10+
11+
YOUR_DOMAIN = 'http://localhost:4242'
12+
13+
14+
@app.route('/create-checkout-session', methods=['POST'])
15+
def create_checkout_session():
16+
try:
17+
checkout_session = stripe.checkout.Session.create(
18+
line_items=[
19+
{
20+
'price': '*****************************',
21+
'quantity': 1,
22+
},
23+
],
24+
mode='payment',
25+
success_url=YOUR_DOMAIN + '/success.html',
26+
cancel_url=YOUR_DOMAIN + '/cancel.html',
27+
)
28+
except Exception as e:
29+
return str(e)
30+
31+
return redirect(checkout_session.url, code=303)
32+
33+
34+
if __name__ == '__main__':
35+
app.run(port=4242)

0 commit comments

Comments
 (0)