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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
{
"cells": [
{
"metadata": {},
"cell_type": "code",
"source": [
"import uuid\n",
"\n",
"import requests\n",
"from collections import Counter\n",
"\n",
"FSB_BASE_URL = \"https://fsb.generalresearch.com/\"\n",
"JB_BASE_URL = \"https://jamesbillings67.com/\"\n",
"product_id = \"888dbc589987425fa846d6e2a8daed04\"\n",
"bpuid = uuid.uuid4().hex"
],
"id": "initial_id",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# Check their balance\n",
"url = FSB_BASE_URL + f\"{product_id}/wallets/?bpuid={bpuid}\"\n",
"print(f\"{url=}\")\n",
"res = requests.get(url).json()\n",
"print(res['displayed_balances'][0])"
],
"id": "74a8d7f3452c2372",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# Get user cashout methods\n",
"url = FSB_BASE_URL + f\"{product_id}/cashout_methods/?bpuid={bpuid}\"\n",
"print(f\"{url=}\")\n",
"res = requests.get(url).json()\n",
"cms = res['cashout_methods']\n",
"print(dict(Counter(x['type'] for x in cms)))\n",
"\n",
"# Get the paypal method\n",
"paypal_cm = next(filter(lambda x: x['type'] == 'PAYPAL', cms))\n",
"print(paypal_cm['id'])"
],
"id": "e5c4e61b4727912d",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# Log in and retain the jb_session cookie for later requests\n",
"from urllib.parse import parse_qs, urlparse\n",
"\n",
"session = requests.Session()\n",
"email = 'your-email@gmail.com'\n",
"\n",
"res = session.post(\n",
" JB_BASE_URL + 'auth/magic-link/request/',\n",
" json={'email': email},\n",
")\n",
"res.raise_for_status()\n",
"print(res.json())"
],
"id": "38c7d77b3abf9948",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# Paste the link from the login email. Exchanging it sets jb_session on `session`.\n",
"magic_link = \"https://jamesbillings67.com/auth/magic-link/?token=XXXX\"\n",
"token = parse_qs(urlparse(magic_link).query)['token'][0]\n",
"res = session.post(\n",
" JB_BASE_URL + 'auth/magic-link/exchange/',\n",
" json={'token': token},\n",
")\n",
"res.raise_for_status()\n",
"\n",
"session_token = session.cookies['jb_session']\n",
"print(f'Logged in; captured jb_session ({len(session_token)} characters)')"
],
"id": "db3caa6e440619fe",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# Request a PayPal cashout using the authenticated session.\n",
"# The response confirms that the cashout confirmation email was sent;\n",
"# the payout event is created only after that email link is confirmed.\n",
"res = session.post(JB_BASE_URL + 'wallet/cashout/request/', json={\n",
" 'amount': 10_00,\n",
" 'cashout_method_id': paypal_cm['id'],\n",
"})\n",
"res.raise_for_status()\n",
"print(res.json())"
],
"id": "774a00c08ab54d4f",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# Paste link from email\n",
"magic_link = \"https://jamesbillings67.com/wallet/cashout/confirm/?token=XXXX\"\n",
"token = parse_qs(urlparse(magic_link).query)['token'][0]\n",
"res = session.post(\n",
" JB_BASE_URL + 'wallet/cashout/confirm/',\n",
" json={'token': token},\n",
")\n",
"print(res.json())\n",
"res.raise_for_status()"
],
"id": "894887ddc479eb1a",
"outputs": [],
"execution_count": null
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|