forked from ajvani/Acred
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (40 loc) · 1.07 KB
/
main.py
File metadata and controls
48 lines (40 loc) · 1.07 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
47
48
import pymongo
import stripe
import random
stripe.api_key = "<stripe_api_key>"
url = "<mongodb_url>"
client = pymongo.MongoClient(url);
db = client.pipedb
col = db.users
def add_user(user_id, fname, lname):
col.insert_one({
'uid': user_id,
'first_name': fname,
'last_name': lname,
'loan_limit': set_limit(),
'loan_taken': 0,
'money_in': 0,
'deadline': None,
'coin_amt': 0,
'public_info': {},
'payback_amt': 0,
'pipe_address': gen_address(),
'secret': gen_secret()
})
def set_limit():
return 240 + 10 * (random.randint(1,26))
def make_charge(user, amt):
stripe.Charge.create(
amount=amt,
currency="usd",
description="$" + str(amt) + " donation from " + user,
source="tok_visa",
idempotency_key='en4aQEL58owJ2Fkd'
)
give_coin(amt)
def get_balance():
return stripe.Balance.retrieve()
def take_loan(uid, loan_amt, deadline):
cur = col.find_one({'uid': uid})
loan_limit = cur['loan_limit']
add_user('shahv', 'Vineet', 'Shah')