Delete
This commit is contained in:
14
yoomoney_src/Dockerfile
Normal file
14
yoomoney_src/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM python:3.9-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
COPY main.py .
|
||||
COPY reg.py .
|
||||
COPY check_ip.py .
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "main:app"]
|
||||
7
yoomoney_src/check_ip.py
Normal file
7
yoomoney_src/check_ip.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import socket
|
||||
|
||||
def check_user_ip(external_ip) -> bool:
|
||||
local_ip = socket.gethostbyname(socket.gethostname())
|
||||
if local_ip != external_ip:
|
||||
return False
|
||||
return True
|
||||
62
yoomoney_src/main.py
Normal file
62
yoomoney_src/main.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import os
|
||||
|
||||
from flask import Flask, redirect, request, jsonify
|
||||
|
||||
from yoomoney import Quickpay
|
||||
from check_ip import check_user_ip
|
||||
from reg import paid
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
remote_docker_address = os.environ.get('REMOTE_ADDRESS', 'Empty')
|
||||
|
||||
@app.route('/pay', methods=['POST'])
|
||||
def process_data():
|
||||
#client_ip = request.remote_addr
|
||||
#print(client_ip)
|
||||
# if not check_user_ip(client_ip) and client_ip != "127.0.0.1" and client_ip != remote_docker_address:
|
||||
# return jsonify({"mes" : "Nice try"}), 403
|
||||
|
||||
data = request.get_json()
|
||||
print(data)
|
||||
if not data or 'sum' not in data or 'id' not in data:
|
||||
return jsonify({"error": "Invalid data: 'sum' and 'id' are required"}), 400
|
||||
|
||||
sum_value = data['sum']
|
||||
id_value = data['id']
|
||||
|
||||
quickpay = Quickpay(
|
||||
receiver="410012845407838", # change
|
||||
quickpay_form="shop",
|
||||
targets="Pay or get out",
|
||||
paymentType="SB",
|
||||
sum=sum_value,
|
||||
label=id_value
|
||||
)
|
||||
redirect_url = quickpay.redirected_url
|
||||
|
||||
response = {
|
||||
"message": "SUCCESS",
|
||||
"redir_url" : redirect_url
|
||||
}
|
||||
|
||||
return jsonify(response), 200
|
||||
|
||||
@app.route('/check_pay', methods=['GET', 'POST'])
|
||||
def check_pay():
|
||||
#client_ip = request.remote_addr
|
||||
# if not check_user_ip(client_ip) and client_ip != "127.0.0.1" and client_ip != remote_docker_address:
|
||||
# return jsonify({"mes" : "Nice try"}), 403
|
||||
|
||||
data = request.get_json()
|
||||
if not data or 'uuid' not in data:
|
||||
return jsonify({"mes": "Invalid data: 'id' is required"}), 400
|
||||
|
||||
id_value = data['uuid']
|
||||
resp = paid(id_value)
|
||||
if resp:
|
||||
return jsonify({"mes" : "OK"}), 200
|
||||
return jsonify({"mes" : "ERR"}), 400
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, host='0.0.0.0')
|
||||
30
yoomoney_src/reg.py
Normal file
30
yoomoney_src/reg.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from yoomoney import Client
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
token = "410012845407838.F390B1DD6C407313ADE9D05C31AA4BCA24A8FD68B050D1DDE209DD13B40964CC2A97970CE9C376B8D36375F0A6F57D33E8223616C05CFB56C5E52DDB1DE937D498650EFD8037C10BA131DE8F679EA9D1E63DE3A5A4F44E030951721267E3818B36E0B472B9400A4507EECD564FD55D4B427F37BDD33E7695D7F4E8F94C566D09"
|
||||
client = Client(token)
|
||||
|
||||
def paid(id_u: str):
|
||||
print(token)
|
||||
now_date = datetime.today() - timedelta(days=1)
|
||||
history = client.operation_history(from_date=now_date, records=100)
|
||||
|
||||
# print("List of operations:")
|
||||
# print("Next page starts with: ", history.next_record)
|
||||
|
||||
for operation in history.operations:
|
||||
if operation.label == id_u:
|
||||
return True
|
||||
# print()
|
||||
# print("Operation:",operation.operation_id)
|
||||
# print("\tStatus -->", operation.status)
|
||||
# print("\tDatetime -->", operation.datetime)
|
||||
# print("\tTitle -->", operation.title)
|
||||
# print("\tPattern id -->", operation.pattern_id)
|
||||
# print("\tDirection -->", operation.direction)
|
||||
# print("\tAmount -->", operation.amount)
|
||||
# print("\tLabel -->", operation.label)
|
||||
# print("\tType -->", operation.type)
|
||||
return False
|
||||
|
||||
#print(paid("Ilias"))
|
||||
4
yoomoney_src/requirements.txt
Normal file
4
yoomoney_src/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
Flask==3.1.0
|
||||
gunicorn==23.0.0
|
||||
requests==2.32.3
|
||||
YooMoney==0.1.2
|
||||
Reference in New Issue
Block a user