habulaj commited on
Commit
f70e965
·
verified ·
1 Parent(s): ed0d9dd

Update routes/subscription.py

Browse files
Files changed (1) hide show
  1. routes/subscription.py +12 -3
routes/subscription.py CHANGED
@@ -15,9 +15,11 @@ stripe.api_version = "2023-10-16"
15
  ### **DATA MODELS** ###
16
  class SubscriptionRequest(BaseModel):
17
  user_id: str
18
- stylist_id: str # This must be the Stripe connected account ID (acct_xxxxx)
19
  amount: int # Value in cents (e.g., R$25.00 -> 2500)
20
  stylist_name: str # Name of the stylist
 
 
21
 
22
  class CancelSubscriptionRequest(BaseModel):
23
  subscription_id: str
@@ -27,7 +29,12 @@ class CancelSubscriptionRequest(BaseModel):
27
  def create_checkout_session(data: SubscriptionRequest):
28
  try:
29
  product_name = f"{data.stylist_name}'s Subscription"
30
- product_description = f"Monthly plan to access exclusive services from {data.stylist_name}."
 
 
 
 
 
31
 
32
  session = stripe.checkout.Session.create(
33
  success_url="https://yourdomain.com/success",
@@ -40,7 +47,8 @@ def create_checkout_session(data: SubscriptionRequest):
40
  "currency": "brl",
41
  "product_data": {
42
  "name": product_name,
43
- "description": product_description
 
44
  },
45
  "unit_amount": data.amount,
46
  "recurring": {"interval": "month"}
@@ -52,6 +60,7 @@ def create_checkout_session(data: SubscriptionRequest):
52
  "metadata": {
53
  "user_id": data.user_id,
54
  "stylist_id": data.stylist_id,
 
55
  }
56
  }
57
  )
 
15
  ### **DATA MODELS** ###
16
  class SubscriptionRequest(BaseModel):
17
  user_id: str
18
+ stylist_id: str # Stripe Connected Account ID (acct_xxxxx)
19
  amount: int # Value in cents (e.g., R$25.00 -> 2500)
20
  stylist_name: str # Name of the stylist
21
+ stylist_avatar: str # URL da foto do estilista
22
+ consultations_per_month: int # Número de consultas inclusas no plano
23
 
24
  class CancelSubscriptionRequest(BaseModel):
25
  subscription_id: str
 
29
  def create_checkout_session(data: SubscriptionRequest):
30
  try:
31
  product_name = f"{data.stylist_name}'s Subscription"
32
+ product_description = (
33
+ f"💼 Exclusive styling plan by {data.stylist_name}.\n\n"
34
+ f"👕 {data.consultations_per_month} styling consultations per month.\n"
35
+ f"📞 Personalized fashion advice and outfit recommendations.\n"
36
+ f"💳 Secure payments powered by Stripe."
37
+ )
38
 
39
  session = stripe.checkout.Session.create(
40
  success_url="https://yourdomain.com/success",
 
47
  "currency": "brl",
48
  "product_data": {
49
  "name": product_name,
50
+ "description": product_description,
51
+ "images": [data.stylist_avatar], # Adiciona a foto do estilista
52
  },
53
  "unit_amount": data.amount,
54
  "recurring": {"interval": "month"}
 
60
  "metadata": {
61
  "user_id": data.user_id,
62
  "stylist_id": data.stylist_id,
63
+ "consultations_per_month": data.consultations_per_month
64
  }
65
  }
66
  )