Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,6 +41,7 @@ ENCRYPTED_CONNECT_SID = encrypt_value('s%3A7Bwbww_JK7pW55D-B57-3b7bi-FzrzEZ.ezXP
|
|
| 41 |
ENCRYPTED_API_URL = encrypt_value('https://astra-bank-moh1812.replit.app/api/transactions')
|
| 42 |
ENCRYPTED_REFERER = encrypt_value('https://astra-bank-moh1812.replit.app/')
|
| 43 |
ENCRYPTED_ETAG = encrypt_value('W/"6e3-L0zHI4rHMa4nHmyewyA/4y+lL6c"')
|
|
|
|
| 44 |
|
| 45 |
class PaymentLink(db.Model):
|
| 46 |
id = db.Column(db.String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
@@ -102,6 +103,90 @@ def check_for_payment(amount, existing_transaction_ids):
|
|
| 102 |
print(f"Error checking for payment: {e}")
|
| 103 |
return None
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
with app.app_context():
|
| 106 |
db.create_all()
|
| 107 |
|
|
@@ -205,6 +290,24 @@ def process_payment(payment_id):
|
|
| 205 |
payment_link.paid = True
|
| 206 |
db.session.commit()
|
| 207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
return jsonify({'success': True, 'message': 'Payment confirmed successfully'})
|
| 209 |
|
| 210 |
except Exception as e:
|
|
|
|
| 41 |
ENCRYPTED_API_URL = encrypt_value('https://astra-bank-moh1812.replit.app/api/transactions')
|
| 42 |
ENCRYPTED_REFERER = encrypt_value('https://astra-bank-moh1812.replit.app/')
|
| 43 |
ENCRYPTED_ETAG = encrypt_value('W/"6e3-L0zHI4rHMa4nHmyewyA/4y+lL6c"')
|
| 44 |
+
ENCRYPTED_BANK_BASE_URL = encrypt_value('https://astra-bank-moh1812.replit.app')
|
| 45 |
|
| 46 |
class PaymentLink(db.Model):
|
| 47 |
id = db.Column(db.String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
|
|
| 103 |
print(f"Error checking for payment: {e}")
|
| 104 |
return None
|
| 105 |
|
| 106 |
+
def get_user_uuid(email):
|
| 107 |
+
try:
|
| 108 |
+
base_url = decrypt_value(ENCRYPTED_BANK_BASE_URL)
|
| 109 |
+
connect_sid = decrypt_value(ENCRYPTED_CONNECT_SID)
|
| 110 |
+
referer = decrypt_value(ENCRYPTED_REFERER)
|
| 111 |
+
|
| 112 |
+
url = f"{base_url}/api/user"
|
| 113 |
+
params = {'email': email}
|
| 114 |
+
|
| 115 |
+
headers = {
|
| 116 |
+
'accept': '*/*',
|
| 117 |
+
'accept-language': 'en-US,en;q=0.9',
|
| 118 |
+
'cache-control': 'no-cache',
|
| 119 |
+
'priority': 'u=1, i',
|
| 120 |
+
'referer': referer,
|
| 121 |
+
'sec-ch-ua': '"Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"',
|
| 122 |
+
'sec-ch-ua-mobile': '?1',
|
| 123 |
+
'sec-ch-ua-platform': '"Android"',
|
| 124 |
+
'sec-fetch-dest': 'empty',
|
| 125 |
+
'sec-fetch-mode': 'cors',
|
| 126 |
+
'sec-fetch-site': 'same-origin',
|
| 127 |
+
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36'
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
cookies = {
|
| 131 |
+
'connect.sid': connect_sid
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
response = requests.get(url, params=params, headers=headers, cookies=cookies, timeout=10)
|
| 135 |
+
if response.status_code == 200:
|
| 136 |
+
return response.text.strip()
|
| 137 |
+
else:
|
| 138 |
+
print(f"Error getting user UUID: {response.status_code} - {response.text}")
|
| 139 |
+
return None
|
| 140 |
+
except Exception as e:
|
| 141 |
+
print(f"Error getting user UUID: {e}")
|
| 142 |
+
return None
|
| 143 |
+
|
| 144 |
+
def send_money(to_user_id, amount, description):
|
| 145 |
+
try:
|
| 146 |
+
base_url = decrypt_value(ENCRYPTED_BANK_BASE_URL)
|
| 147 |
+
connect_sid = decrypt_value(ENCRYPTED_CONNECT_SID)
|
| 148 |
+
referer = decrypt_value(ENCRYPTED_REFERER)
|
| 149 |
+
|
| 150 |
+
url = f"{base_url}/api/send-money"
|
| 151 |
+
|
| 152 |
+
headers = {
|
| 153 |
+
'accept': '*/*',
|
| 154 |
+
'accept-language': 'en-US,en;q=0.9',
|
| 155 |
+
'cache-control': 'no-cache',
|
| 156 |
+
'content-type': 'application/json',
|
| 157 |
+
'origin': base_url,
|
| 158 |
+
'pragma': 'no-cache',
|
| 159 |
+
'priority': 'u=1, i',
|
| 160 |
+
'referer': referer,
|
| 161 |
+
'sec-ch-ua': '"Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"',
|
| 162 |
+
'sec-ch-ua-mobile': '?1',
|
| 163 |
+
'sec-ch-ua-platform': '"Android"',
|
| 164 |
+
'sec-fetch-dest': 'empty',
|
| 165 |
+
'sec-fetch-mode': 'cors',
|
| 166 |
+
'sec-fetch-site': 'same-origin',
|
| 167 |
+
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36'
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
cookies = {
|
| 171 |
+
'connect.sid': connect_sid
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
data = {
|
| 175 |
+
'toUserId': to_user_id,
|
| 176 |
+
'amount': amount,
|
| 177 |
+
'description': description
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
response = requests.post(url, json=data, headers=headers, cookies=cookies, timeout=10)
|
| 181 |
+
if response.status_code == 200:
|
| 182 |
+
return True, response.json()
|
| 183 |
+
else:
|
| 184 |
+
print(f"Error sending money: {response.status_code} - {response.text}")
|
| 185 |
+
return False, response.text
|
| 186 |
+
except Exception as e:
|
| 187 |
+
print(f"Error sending money: {e}")
|
| 188 |
+
return False, str(e)
|
| 189 |
+
|
| 190 |
with app.app_context():
|
| 191 |
db.create_all()
|
| 192 |
|
|
|
|
| 290 |
payment_link.paid = True
|
| 291 |
db.session.commit()
|
| 292 |
|
| 293 |
+
if payment_link.recipient_email:
|
| 294 |
+
try:
|
| 295 |
+
user_uuid = get_user_uuid(payment_link.recipient_email)
|
| 296 |
+
if user_uuid:
|
| 297 |
+
success, result = send_money(
|
| 298 |
+
to_user_id=user_uuid,
|
| 299 |
+
amount=payment_link.amount,
|
| 300 |
+
description=payment_link.description
|
| 301 |
+
)
|
| 302 |
+
if success:
|
| 303 |
+
print(f"Successfully sent {payment_link.amount} Astras to {payment_link.recipient_email}")
|
| 304 |
+
else:
|
| 305 |
+
print(f"Failed to send money: {result}")
|
| 306 |
+
else:
|
| 307 |
+
print(f"Could not find user UUID for email: {payment_link.recipient_email}")
|
| 308 |
+
except Exception as e:
|
| 309 |
+
print(f"Error processing recipient payment: {e}")
|
| 310 |
+
|
| 311 |
return jsonify({'success': True, 'message': 'Payment confirmed successfully'})
|
| 312 |
|
| 313 |
except Exception as e:
|