Update routes/subscription.py
Browse files- routes/subscription.py +12 -0
routes/subscription.py
CHANGED
@@ -615,6 +615,18 @@ async def check_subscription(
|
|
615 |
raise HTTPException(status_code=500, detail="Error checking subscription.")
|
616 |
|
617 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
618 |
# Função assíncrona para atualizar o status de uma assinatura
|
619 |
async def update_subscription_status(subscription_id, status):
|
620 |
update_data = {
|
|
|
615 |
raise HTTPException(status_code=500, detail="Error checking subscription.")
|
616 |
|
617 |
|
618 |
+
# Função assíncrona para fazer requisições de rede
|
619 |
+
async def async_request(url, headers, json=None, method='GET'):
|
620 |
+
method_func = requests.post if method == 'POST' else requests.get
|
621 |
+
response = method_func(url, headers=headers, json=json)
|
622 |
+
return response
|
623 |
+
|
624 |
+
# Função assíncrona para chamar a Stripe API
|
625 |
+
async def async_stripe_request(func, **kwargs):
|
626 |
+
loop = asyncio.get_event_loop()
|
627 |
+
response = await loop.run_in_executor(None, lambda: func(**kwargs))
|
628 |
+
return response
|
629 |
+
|
630 |
# Função assíncrona para atualizar o status de uma assinatura
|
631 |
async def update_subscription_status(subscription_id, status):
|
632 |
update_data = {
|