-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper_functions.py
40 lines (32 loc) · 916 Bytes
/
helper_functions.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
36
37
38
39
40
from importlib.metadata import metadata
from locale import currency
import stripe
import os
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
API_KEY=os.getenv('API_KEY')
stripe.api_key=API_KEY
def dict_to_list(dict):
array=dict.items()
result=[]
for element in array:
result.append(element)
return result
def invoice_price(form):
""" returns invoice price in cents"""
hourly_rate=form.hourly_rate.data * 100
hours=form.sessions.data
return hourly_rate*hours
def create_product_stripe(teacher_accountid,form):
price=stripe.Price.create(
unit_amount=invoice_price(form),
currency="usd",
product_data={
"name":form.service_field.data,
},
recurring={"interval":form.cadence.data},
stripe_account=teacher_accountid
)
return price
def convert_quote():
return