-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathidpay.py
More file actions
62 lines (54 loc) · 1.6 KB
/
Copy pathidpay.py
File metadata and controls
62 lines (54 loc) · 1.6 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
53
54
55
56
57
58
59
60
61
62
import requests
import json
API_URL = "https://api.idpay.ir/v1.1/"
# You can get your Token from this url => https://idpay.ir/dashboard/web-services
TOKEN = "Your Token Here"
SANDBOX = str(1) # 1 or 0
header = {
"Content-Type": "application/json",
"X-SANDBOX": SANDBOX,
"X-API-KEY": TOKEN
}
def payment(order_id, amount, callback, name="", mail="", phone="", description=""):
posts = {
"order_id": str(order_id),
"amount": int(amount),
"callback": callback,
"name": name,
"mail": mail,
"phone": phone,
"desc": description
}
posts = json.dumps(posts)
try:
response = requests.post(f"{API_URL}payment", data=posts, headers=header).text
response = json.loads(response)
except Exception as e:
return False
return response
def verify(id, order_id):
order_id = str(order_id)
id = str(id)
posts = {
"id": id,
"order_id": order_id
}
posts = json.dumps(posts)
try:
response = requests.post(f"{API_URL}payment/verify", data=posts, headers=header).text
response = json.loads(response)
except Exception as e:
return False
return response
def inquiry(id, order_id):
posts = {
"id": str(id),
"order_id": str(order_id)
}
posts_json = json.dumps(posts)
try:
response = requests.post(f"{API_URL}payment/inquiry", data=posts_json, headers=header).text
response = json.loads(response)
except Exception as e:
return False
return response