-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathserver.py
35 lines (30 loc) · 1.04 KB
/
server.py
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
#! /usr/bin/env python3.6
"""
Python 3.6 or newer required.
"""
import stripe
stripe.api_key = 'sk_test_sample_key'
from flask import Flask, jsonify
app = Flask(__name__, static_folder='public',
static_url_path='', template_folder='public')
@app.route('/account_session', methods=['POST'])
def create_account_session():
try:
account_session = stripe.AccountSession.create(
# We currently only support US custom accounts for onboarding
# https://stripe.com/docs/connect/supported-embedded-components#account-onboarding for more info
account="{{CONNECTED_ACCOUNT_ID}}",
components={
"account_onboarding": {
"enabled": True
},
},
)
return jsonify({
'client_secret': account_session.client_secret,
})
except Exception as e:
print('An error occurred when calling the Stripe API to create an account session: ', e)
return jsonify(error=str(e)), 500
if __name__ == '__main__':
app.run(port=4242)