habulaj commited on
Commit
5e5ee01
·
verified ·
1 Parent(s): d4d3d48

Update routes/subscription.py

Browse files
Files changed (1) hide show
  1. routes/subscription.py +11 -1
routes/subscription.py CHANGED
@@ -584,6 +584,15 @@ async def stripe_webhook(request: Request):
584
 
585
  elif event_type == "payment_intent.succeeded":
586
  payment_intent = payload.get("data", {}).get("object", {})
 
 
 
 
 
 
 
 
 
587
 
588
  # 🔹 Pegando os valores do metadado
589
  stylist_id = payment_intent.get("metadata", {}).get("stylist_id")
@@ -830,7 +839,8 @@ def emergency_checkout_session(
830
  customer=user_stripe_id,
831
  application_fee_amount=int(emergency_price * 0.20), # 20% para a plataforma
832
  transfer_data={
833
- "destination": stylist_stripe_id, # 80% para o estilista
 
834
  },
835
  metadata={
836
  "stylist_id": stylist_id, # Id do estilista
 
584
 
585
  elif event_type == "payment_intent.succeeded":
586
  payment_intent = payload.get("data", {}).get("object", {})
587
+
588
+ # Pegando o Stylist Stripe Account ID
589
+ stylist_stripe_id = payment_intent.get("metadata", {}).get("stylist_stripe_id")
590
+
591
+ if not stylist_stripe_id:
592
+ logger.error("❌ Stylist Stripe ID não encontrado nos metadados do Payment Intent.")
593
+ return {"status": "error", "message": "Stylist Stripe ID missing."}
594
+
595
+ logger.info(f"🔹 Pagamento recebido. Preparando para transferir fundos para {stylist_stripe_id}.")
596
 
597
  # 🔹 Pegando os valores do metadado
598
  stylist_id = payment_intent.get("metadata", {}).get("stylist_id")
 
839
  customer=user_stripe_id,
840
  application_fee_amount=int(emergency_price * 0.20), # 20% para a plataforma
841
  transfer_data={
842
+ "destination": stylist_stripe_id,
843
+ "amount": int(price_amount * 0.8 * 100)
844
  },
845
  metadata={
846
  "stylist_id": stylist_id, # Id do estilista