diff --git a/app/Models/Company.php b/app/Models/Company.php index c0bb8f2df705..b062d01d4b46 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -904,4 +904,18 @@ class Company extends BaseModel return $item->id == $this->getSetting('date_format_id'); })->first()->format; } + + public function getInvoiceCert() + { + if($this->e_invoice_certificate) + return base64_decode($this->e_invoice_certificate); + + return false; + } + + public function getSslPassPhrase() + { + return $this->e_invoice_certificate_passphrase; + } + } diff --git a/app/Services/Invoice/EInvoice/FacturaEInvoice.php b/app/Services/Invoice/EInvoice/FacturaEInvoice.php index 98802616ac9e..ffb9622b2670 100644 --- a/app/Services/Invoice/EInvoice/FacturaEInvoice.php +++ b/app/Services/Invoice/EInvoice/FacturaEInvoice.php @@ -174,9 +174,9 @@ class FacturaEInvoice extends AbstractService $disk = config('filesystems.default'); - if (!Storage::disk($disk)->exists($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()))) { - Storage::makeDirectory($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first())); - } + // if (!Storage::disk($disk)->exists($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()))) { + // Storage::makeDirectory($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first())); + // } $this->fac->export(Storage::disk($disk)->path($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xsig"))); @@ -386,9 +386,12 @@ class FacturaEInvoice extends AbstractService private function signDocument(): self { - // $ssl_cert = file_get_contents(base_path('e_invoice_cert.p12')); - // $this->fac->sign($ssl_cert, null, "SuperSecretPassword"); + $ssl_cert = $this->invoice->company->getInvoiceCert(); + $ssl_passphrase = $this->invoice->company->getSslPassPhrase(); + + if($ssl_cert) + $this->fac->sign($ssl_cert, null, $ssl_passphrase); return $this; }