-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirect_charge.py
54 lines (46 loc) · 1.32 KB
/
direct_charge.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import base64
import requests
url = "https://sandbox.paytrek.com/api/v2/direct_charge/"
payload = {
"amount": "12",
"order_id": 7,
"secure_option": False,
"pre_auth": False,
"number": "4508034508034509",
"expiration": "12/2020",
"cvc": "000",
"card_holder_name": "John Doe",
"billing_address": "Davutpasa",
"billing_city": "ISTANBUL",
"billing_country": "TR",
"billing_state": "IST",
"currency": "TRY",
"customer_email": "johndoe@sample.com",
"customer_first_name": "john",
"customer_ip_address": "78.167.133.200",
"customer_last_name": "doe",
"installment": 1,
"items": [
{
"unit_price": 205,
"quantity": 1,
"name": "Product Sample",
"photo": "https://blog.paytrek.com.tr/wp-content/uploads/2019/01/paytrek-new-logo.png"
}
],
"sale_data": {
"merchant_name": "Your Store"
},
"language_code": "tr"
}
# https://sandbox.paytrek.com/dashboard/account_info/
# Channel type must be API
api_key = ""
secret = ""
auth_token = base64.encodestring('%s:%s' % (api_key, secret)).replace('\n', '')
headers = {
'Content-Type': "application/json",
'Authorization': "Basic {}".format(auth_token),
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)