Update routes/subscription.py
Browse files- routes/subscription.py +7 -7
routes/subscription.py
CHANGED
@@ -14,7 +14,7 @@ stripe.api_version = "2023-10-16"
|
|
14 |
|
15 |
### **DATA MODELS** ###
|
16 |
class PriceRequest(BaseModel):
|
17 |
-
amount: int # Value in cents (e.g., $25.00 -> 2500)
|
18 |
stylist_name: str # Name of the stylist
|
19 |
|
20 |
class SubscriptionRequest(BaseModel):
|
@@ -39,7 +39,7 @@ def create_price(data: PriceRequest):
|
|
39 |
|
40 |
price = stripe.Price.create(
|
41 |
unit_amount=data.amount,
|
42 |
-
currency="
|
43 |
recurring={"interval": "month"},
|
44 |
product=product.id,
|
45 |
)
|
@@ -50,8 +50,8 @@ def create_price(data: PriceRequest):
|
|
50 |
"product_id": product.id,
|
51 |
"product_name": product_name,
|
52 |
"product_description": product_description,
|
53 |
-
"amount": data.amount / 100, # Converting cents to
|
54 |
-
"currency": "
|
55 |
}
|
56 |
except Exception as e:
|
57 |
logger.error(f"Error creating price: {e}")
|
@@ -120,11 +120,11 @@ async def stripe_webhook(request: Request):
|
|
120 |
try:
|
121 |
transfer = stripe.Transfer.create(
|
122 |
amount=stylist_share, # Value in CENTS
|
123 |
-
currency="
|
124 |
destination=stylist_id, # The Stripe Connected Account ID (acct_xxxx)
|
125 |
description=f"Payment for stylist {stylist_id} - Subscription",
|
126 |
)
|
127 |
-
logger.info(f"💸 Transfer successful: ${stylist_share / 100:.2f}
|
128 |
transfer_status = "Completed"
|
129 |
except Exception as e:
|
130 |
logger.error(f"🚨 Transfer error for stylist {stylist_id}: {e}")
|
@@ -134,7 +134,7 @@ async def stripe_webhook(request: Request):
|
|
134 |
"status": "Payment processed successfully!",
|
135 |
"user_id": user_id,
|
136 |
"stylist_id": stylist_id,
|
137 |
-
"total_paid": amount / 100, # Convert cents to
|
138 |
"stylist_share": stylist_share / 100,
|
139 |
"platform_share": platform_share / 100,
|
140 |
"transfer_status": transfer_status
|
|
|
14 |
|
15 |
### **DATA MODELS** ###
|
16 |
class PriceRequest(BaseModel):
|
17 |
+
amount: int # Value in cents (e.g., R$25.00 -> 2500)
|
18 |
stylist_name: str # Name of the stylist
|
19 |
|
20 |
class SubscriptionRequest(BaseModel):
|
|
|
39 |
|
40 |
price = stripe.Price.create(
|
41 |
unit_amount=data.amount,
|
42 |
+
currency="brl", # Changed to BRL
|
43 |
recurring={"interval": "month"},
|
44 |
product=product.id,
|
45 |
)
|
|
|
50 |
"product_id": product.id,
|
51 |
"product_name": product_name,
|
52 |
"product_description": product_description,
|
53 |
+
"amount": data.amount / 100, # Converting cents to BRL
|
54 |
+
"currency": "BRL",
|
55 |
}
|
56 |
except Exception as e:
|
57 |
logger.error(f"Error creating price: {e}")
|
|
|
120 |
try:
|
121 |
transfer = stripe.Transfer.create(
|
122 |
amount=stylist_share, # Value in CENTS
|
123 |
+
currency="brl", # Changed to BRL
|
124 |
destination=stylist_id, # The Stripe Connected Account ID (acct_xxxx)
|
125 |
description=f"Payment for stylist {stylist_id} - Subscription",
|
126 |
)
|
127 |
+
logger.info(f"💸 Transfer successful: R${stylist_share / 100:.2f} BRL to {stylist_id}")
|
128 |
transfer_status = "Completed"
|
129 |
except Exception as e:
|
130 |
logger.error(f"🚨 Transfer error for stylist {stylist_id}: {e}")
|
|
|
134 |
"status": "Payment processed successfully!",
|
135 |
"user_id": user_id,
|
136 |
"stylist_id": stylist_id,
|
137 |
+
"total_paid": amount / 100, # Convert cents to BRL
|
138 |
"stylist_share": stylist_share / 100,
|
139 |
"platform_share": platform_share / 100,
|
140 |
"transfer_status": transfer_status
|