All checks were successful
BCards Deployment Pipeline / Run Tests (push) Successful in 2s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Successful in 16m1s
BCards Deployment Pipeline / Deploy to Staging (x86 - Local) (push) Has been skipped
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Successful in 1m21s
BCards Deployment Pipeline / Cleanup Old Resources (push) Has been skipped
BCards Deployment Pipeline / Deployment Summary (push) Successful in 0s
219 lines
6.0 KiB
Markdown
219 lines
6.0 KiB
Markdown
# 🎯 **GUIA COMPLETO: STRIPE TESTE → PRODUÇÃO**
|
|
|
|
## 📋 **DIFERENÇAS IMPORTANTES**
|
|
|
|
### **MODO DE TESTE vs MODO RESTRITO**
|
|
|
|
| Aspecto | **Modo de Teste** | **Modo Restrito** |
|
|
|---------|-------------------|-------------------|
|
|
| 🎯 **Propósito** | Simular pagamentos | Limitar acesso público |
|
|
| 💳 **Cartões** | Apenas cartões de teste (`4242...`) | Cartões reais OU teste |
|
|
| 💰 **Dinheiro** | Não cobra dinheiro real | Pode cobrar (se live mode) |
|
|
| 🌐 **Acesso Online** | ✅ Funciona perfeitamente | ❌ Bloqueia usuários não autorizados |
|
|
| 🧪 **Para Testes** | ✅ **IDEAL** | ❌ Impede testes públicos |
|
|
|
|
### **🚨 PROBLEMA ATUAL**
|
|
Seu site provavelmente está em **Modo Restrito**, impedindo pagamentos online mesmo com cartões de teste.
|
|
|
|
---
|
|
|
|
## 🛠️ **PASSO-A-PASSO COMPLETO**
|
|
|
|
### **📝 FASE 1: PREPARAÇÃO LOCAL**
|
|
|
|
#### **1.1 Criar appsettings.Production.json**
|
|
```bash
|
|
# No seu ambiente local, crie:
|
|
cp appsettings.Production.example.json src/BCards.Web/appsettings.Production.json
|
|
```
|
|
|
|
#### **1.2 Para TESTE ONLINE (Recomendado primeiro)**
|
|
Edite `appsettings.Production.json`:
|
|
```json
|
|
{
|
|
"Stripe": {
|
|
"PublishableKey": "pk_test_51RjUmIBMIadsOxJVP4bWc54pHEOSf5km1hpOkOBSoGVoKxI46N4KSWtevpXCSq68OjFazBuXmPJGBwZ1KDN5MNJy003lj1YmAS",
|
|
"SecretKey": "sk_test_51RjUmIBMIadsOxJVeqsMFxnZ8ePR7d8IbnaF4sAwBVJv9rrfODPEQ2C9fF3beoABpITdfzEk0ZDzGTTQfvKv63xI00PeZoABGO",
|
|
"WebhookSecret": "SEU_WEBHOOK_PRODUÇÃO_AQUI",
|
|
"Environment": "test"
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### **🔧 FASE 2: CONFIGURAÇÃO DO STRIPE**
|
|
|
|
#### **2.1 Desativar Modo Restrito (CRÍTICO)**
|
|
1. **Acesse**: https://dashboard.stripe.com
|
|
2. **Certifique-se**: Test mode **LIGADO** (toggle azul no topo)
|
|
3. **Settings** → **Account settings**
|
|
4. **Business settings** → **Restrictions**
|
|
5. **"Restricted mode"** → **DESATIVAR** ✅
|
|
|
|
#### **2.2 Configurar Webhook de Produção**
|
|
1. **Stripe Dashboard** → **Developers** → **Webhooks**
|
|
2. **Add endpoint**: `https://bcards.site/api/stripe/webhook`
|
|
3. **Select events**:
|
|
- `customer.subscription.created`
|
|
- `customer.subscription.updated`
|
|
- `customer.subscription.deleted`
|
|
- `invoice.payment_succeeded`
|
|
- `invoice.payment_failed`
|
|
4. **Copiar**: Signing secret → `whsec_...`
|
|
5. **Colar**: no `WebhookSecret` do seu `appsettings.Production.json`
|
|
|
|
---
|
|
|
|
### **📤 FASE 3: COMMIT E DEPLOY**
|
|
|
|
#### **3.1 Commit (SEGURO)**
|
|
```bash
|
|
# Seus arquivos de configuração agora estão seguros:
|
|
git add .
|
|
git commit -m "feat: configuração segura do Stripe para teste online
|
|
|
|
- appsettings.json: chaves removidas (seguro para git)
|
|
- appsettings.Development.json: chaves teste para desenvolvimento
|
|
- appsettings.Production.json: ignorado pelo git (chaves produção)
|
|
- Validação de ambiente Stripe adicionada
|
|
- Endpoint /stripe-info para debugging
|
|
|
|
🔧 Generated with [Claude Code](https://claude.ai/code)
|
|
|
|
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
|
|
# Push para main (deploy automático)
|
|
git push origin main
|
|
```
|
|
|
|
#### **3.2 Verificar Deploy**
|
|
```bash
|
|
# Aguardar deploy completar, então testar:
|
|
curl https://bcards.site/health
|
|
curl https://bcards.site/stripe-info
|
|
```
|
|
|
|
---
|
|
|
|
### **🧪 FASE 4: TESTES ONLINE**
|
|
|
|
#### **4.1 Testar Informações do Stripe**
|
|
```bash
|
|
# Verificar configuração:
|
|
https://bcards.site/stripe-info
|
|
|
|
# Deve mostrar:
|
|
{
|
|
"Environment": "test",
|
|
"IsTestMode": true,
|
|
"WebhookConfigured": true
|
|
}
|
|
```
|
|
|
|
#### **4.2 Testar Pagamento**
|
|
1. **Cadastre-se** no site online
|
|
2. **Escolha um plano**
|
|
3. **Use cartão teste**: `4242 4242 4242 4242`
|
|
4. **Data**: Qualquer data futura (ex: 12/25)
|
|
5. **CVC**: Qualquer 3 dígitos (ex: 123)
|
|
|
|
#### **4.3 Verificar Logs**
|
|
```bash
|
|
# Monitorar webhooks no Stripe Dashboard
|
|
# Developers → Webhooks → Seu endpoint → Recent deliveries
|
|
```
|
|
|
|
---
|
|
|
|
### **🚀 FASE 5: MIGRAÇÃO PARA LIVE (QUANDO PRONTO)**
|
|
|
|
#### **5.1 Obter Chaves Live**
|
|
1. **Stripe Dashboard** → Toggle "Test mode" **OFF**
|
|
2. **Developers** → **API Keys**
|
|
3. **Copiar**: `pk_live_...` e `sk_live_...`
|
|
|
|
#### **5.2 Criar Produtos Live**
|
|
```bash
|
|
# No Stripe Dashboard (Live mode):
|
|
# Products → Create products para cada plano
|
|
# Copiar todos os price_live_xxx
|
|
```
|
|
|
|
#### **5.3 Atualizar Produção**
|
|
```json
|
|
// appsettings.Production.json
|
|
{
|
|
"Stripe": {
|
|
"PublishableKey": "pk_live_...",
|
|
"SecretKey": "sk_live_...",
|
|
"WebhookSecret": "whsec_live_...",
|
|
"Environment": "live"
|
|
},
|
|
"Plans": {
|
|
"Basic": {
|
|
"PriceId": "price_live_basic_xxx" // ← ATUALIZAR TODOS
|
|
}
|
|
// ... outros planos
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 🔍 **DEBUGGING & MONITORAMENTO**
|
|
|
|
### **Endpoints Úteis:**
|
|
- `https://bcards.site/health` - Status da aplicação
|
|
- `https://bcards.site/stripe-info` - Configuração Stripe (apenas logados)
|
|
|
|
### **Logs Importantes:**
|
|
```bash
|
|
# Ao iniciar a aplicação, você verá:
|
|
🔧 Stripe Environment: TEST | Test Mode: True
|
|
⚠️ STRIPE TEST MODE ENABLED - Only test payments will work
|
|
```
|
|
|
|
### **Cartões de Teste:**
|
|
- **Sucesso**: `4242 4242 4242 4242`
|
|
- **Falha**: `4000 0000 0000 0002`
|
|
- **3D Secure**: `4000 0025 0000 3155`
|
|
|
|
---
|
|
|
|
## ✅ **CHECKLIST FINAL**
|
|
|
|
### **Para Teste Online:**
|
|
```bash
|
|
□ Modo Restrito DESATIVADO no Stripe
|
|
□ Webhook configurado para bcards.site
|
|
□ appsettings.Production.json criado (não no git)
|
|
□ Commit realizado (configurações seguras)
|
|
□ Deploy executado com sucesso
|
|
□ /stripe-info mostra Environment: "test"
|
|
□ Pagamento teste funciona online
|
|
```
|
|
|
|
### **Para Produção (Depois):**
|
|
```bash
|
|
□ Chaves LIVE obtidas
|
|
□ Produtos LIVE criados no Stripe
|
|
□ Price IDs atualizados
|
|
□ Webhook LIVE configurado
|
|
□ appsettings.Production.json atualizado
|
|
□ Environment: "live" configurado
|
|
□ Testes com cartões reais (pequenos valores)
|
|
□ Monitoramento ativo
|
|
```
|
|
|
|
---
|
|
|
|
## 🎯 **RESULTADO ESPERADO**
|
|
|
|
**Agora** você pode:
|
|
- ✅ **Testar online** com cartões de teste
|
|
- ✅ **Manter segurança** (chaves fora do git)
|
|
- ✅ **Monitorar** facilmente via endpoints
|
|
- ✅ **Migrar para live** quando pronto
|
|
|
|
**O site funcionará online em modo teste, permitindo que qualquer pessoa teste com cartões fake!** 🎉 |