greenter/ws
Cliente PHP para conectar con los Web Services de SUNAT y enviar comprobantes electrónicos. Parte del ecosistema Greenter, con documentación oficial y soporte vía issues/pull requests en el repositorio principal.
sunat.pe for validation, emission, or consultation of electronic documents).SUNATService facade).sunat-api) if the team prefers decoupling.https://e-factura.sunat.gob.pe). Feasibility is high if:
Mockery or Vcr).guzzlehttp/guzzle (for HTTP requests), phpseclib/phpseclib (for digital signatures).config, log, and cache systems (if configured).phpseclib may need updates for TLS 1.3 compliance (SUNAT may enforce this).ComprobanteElectronico).CDR, receipts, or errors like 1001 for invalid signatures).UBL-2.1 for invoices) may require additional libraries (e.g., ext-simplexml, xmlschema).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Deprecated Package | High | Fork/replace if SUNAT API changes (last update: 2019). |
| SOAP/XML Complexity | Medium | Use Laravel’s SoapClient as fallback if issues arise. |
| Digital Signing | High | Test with mock certificates before production. |
| Rate Limiting | Medium | Implement exponential backoff for retries. |
| Laravel Version | Low | Package is PHP 7.2+; Laravel 8+ should work with minor tweaks. |
CDR for credit notes, PDA for authorizations)?.p12/.pfx) be managed? (e.g., AWS Secrets Manager, Laravel Vault).phpseclib support it?Vcr or Pest).composer require greenter/ws
AppServiceProvider):
$this->app->singleton(SUNATService::class, function ($app) {
return new SUNATService(config('sunat.credentials'));
});
use Greenter\Ws\Facades\SUNAT;
SUNAT::sendInvoice($xmlPayload);
Phase 1: Proof of Concept (PoC)
Phase 2: Core Integration
spatie/laravel-queueable-middleware).Log channel).User creates invoice → System generates XML → SUNATService sends to SUNAT → Store CDR → Return receipt to user.
Phase 3: Production Readiness
sunat_audit_logs table).composer.json).^6.5 or ^7.0 is used (avoid breaking changes).| Task | Priority | Dependencies |
|---|---|---|
| Set up local SUNAT mock | P0 | None |
| Integrate package via Composer | P0 | Mock setup |
| Implement digital signing | P0 | Test certificates |
| Wrap SUNAT calls in Jobs | P1 | Queue setup (e.g., Redis) |
| Add retry logic | P1 | Job wrappers |
| Configure logging/monitoring | P1 | Laravel monitoring tools (e.g., Sentry) |
| Test with real SUNAT sandbox | P2 | Valid credentials |
| Deploy to staging | P2 | All tests passed |
| Roll out to production | P3 | Backup plan documented |
How can I help you explore Laravel packages today?