PHP code example of raalveco / ciberfactura
1. Go to this page and download the library: Download raalveco/ciberfactura library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
raalveco / ciberfactura example snippets
// config/app.php
'providers' => [
Raalveco\Ciberfactura\CiberfacturaServiceProvider::class,
];
'aliases' => [
'Cfdi' => Raalveco\Ciberfactura\Facades\Cfdi::class,
];
return array(
'production' => env('CFDI_PRODUCTION', false),
'certificate' => array(
'cer' => env('CFDI_CERTIFICATE_CER', 'config/packages/raalveco/ciberfactura/certificate/aad990814bp7_1210261233s.cer'),
'key' => env('CFDI_CERTIFICATE_KEY', 'config/packages/raalveco/ciberfactura/certificate/aad990814bp7_1210261233s.key'),
'password' => env('CFDI_CERTIFICATE_PRIVATE_KEY', '12345678a')
),
'wsdl' => array(
'sandbox' => array(
'autentificacion' => 'http://pruebascfdi.smartweb.com.mx/Autenticacion/wsAutenticacion.asmx?wsdl',
'timbrado' => 'http://pruebascfdi.smartweb.com.mx/Timbrado/wsTimbrado.asmx?wsdl',
'cancelacion' => 'http://pruebascfdi.smartweb.com.mx/Cancelacion/wsCancelacion.asmx?wsdl',
'usuario' => 'demo',
'password' => '123456789',
),
'production' => array(
'autentificacion' => 'https://cfdi.smartweb.com.mx/Autenticacion/wsAutenticacion.asmx?wsdl',
'timbrado' => 'https://cfdi.smartweb.com.mx/Timbrado/wsTimbrado.asmx?wsdl',
'cancelacion' => 'https://cfdi.smartweb.com.mx/Cancelacion/wsCancelacion.asmx?wsdl',
'usuario' => env('SMART_WEB_USER', ''),
'password' => env('SMART_WEB_PASSWORD', ''),
)
),
'path_xmls' => public_path().'/cfdis'
);
$factura = CfdiFactura::create(
array(
"serie" => "A",
"folio" => 234,
"fecha" => date("Y-m-d H:i:s"),
"subTotal" => 200,
"total" => 232.0
)
);
$factura->addEmisor(
"AAD990814BP7",
"EMPRESA PRUEBAS SA DE CV",
"Independencia",
"54",
"",
"Centro",
"Ameca",
"Ameca",
"Jalisco",
"Mexico",
"46600"
);
$factura->addReceptor(
"PEGJ801021H4K",
"Juan Pérez González",
"Juarez",
"56",
"3A",
"Centro",
"Guadalajara",
"Guadalajara",
"Jalisco",
"Mexico",
"44460"
);
$factura->addConcepto(
1,
"Año",
"Servicio de Facturación Electrónica",
100.00,
100.00
);
$factura->addConcepto(
1,
"Año",
"Servicio de Timbrado de Facturas Electrónicas",
100.00,
100.00
);
$factura->addImpuesto(
"Traslado",
"IVA",
16.00,
32.00
);
$factura->addSucursal(
"Av. Revolución",
"212",
"",
"Centro",
"Ameca",
"Ameca",
"Jalisco",
"Mexico",
"46600"
);
$factura->addRegimen("Regimen General para Personas Morales");
Cfdi::loadCfdi($factura);
$sello = Cfdi::sellar();
$uuid = Cfdi::timbrar();
Cfdi::guardar();
$xml = Cfdi::xml();
bash
php artisan vendor:publish
bash
php artisan migrate