Add subcription feature 10
This commit is contained in:
@@ -10,6 +10,48 @@
|
||||
7. [Common Issues & Solutions](#common-issues--solutions)
|
||||
8. [Production Checklist](#production-checklist)
|
||||
|
||||
|
||||
Flow Without 3DS Required
|
||||
|
||||
Step 1: POST /start-registration
|
||||
├── Create Stripe Customer
|
||||
├── Create SetupIntent with confirm=True
|
||||
│ └── Stripe checks: "Does this card need 3DS?" → NO
|
||||
│ └── SetupIntent status = 'succeeded' immediately
|
||||
├── Store state: {customer_id, setup_intent_id, etc.}
|
||||
└── Return: {requires_action: false, setup_intent_id}
|
||||
|
||||
Step 2: Frontend sees requires_action=false
|
||||
└── Immediately calls /complete-registration (no 3DS popup)
|
||||
|
||||
Step 3: POST /complete-registration
|
||||
├── Verify SetupIntent status = 'succeeded' ✓ (already succeeded)
|
||||
├── Create Subscription with verified payment method
|
||||
├── Create User, Tenant, etc.
|
||||
└── Return: {user, tokens, subscription}
|
||||
Flow With 3DS Required
|
||||
|
||||
Step 1: POST /start-registration
|
||||
├── Create Stripe Customer
|
||||
├── Create SetupIntent with confirm=True
|
||||
│ └── Stripe checks: "Does this card need 3DS?" → YES
|
||||
│ └── SetupIntent status = 'requires_action'
|
||||
├── Store state: {customer_id, setup_intent_id, etc.}
|
||||
└── Return: {requires_action: true, client_secret}
|
||||
|
||||
Step 2: Frontend sees requires_action=true
|
||||
├── Shows 3DS popup: stripe.confirmCardSetup(client_secret)
|
||||
├── User completes 3DS verification
|
||||
└── Calls /complete-registration
|
||||
|
||||
Step 3: POST /complete-registration
|
||||
├── Verify SetupIntent status = 'succeeded' ✓ (after 3DS)
|
||||
├── Create Subscription with verified payment method
|
||||
├── Create User, Tenant, etc.
|
||||
└── Return: {user, tokens, subscription}
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -546,7 +546,16 @@ const NewProfileSettingsPage: React.FC = () => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
await updateProfileMutation.mutateAsync(profileData);
|
||||
// Map the form fields to the expected API format
|
||||
// The API expects 'full_name' instead of separate 'first_name' and 'last_name'
|
||||
const profileUpdateData = {
|
||||
full_name: `${profileData.first_name} ${profileData.last_name}`.trim(),
|
||||
phone: profileData.phone,
|
||||
language: profileData.language,
|
||||
timezone: profileData.timezone
|
||||
};
|
||||
|
||||
await updateProfileMutation.mutateAsync(profileUpdateData);
|
||||
|
||||
setIsEditing(false);
|
||||
showToast.success(t('profile.save_changes'));
|
||||
|
||||
@@ -173,7 +173,16 @@ const ProfilePage: React.FC = () => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
await updateProfileMutation.mutateAsync(profileData);
|
||||
// Map the form fields to the expected API format
|
||||
// The API expects 'full_name' instead of separate 'first_name' and 'last_name'
|
||||
const profileUpdateData = {
|
||||
full_name: `${profileData.first_name} ${profileData.last_name}`.trim(),
|
||||
phone: profileData.phone,
|
||||
language: profileData.language,
|
||||
timezone: profileData.timezone
|
||||
};
|
||||
|
||||
await updateProfileMutation.mutateAsync(profileUpdateData);
|
||||
|
||||
setIsEditing(false);
|
||||
showToast.success('Perfil actualizado correctamente');
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"tenant_id": "A0000000-0000-4000-a000-000000000001",
|
||||
"name": "Gerente Madrid - Salamanca",
|
||||
"email": "gerente.a0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "manager",
|
||||
"role": "admin",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 180d",
|
||||
"updated_at": "BASE_TS - 180d"
|
||||
@@ -15,7 +15,7 @@
|
||||
"tenant_id": "A0000000-0000-4000-a000-000000000001",
|
||||
"name": "Empleado Madrid - Salamanca",
|
||||
"email": "empleado.a0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "user",
|
||||
"role": "member",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 150d",
|
||||
"updated_at": "BASE_TS - 150d"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"tenant_id": "B0000000-0000-4000-a000-000000000001",
|
||||
"name": "Gerente Barcelona - Eixample",
|
||||
"email": "gerente.b0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "manager",
|
||||
"role": "admin",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 180d",
|
||||
"updated_at": "BASE_TS - 180d"
|
||||
@@ -15,7 +15,7 @@
|
||||
"tenant_id": "B0000000-0000-4000-a000-000000000001",
|
||||
"name": "Empleado Barcelona - Eixample",
|
||||
"email": "empleado.b0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "user",
|
||||
"role": "member",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 150d",
|
||||
"updated_at": "BASE_TS - 150d"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"tenant_id": "C0000000-0000-4000-a000-000000000001",
|
||||
"name": "Gerente Valencia - Ruzafa",
|
||||
"email": "gerente.c0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "manager",
|
||||
"role": "admin",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 180d",
|
||||
"updated_at": "BASE_TS - 180d"
|
||||
@@ -15,7 +15,7 @@
|
||||
"tenant_id": "C0000000-0000-4000-a000-000000000001",
|
||||
"name": "Empleado Valencia - Ruzafa",
|
||||
"email": "empleado.c0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "user",
|
||||
"role": "member",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 150d",
|
||||
"updated_at": "BASE_TS - 150d"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"tenant_id": "D0000000-0000-4000-a000-000000000001",
|
||||
"name": "Gerente Seville - Triana",
|
||||
"email": "gerente.d0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "manager",
|
||||
"role": "admin",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 180d",
|
||||
"updated_at": "BASE_TS - 180d"
|
||||
@@ -15,7 +15,7 @@
|
||||
"tenant_id": "D0000000-0000-4000-a000-000000000001",
|
||||
"name": "Empleado Seville - Triana",
|
||||
"email": "empleado.d0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "user",
|
||||
"role": "member",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 150d",
|
||||
"updated_at": "BASE_TS - 150d"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"tenant_id": "E0000000-0000-4000-a000-000000000001",
|
||||
"name": "Gerente Bilbao - Casco Viejo",
|
||||
"email": "gerente.e0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "manager",
|
||||
"role": "admin",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 180d",
|
||||
"updated_at": "BASE_TS - 180d"
|
||||
@@ -15,7 +15,7 @@
|
||||
"tenant_id": "E0000000-0000-4000-a000-000000000001",
|
||||
"name": "Empleado Bilbao - Casco Viejo",
|
||||
"email": "empleado.e0000000-0000-4000-a000-000000000001@panaderiaartesana.es",
|
||||
"role": "user",
|
||||
"role": "member",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 150d",
|
||||
"updated_at": "BASE_TS - 150d"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"tenant_id": "80000000-0000-4000-a000-000000000001",
|
||||
"name": "Produccion",
|
||||
"email": "produccion@panaderiaartesana.es",
|
||||
"role": "production_director",
|
||||
"role": "admin",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 300d",
|
||||
"updated_at": "BASE_TS - 300d"
|
||||
@@ -26,7 +26,7 @@
|
||||
"tenant_id": "80000000-0000-4000-a000-000000000001",
|
||||
"name": "Compras",
|
||||
"email": "compras@panaderiaartesana.es",
|
||||
"role": "procurement_manager",
|
||||
"role": "admin",
|
||||
"is_active": true,
|
||||
"created_at": "BASE_TS - 280d",
|
||||
"updated_at": "BASE_TS - 280d"
|
||||
@@ -37,7 +37,7 @@
|
||||
"email": "calidad@panaderiaartesana.es",
|
||||
"first_name": "Jos\u00e9",
|
||||
"last_name": "Mart\u00ednez",
|
||||
"role": "quality_control",
|
||||
"role": "admin",
|
||||
"department": "quality",
|
||||
"position": "Responsable de Calidad",
|
||||
"phone": "+34 916 123 459",
|
||||
@@ -57,7 +57,7 @@
|
||||
"email": "logistica@panaderiaartesana.es",
|
||||
"first_name": "Laura",
|
||||
"last_name": "L\u00f3pez",
|
||||
"role": "logistics_coord",
|
||||
"role": "admin",
|
||||
"department": "logistics",
|
||||
"position": "Coordinadora de Log\u00edstica",
|
||||
"phone": "+34 916 123 460",
|
||||
@@ -77,7 +77,7 @@
|
||||
"email": "maestro1@panaderiaartesana.es",
|
||||
"first_name": "Antonio",
|
||||
"last_name": "S\u00e1nchez",
|
||||
"role": "master_baker",
|
||||
"role": "admin",
|
||||
"department": "production",
|
||||
"position": "Maestro Panadero Principal",
|
||||
"phone": "+34 916 123 461",
|
||||
@@ -97,7 +97,7 @@
|
||||
"email": "maestro2@panaderiaartesana.es",
|
||||
"first_name": "Isabel",
|
||||
"last_name": "Ruiz",
|
||||
"role": "master_baker",
|
||||
"role": "admin",
|
||||
"department": "production",
|
||||
"position": "Maestra Panadera Senior",
|
||||
"phone": "+34 916 123 462",
|
||||
@@ -117,7 +117,7 @@
|
||||
"email": "almacen1@panaderiaartesana.es",
|
||||
"first_name": "Francisco",
|
||||
"last_name": "Moreno",
|
||||
"role": "warehouse_supervisor",
|
||||
"role": "admin",
|
||||
"department": "warehouse",
|
||||
"position": "Supervisor de Almac\u00e9n",
|
||||
"phone": "+34 916 123 463",
|
||||
@@ -137,7 +137,7 @@
|
||||
"email": "almacen2@panaderiaartesana.es",
|
||||
"first_name": "Carmen",
|
||||
"last_name": "Jim\u00e9nez",
|
||||
"role": "warehouse_supervisor",
|
||||
"role": "admin",
|
||||
"department": "warehouse",
|
||||
"position": "Supervisora de Almac\u00e9n Turno Noche",
|
||||
"phone": "+34 916 123 464",
|
||||
@@ -157,7 +157,7 @@
|
||||
"email": "analisis@panaderiaartesana.es",
|
||||
"first_name": "David",
|
||||
"last_name": "Gonz\u00e1lez",
|
||||
"role": "operations_analyst",
|
||||
"role": "admin",
|
||||
"department": "operations",
|
||||
"position": "Analista de Operaciones",
|
||||
"phone": "+34 916 123 465",
|
||||
@@ -177,7 +177,7 @@
|
||||
"email": "mantenimiento@panaderiaartesana.es",
|
||||
"first_name": "Pedro",
|
||||
"last_name": "D\u00edaz",
|
||||
"role": "maintenance_tech",
|
||||
"role": "admin",
|
||||
"department": "maintenance",
|
||||
"position": "T\u00e9cnico de Mantenimiento",
|
||||
"phone": "+34 916 123 466",
|
||||
@@ -196,7 +196,7 @@
|
||||
"email": "turno.dia@panaderiaartesana.es",
|
||||
"first_name": "Rosa",
|
||||
"last_name": "Navarro",
|
||||
"role": "shift_supervisor",
|
||||
"role": "admin",
|
||||
"department": "production",
|
||||
"position": "Supervisora Turno D\u00eda",
|
||||
"phone": "+34 916 123 467",
|
||||
@@ -216,7 +216,7 @@
|
||||
"email": "turno.tarde@panaderiaartesana.es",
|
||||
"first_name": "Manuel",
|
||||
"last_name": "Torres",
|
||||
"role": "shift_supervisor",
|
||||
"role": "admin",
|
||||
"department": "production",
|
||||
"position": "Supervisor Turno Tarde",
|
||||
"phone": "+34 916 123 468",
|
||||
@@ -236,7 +236,7 @@
|
||||
"email": "turno.noche@panaderiaartesana.es",
|
||||
"first_name": "Luc\u00eda",
|
||||
"last_name": "Romero",
|
||||
"role": "shift_supervisor",
|
||||
"role": "admin",
|
||||
"department": "production",
|
||||
"position": "Supervisora Turno Noche",
|
||||
"phone": "+34 916 123 469",
|
||||
@@ -256,7 +256,7 @@
|
||||
"email": "it@panaderiaartesana.es",
|
||||
"first_name": "Javier",
|
||||
"last_name": "Vargas",
|
||||
"role": "it_admin",
|
||||
"role": "admin",
|
||||
"department": "it",
|
||||
"position": "Administrador de Sistemas",
|
||||
"phone": "+34 916 123 470",
|
||||
|
||||
Reference in New Issue
Block a user