https://github.com/feimx/csd-converter
This package allow convert CSD (cer and key files) to pem files
https://github.com/feimx/csd-converter
cfdi33 csd electronica facturacion mexico sat
Last synced: 5 days ago
JSON representation
This package allow convert CSD (cer and key files) to pem files
- Host: GitHub
- URL: https://github.com/feimx/csd-converter
- Owner: feimx
- License: mit
- Created: 2018-08-06T20:17:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-08T07:00:52.000Z (almost 8 years ago)
- Last Synced: 2025-12-14T16:48:28.902Z (6 months ago)
- Topics: cfdi33, csd, electronica, facturacion, mexico, sat
- Language: PHP
- Size: 25.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Convert pem required files for CFDI
[](https://packagist.org/packages/feimx/csd_converter)
[](https://travis-ci.org/feimx/csd_converter)
[](https://scrutinizer-ci.com/g/feimx/csd_converter)
[](https://packagist.org/packages/feimx/csd_converter)
The `feimx/csd_converter` package provide a simple way for create .pem files for your CSD's.
## Installation
You can install the package via composer:
```bash
composer require feimx/csd_converter
```
## Usage
Firt need create a new instance of `CsdConverter`:
``` php
$converter = new FeiMx\Csd\CsdConverter();
echo $converter->serial_number();
```
Thats all, now you can access the cer info and save the news files to given path
``` php
echo $converter->serial_number;
echo $converter->tax_id;
echo $converter->valid_from; // instance of Carbon
echo $converter->valid_to; // instance of Carbon
echo $converter->getStatus();
```
`valid_from` and `valid_to` are instances of Carbon, so you can modify and format the dates:
``` php
echo $converter->valid_from->format('d/m/Y h:i a');
echo $converter->valid_to->format('d/m/Y h:i a');
```
`getStatus()` returns a expired, valid or invalid status:
``` php
if($converter->getStatus() === CsdConverter::VALID){}
if($converter->getStatus() === CsdConverter::INVALID){}
if($converter->getStatus() === CsdConverter::EXPIRED){}
```
You can verify if the files are a valid CSD:
``` php
var_dump($converter->isValidCsd()); // true or false
```
Now you can save the created files to a given path and assigne a optional filename:
``` php
$path = __DIR__.'/temp/';
$filename = 'VALIDCSD';
$converter->save($path, $filename);
//this create 4 files:
//__DIR__.'/temp/VALIDCSD.cer'
//__DIR__.'/temp/VALIDCSD.cer.pem'
//__DIR__.'/temp/VALIDCSD.key'
//__DIR__.'/temp/VALIDCSD.key.pem'
```
And last, but not less important, you can encryp the converted key into des3:
``` php
$file = __DIR__.'/temp/VALIDCSD.key.pem';
$password = 'secret';
$converter->encryptKey($file, $password);
//__DIR__.'/temp/VALIDCSD.enc.key'
```
_Note:_ This is very useful with third party provider such as Finkok for stamp the CFDI
### Testing
``` bash
composer test
```
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email yorch@feimexico.com.mx instead of using the issue tracker.
## Credits
- [Jorge Andrade](https://github.com/Yorchi)
- [All Contributors](../../contributors)
## Support us
FEI is a Digital Invoicing startup based in Yucatán, México. You'll find an overview of all our open source projects [on our website](https://fei.com.mx/opensource).
Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/jorge_andrade).
All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.