PHP code example of elpandape / quipu-lite
1. Go to this page and download the library: Download elpandape/quipu-lite 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/ */
elpandape / quipu-lite example snippets
use ElPandaPe\Quipu\Quipu;
use ElPandaPe\Quipu\Signer\XmlSecSigner;
use ElPandaPe\Quipu\Ws\{SoapEndpoints, SoapSender};
use ElPandaPe\Quipu\Xml\InvoiceBuilder;
$quipu = new Quipu(
new InvoiceBuilder(),
new XmlSecSigner($certificatePem), // PEM: cert X.509 + clave privada
new SoapSender(SoapEndpoints::beta()->billServiceUrl(), $solUsername, $solPassword),
);
$errors = $quipu->validate($invoice); // reglas de negocio SUNAT, opt-in — [] si es consistente
$result = $quipu->emitInvoice($invoice); // firma + envío; devuelve un BillResult con el CDR tipado
$result->cdr->status; // Accepted | AcceptedWithObservations | Rejected
$result->cdr->responseCode; // "0" = aceptado