-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_order.py
More file actions
52 lines (46 loc) · 1.02 KB
/
create_order.py
File metadata and controls
52 lines (46 loc) · 1.02 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
49
50
51
52
import hashlib
import hmac
import json
import requests
import time
api_key = 'EEFA1913EA9D9351469B1E5D852A'
data = {
'shop_id': '1913EA9D9351469B1E5D852A',
'nonce': time.time_ns(),
"currency": "RUB",
"amount": 1200,
"order_id": "test order",
"payment_system": 5,
"fields": {
"email": "user@email.ru",
"phone": "79111231212"
},
"receipt": {
"items": [
{
"name": "test item 1",
"count": 1,
"price": 600
},
{
"name": "test item 2",
"count": 1,
"price": 600
}
]
}
}
body = json.dumps(data)
sign = hmac.new(api_key.encode(),
msg=body.encode(),
digestmod=hashlib.sha256).hexdigest()
url = "https://tegro.money/api/createOrder/"
headers = {
'Authorization': f'Bearer {sign}',
'Content-Type': 'application/json'
}
response = requests.post(
url=url,
data=body,
headers=headers,
)