feimx/csd-converter

This package allow you to convert csd to required pem files

1.1 2018-08-08 06:59 UTC

This package is auto-updated.

Last update: 2024-10-20 05:05:57 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

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:

composer require feimx/csd_converter

Usage

Firt need create a new instance of CsdConverter:

$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

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:

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:

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:

var_dump($converter->isValidCsd()); // true or false

Now you can save the created files to a given path and assigne a optional filename:

$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:

$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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email yorch@feimexico.com.mx instead of using the issue tracker.

Credits

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.

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License

The MIT License (MIT). Please see License File for more information.