40 lines
973 B
Python
40 lines
973 B
Python
import uuid
|
|
import requests
|
|
import base64
|
|
|
|
shop_id = '1017909'
|
|
api_key = 'test_udCBy7nXqGavVoj3RrzIRXN9UL02_UnF0FBBykxWH60'
|
|
|
|
auth_token = base64.b64encode(f'{shop_id}:{api_key}'.encode()).decode()
|
|
|
|
idempotence_key = str(uuid.uuid4())
|
|
|
|
headers = {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': f'Basic {auth_token}',
|
|
'Idempotence-Key': idempotence_key
|
|
}
|
|
|
|
data = {
|
|
"amount": {
|
|
"value": "1500.00",
|
|
"currency": "RUB"
|
|
},
|
|
"confirmation": {
|
|
"type": "redirect",
|
|
"return_url": "https://example.com/return"
|
|
},
|
|
"capture": True,
|
|
"description": "Зеленый слоник 2",
|
|
"metadata": {
|
|
"order_id": str(uuid.uuid4())
|
|
}
|
|
}
|
|
|
|
response = requests.post("https://api.yookassa.ru/v3/payments", json=data, headers=headers)
|
|
|
|
if response.status_code in [200, 201]:
|
|
print(response.json()["confirmation"]["confirmation_url"])
|
|
else:
|
|
print(f"Ошибка {response.status_code}: {response.text}")
|