113 lines
5.8 KiB
Python
Executable file
113 lines
5.8 KiB
Python
Executable file
import aiohttp
|
|
from aiohttp import ClientConnectorError, ClientResponseError
|
|
import asyncio
|
|
import json
|
|
import sys
|
|
|
|
async def send_data_to_flask(chosen_payment_method, chosen_location, chosen_service_as_string, chosen_email_operator, chosen_proxy_status, peer_to_peer_billing_id):
|
|
async with aiohttp.ClientSession() as session:
|
|
# filter out if no email:
|
|
if chosen_email_operator == "email disabled" or chosen_email_operator == "profile already has an email":
|
|
chosen_email_operator = "disabled"
|
|
# send to API regardless:
|
|
try:
|
|
async with session.post('https://onboard.simplifiedprivacy.net/api', json={
|
|
'peer_to_peer_billing_id': peer_to_peer_billing_id,
|
|
'chosen_payment_method': chosen_payment_method,
|
|
'chosen_service': chosen_service_as_string,
|
|
'chosen_email': chosen_email_operator,
|
|
'chosen_proxy_status': chosen_proxy_status,
|
|
'chosen_location': chosen_location
|
|
}) as response:
|
|
content_type = response.headers.get('Content-Type', '')
|
|
|
|
if 'application/json' in content_type:
|
|
return await response.json()
|
|
else:
|
|
# If content type is HTML, return the text content
|
|
html_content = await response.text()
|
|
return {"error": f"It returned this as HTML: {content_type}, Content: {html_content}"}
|
|
except ClientConnectorError as e:
|
|
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
|
return {"error": "Connection error: Unable to reach the server"}
|
|
except ClientResponseError as e:
|
|
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
|
return {"error": f"Bad response: {e.status} - {e.message}"}
|
|
|
|
async def dispute_send_data_to_flask(how_did_it_go, peer_to_peer_billing_id):
|
|
async with aiohttp.ClientSession() as session:
|
|
try:
|
|
async with session.post('https://onboard.simplifiedprivacy.net/dispute', json={
|
|
'peer_to_peer_billing_id': peer_to_peer_billing_id,
|
|
'dispute_status': f"{how_did_it_go}"
|
|
}) as response:
|
|
return await response.json() # Assuming the server returns JSON
|
|
|
|
except ClientConnectorError as e:
|
|
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
|
return {"error": "Connection error: Unable to reach the server"}
|
|
except ClientResponseError as e:
|
|
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
|
return {"error": f"Bad response: {e.status} - {e.message}"}
|
|
|
|
async def check_if_paid_by_sending_data_to_flask(peer_to_peer_billing_id):
|
|
async with aiohttp.ClientSession() as session:
|
|
try:
|
|
async with session.post('https://onboard.simplifiedprivacy.net/checkpaid', json={
|
|
'peer_to_peer_billing_id':peer_to_peer_billing_id
|
|
}) as response:
|
|
return await response.json() # Assuming the server returns JSON
|
|
|
|
except ClientConnectorError as e:
|
|
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
|
return {"error": "Connection error: Unable to reach the server"}
|
|
except ClientResponseError as e:
|
|
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
|
return {"error": f"Bad response: {e.status} - {e.message}"}
|
|
|
|
async def ready_for_code_by_sending_data_to_flask(peer_to_peer_billing_id):
|
|
async with aiohttp.ClientSession() as session:
|
|
try:
|
|
async with session.post('https://onboard.simplifiedprivacy.net/code', json={
|
|
'peer_to_peer_billing_id': peer_to_peer_billing_id
|
|
}) as response:
|
|
return await response.json() # Assuming the server returns JSON
|
|
|
|
except ClientConnectorError as e:
|
|
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
|
return {"error": "Connection error: Unable to reach the server"}
|
|
except ClientResponseError as e:
|
|
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
|
return {"error": f"Bad response: {e.status} - {e.message}"}
|
|
|
|
async def send_crypto_address_for_refund(peer_to_peer_billing_id, refund_crypto_address):
|
|
async with aiohttp.ClientSession() as session:
|
|
try:
|
|
async with session.post('https://onboard.simplifiedprivacy.net/refund_address', json={
|
|
'peer_to_peer_billing_id': peer_to_peer_billing_id,
|
|
'refund_crypto_address': refund_crypto_address
|
|
}) as response:
|
|
return await response.json() # Assuming the server returns JSON
|
|
|
|
except ClientConnectorError as e:
|
|
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
|
return {"error": "Connection error: Unable to reach the server"}
|
|
except ClientResponseError as e:
|
|
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
|
return {"error": f"Bad response: {e.status} - {e.message}"}
|
|
|
|
|
|
async def restore_an_already_finalized_number(peer_to_peer_billing_id, which_stage):
|
|
async with aiohttp.ClientSession() as session:
|
|
try:
|
|
async with session.post(f'https://onboard.simplifiedprivacy.net/{which_stage}', json={
|
|
'peer_to_peer_billing_id': peer_to_peer_billing_id
|
|
}) as response:
|
|
return await response.json() # Assuming the server returns JSON
|
|
|
|
except ClientConnectorError as e:
|
|
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
|
return {"error": "Connection error: Unable to reach the server"}
|
|
except ClientResponseError as e:
|
|
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
|
return {"error": f"Bad response: {e.status} - {e.message}"}
|