-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
46 lines (28 loc) · 1.03 KB
/
server.py
File metadata and controls
46 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
from flask import Flask, request, jsonify, send_from_directory, redirect
from flask_cors import CORS
from smartpay import Smartpay
# Replace the keys with yours
SECRET_KEY = os.environ.get('SECRET_KEY', '<YOUR_SECRET_KEY>')
PUBLIC_KEY = os.environ.get('PUBLIC_KEY', '<YOUR_PUBLIC_KEY>')
smartpay = Smartpay(SECRET_KEY, public_key=PUBLIC_KEY)
app = Flask(__name__, static_url_path='')
CORS(app)
root = '../client/build'
@app.route("/", methods=['GET'])
def index():
return redirect('http://localhost:3080')
@app.route("/create-smartpay-checkout", methods=['POST'])
def create_smartpay_checkout():
payload = request.json
session = smartpay.create_checkout_session(payload)
return jsonify(session)
@app.route("/payment-success")
def payment_success():
return send_from_directory(root, 'payment-success.html')
@app.route("/payment-canceled")
def payment_cancel():
return send_from_directory(root, 'payment-canceled.html')
@app.route("/<path>")
def files(path):
return send_from_directory(root, path)