Overview
SUNAT provides two separate environments for electronic invoicing:- Beta (Testing) - For development and testing
- Production - For real business documents
Environment Comparison
- Beta / Testing
- Production
Purpose: Development, testing, and trainingCharacteristics:
- No legal validity
- Test credentials provided by SUNAT
- Relaxed validation rules
- May have downtime for maintenance
- Free to use
- Initial integration development
- Testing new document types
- Training users
- Debugging issues
- Invoicing:
https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService - Dispatch Guides (GRE):
https://api-cpe-beta.sunat.gob.pe/v1/
Configuration
Company Model
Environment configuration is managed at the company level: Location:app/Models/Company.php:14
app/Models/Company.php
Default Endpoints
Endpoints are automatically configured when creating a company: Location:app/Models/Company.php:130
app/Models/Company.php
Environment Switching
Switch between Beta and Production by updatingmodo_produccion:
Service Endpoints
SUNAT has different endpoints for different document types.Invoicing Endpoints (Facturas, Boletas, Notas)
Configuration:app/Traits/HasCompanyConfigurations.php:586
- Beta
- Production
- Facturas (01)
- Boletas (03)
- Credit Notes (07)
- Debit Notes (08)
- Daily Summaries
- Voided Documents
Dispatch Guide Endpoints (Guías de Remisión - GRE)
- Beta
- Production
GRE uses OAuth2 authentication instead of SOAP. Requires
client_id and client_secret.Dynamic Endpoint Selection
The system automatically selects endpoints based onmodo_produccion:
Location: app/Traits/HasCompanyConfigurations.php:368
app/Traits/HasCompanyConfigurations.php
GreenterService Configuration
GreenterService initializes with environment-specific settings: Location:app/Services/GreenterService.php:50
app/Services/GreenterService.php
Testing in Beta
Setup Beta Testing
Beta Testing Checklist
Test All Document Types
Test All Document Types
- Facturas (01)
- Boletas (03)
- Credit Notes (07)
- Debit Notes (08)
- Daily Summaries
- Voided Documents
- Dispatch Guides (09)
Test Tax Scenarios
Test Tax Scenarios
- Gravada (IGV 18%)
- Exonerada (No IGV)
- Inafecta (No IGV)
- Gratuita (Free items)
- IVAP (Rice tax)
- ISC (Selective consumption)
- ICBPER (Plastic bag tax)
Test Payment Methods
Test Payment Methods
- Contado (Cash)
- Crédito (Credit with installments)
- Multiple installments
Test Error Handling
Test Error Handling
- Invalid RUC
- Missing required fields
- Invalid tax calculations
- Network timeouts
- SUNAT rejection codes
Production Deployment
Pre-Production Checklist
Verify Company Registration
- Company is registered with SUNAT for electronic invoicing
- Valid SOL credentials obtained from SUNAT
- Production digital certificate acquired from approved CA
Environment Comparison
| Feature | Beta | Production |
|---|---|---|
| Legal Validity | No | Yes |
| Credentials | Test credentials | Real SOL credentials |
| Certificate | Test or real | Must be real |
| Validation | Relaxed | Strict |
| Availability | May have downtime | High availability |
| Cost | Free | Free (service), certificate costs vary |
| Document Storage | Temporary | Permanent |
| CDR Response | Similar format | Official format |
| Monitoring | Not monitored | Subject to SUNAT audits |
Environment-Specific Configurations
Configuration Trait
TheHasCompanyConfigurations trait manages environment-specific settings:
Location: app/Traits/HasCompanyConfigurations.php:44
app/Traits/HasCompanyConfigurations.php
GRE Credentials by Environment
Location:app/Traits/HasCompanyConfigurations.php:210
app/Traits/HasCompanyConfigurations.php
Logging and Monitoring
The system logs environment information for debugging:Best Practices
Test Thoroughly in Beta
Complete all testing scenarios in Beta before switching to Production
Use Separate Databases
Maintain separate databases for Beta and Production environments
Monitor Production
Set up alerts for SUNAT rejections and errors in Production
Backup Before Switching
Back up database and configurations before switching environments
Common Issues
Error: Invalid credentials in Production
Error: Invalid credentials in Production
Cause: Using test credentials (MODDATOS) in Production mode.Solution:
Error: Certificate rejected in Production
Error: Certificate rejected in Production
Cause: Using test certificate in Production or certificate doesn’t match RUC.Solution:
- Verify certificate CN matches company RUC
- Ensure certificate is from SUNAT-approved CA
- Check certificate hasn’t expired
Documents accepted in Beta but rejected in Production
Documents accepted in Beta but rejected in Production
Cause: Production has stricter validation than Beta.Solution:
- Review SUNAT rejection message
- Ensure all required fields are present
- Verify tax calculations are exact
- Check document series is authorized by SUNAT
Can't switch back to Beta
Can't switch back to Beta
Cause: Once in Production, switching back can confuse document tracking.Solution:
- Use separate companies for Beta and Production
- If you must switch, ensure all pending documents are completed first
Next Steps
Create Your First Invoice
Start sending documents to SUNAT
API Reference
Explore all available endpoints
