agustinzamar / laravel-arca-sdk
A Laravel package to easily use the ARCA (ex AFIP) web services.
Fund package maintenance!
Agustin Zamar
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/agustinzamar/laravel-arca-sdk
Requires
- php: ^8.1||^8.2||^8.3||^8.4||^8.5
- ext-openssl: *
- ext-simplexml: *
- ext-soap: *
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
This package makes it easy to use the ARCA (ex AFIP) web services in your Laravel application.
⚠️ Do not use this package yet, it is still under development.
Installation
You can install the package via composer:
composer require agustinzamar/laravel-arca-sdk
You can publish the config file with:
php artisan vendor:publish --tag="arca-sdk-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="arca-sdk-views"
Setup
To Start using the ARCA Web Services you need to register a certificate on their system.
- Create CSR file:
2. Run
openssl genrsa -out arca.key 2048
3. Runopenssl req -new -key arca.key -subj "/C=AR/O=YourName/CN=AppName/serialNumber=CUIT XXXXXXXXXXX" -out arca.csr
- Login into ARCA using your CUIT and password
- Search for WSAS - Autogestión Certificados Homologación"
- Select "Nuevo Certificado"
- Set a name and paste the contents of the arca.csr file, then click on "Crear DN y obtener certificado"
- Copy the result on a plain text file and save it as arca.crt
- Paste
arca.key
,arca.csr
, andarca.crt
instorage/app/arca/
- You are now ready to use the package
Usage
You can use the package by using the Arca
facade. Here is an example of how to use it:
Obtaining Invoice Types
Arca::getInvoiceTypes()
Obtaining Recipient VAT Conditions
Arca::getRecipientVatConditions();
Obtaining the last authorized invoice number
$pointOfSale = 1; // Your point of sale number Arca::getLastInvoiceNumber($pointOfSale, InvoiceType::FACTURA_A);
Obtaining the details of an existing invoice
$pointOfSale = 1; // Your point of sale number $invoiceNumber = 123; // Invoice number to query Arca::getInvoiceDetails($pointOfSale, InvoiceType::FACTURA_C, $invoiceNumber);
Creating an invoice
$pointOfSale = 1; // Your point of sale number $nextInvoiceNumber = Arca::getLastInvoiceNumber($pointOfSale, InvoiceType::FACTURA_C); $request = new CreateInvoiceRequest( concept: InvoiceConcept::GOODS, pointOfSale: $pointOfSale, identification: new Identification( type: IdentificationType::CUIT, number: 20111111112 ), invoiceType: InvoiceType::FACTURA_C, invoiceFrom: $nextInvoiceNumber, invoiceTo: $nextInvoiceNumber, total: 150.0, net: 150.0, exempt: 0.0, nonTaxableConceptsAmount: 0.0, vatCondition: 1, currency: Currency::ARS, currencyQuote: 1.0, invoiceDate: now()->addDays(3), ); Arca::generateInvoice($request); // Or automatically generate next invoice $request = new CreateInvoiceRequest( concept: InvoiceConcept::GOODS, pointOfSale: 12, identification: new Identification( type: IdentificationType::CUIT, number: 20111111112 ), invoiceType: InvoiceType::FACTURA_C, total: 150.0, net: 150.0, exempt: 0.0, nonTaxableConceptsAmount: 0.0, vatCondition: 1, currency: Currency::ARS, currencyQuote: 1.0, invoiceDate: now()->addDays(3), ); Arca::generateNextInvoice($request);
The package also offers a set of convenient Enums for commonly used values:
InvoiceType
: Represents the different types of invoices (e.g., FACTURA_A, FACTURA_B, etc.).InvoiceConcept
: Represents the concept of the invoice (e.g., GOODS, SERVICES, etc.).IdentificationType
: Represents the type of identification (e.g., CUIT, CUIL, etc.).Currency
: Represents the currency type (e.g., ARS, USD, etc.).RecipientVatCondition
: Represents the VAT condition of the recipient (e.g., RESPONSABLE_INSCRIPTO, MONOTRIBUTISTA, etc.).
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please report any security vulnerabilities to agustinzamar33@gmail.com
Credits
License
The MIT License (MIT). Please see License File for more information.