Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Greenter Laravel Package

codersfree/laravel-greenter

Paquete para emitir comprobantes electrónicos en Laravel con Greenter: firma digital, envío a SUNAT (SEE o REST), generación de XML firmados, manejo de CDR y representación impresa en HTML/PDF. Soporta emisión para múltiples empresas y envío de XML existente.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Domain Alignment: The package is tailored for Peruvian electronic invoicing (Facturación Electrónica) under SUNAT regulations, making it a highly specialized fit for businesses operating in Peru or requiring SUNAT compliance. It abstracts complex XML schema generation, digital signing (via SunatOCSP or SunatPKCS12), and SUNAT API interactions, reducing custom development effort.
  • Laravel Synergy: Leverages Laravel’s service providers, facades, and event system for seamless integration. Follows Laravel conventions (e.g., config files, service containers), minimizing architectural friction.
  • Modularity: The package is designed as a standalone module, allowing for incremental adoption (e.g., start with XML generation before enabling API calls).

Integration Feasibility

  • Core Features:
    • XML Schema Compliance: Generates SUNAT-compliant XML for invoices, credit notes, and other documents (CFDI).
    • Digital Signing: Supports PKCS12 and OCSP signing methods (critical for SUNAT validation).
    • SUNAT API Integration: Handles consultas, envío de comprobantes, and recepción de respuestas via SUNAT’s SOAP/WSDL endpoints.
    • Web Services: Provides endpoints for real-time validation (e.g., checking if a document is accepted/rejected by SUNAT).
  • Dependencies:
    • Requires PHP 8.0+, Laravel 8+, and OpenSSL (for PKCS12 signing).
    • Uses Guzzle HTTP (for API calls) and SimpleXMLElement (for XML handling).
    • No heavy database schema changes required; stores configurations in Laravel’s config/greenter.php.

Technical Risk

Risk Area Assessment Mitigation Strategy
SUNAT API Changes SUNAT frequently updates schemas/APIs (e.g., new tax laws, XML versions). Monitor SUNAT’s official docs and fork the package for patches.
PKCS12/OCSP Configuration Misconfigured certificates can cause SUNAT rejections. Implement pre-signing validation (e.g., test with SUNAT’s sandbox environment first).
XML Schema Validation Custom document types (e.g., light invoices) may not be fully supported. Extend the package via service providers or custom XML templates.
Performance SUNAT API rate limits or slow responses could impact real-time operations. Cache responses (e.g., rejected documents) and implement retry logic with exponential backoff.
Legacy System Integration Existing ERP/legacy systems may not align with SUNAT’s data model. Use Laravel queues to decouple document generation from SUNAT submission.

Key Questions

  1. Compliance Scope:

    • Does the business require only invoices (Factura Electrónica) or also credit notes (Nota de Crédito), perception vouchers (Recibo por Operaciones en el Exterior), etc.?
    • Are there custom document types (e.g., light invoices for S/ 1500 or less)?
  2. Signing Method:

    • Will the team use PKCS12 (recommended by SUNAT) or OCSP? Does the organization have the necessary digital certificates?
  3. Testing Strategy:

    • Is access to SUNAT’s sandbox environment available for pre-go-live testing?
    • Are there automated tests (e.g., PHPUnit) to validate XML generation and API responses?
  4. Error Handling:

    • How will SUNAT rejections (e.g., invalid UBL, expired certificates) be surfaced to end users?
    • Should rejected documents trigger automated retries or require manual review?
  5. Audit & Compliance:

    • Does the system need to log all SUNAT interactions (e.g., for tax audits)?
    • Are there retention policies for electronic documents (SUNAT requires 10+ years)?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Service Providers: The package registers as a Laravel service provider, allowing dependency injection (e.g., Greenter\GreenterFacade::invoice()).
    • Config Files: Centralized configuration (config/greenter.php) for SUNAT credentials, endpoints, and signing methods.
    • Events: Triggers events (e.g., InvoiceGenerated, SunatResponseReceived) for custom logic (e.g., notifications, analytics).
  • PHP Extensions:
    • OpenSSL: Required for PKCS12 signing. Verify server has php-openssl enabled.
    • DOM/SimpleXML: Used for XML parsing. Ensure php-xml is installed.
  • Database:
    • No mandatory tables, but the package suggests storing:
      • Document metadata (e.g., sunat_document_id, status).
      • Certificate rotations (expiry dates).
    • Recommend using Laravel Migrations for these tables.

Migration Path

Phase Action Items Dependencies
1. Setup & Validation Install package (composer require codersfree/laravel-greenter). Publish config (php artisan vendor:publish --provider="Greenter\GreenterServiceProvider"). SUNAT credentials, PKCS12/OCSP setup.
2. XML Generation Test XML output for a sample invoice using the package’s sandbox mode. Sample data (client, product, tax info).
3. Signing & Local Validation Validate locally generated XML against SUNAT’s XSD schemas. SUNAT XSD files (download from SUNAT).
4. Sandbox Testing Submit test documents to SUNAT’s sandbox API and verify responses. Sandbox credentials.
5. Production Rollout Deploy to staging, monitor SUNAT API calls, and validate against real responses. Staging environment with live-like data.
6. Monitoring Set up Laravel Horizon or external monitoring for SUNAT API failures. Logging (e.g., Laravel’s log channel).

Compatibility

  • Laravel Versions: Officially supports Laravel 8+. Test thoroughly if using Laravel 9/10 (check for breaking changes in dependencies like Guzzle).
  • PHP Versions: Requires PHP 8.0+ (type hints, named arguments). Avoid PHP 7.x.
  • SUNAT Schema Versions: The package may lag behind SUNAT’s latest schema. Plan for periodic updates (e.g., quarterly reviews).
  • Third-Party Tools:
    • Digital Certificates: Ensure compatibility with SUNAT’s PKCS12 format (e.g., generated via SUNAT’s OCSP tool).
    • PDF Generation: The package doesn’t generate PDFs; integrate with Laravel Snappy or DomPDF if needed.

Sequencing

  1. Core Integration:
    • Start with invoice generation and local XML validation.
    • Gradually enable SUNAT API calls (first in sandbox).
  2. Extended Features:
    • Add webhooks for SUNAT responses (e.g., notify when a document is accepted/rejected).
    • Implement automated retries for failed submissions.
  3. Customization:
    • Extend XML templates for non-standard document types.
    • Add custom fields via Laravel’s accessors/mutators.

Operational Impact

Maintenance

  • Package Updates:
    • Monitor GitHub releases and SUNAT announcements for schema/API changes.
    • Fork the package if upstream updates are too slow (e.g., for custom SUNAT versions).
  • Certificate Management:
    • SUNAT certificates expire (~1 year). Automate renewal alerts (e.g., Laravel scheduler).
    • Store certificates securely (e.g., encrypted config or AWS Secrets Manager).
  • Configuration Drift:
    • Use Laravel Envoy or Ansible to sync config/greenter.php across environments.

Support

  • Troubleshooting:
    • Common Issues:
      • XML Validation Errors: Use SUNAT’s validation tool to debug.
      • Signing Failures: Verify PKCS12 password and OpenSSL compatibility.
      • API Timeouts: SUNAT’s SOAP endpoint may throttle requests; implement rate limiting.
    • Logging:
      • Log raw SUNAT responses (XML/JSON) for audits.
      • Use **
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php
agtp/mod-php
centraldesktop/protobuf-php