mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Hosted PDFs by invoice ninja
This commit is contained in:
parent
7fbe4ceb5d
commit
086189a1ea
@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
@ -114,6 +123,7 @@ class BillingPortalPurchase extends Component
|
||||
|
||||
public function handleBeforePaymentEvents()
|
||||
{
|
||||
//stubs
|
||||
$data = [
|
||||
'client_id' => $this->contact->client->id,
|
||||
'date' => now()->format('Y-m-d'),
|
||||
@ -142,6 +152,7 @@ class BillingPortalPurchase extends Component
|
||||
$this->emit('beforePaymentEventsCompleted');
|
||||
}
|
||||
|
||||
//this isn't managed here - this is taken care of in the BS
|
||||
public function applyCouponCode()
|
||||
{
|
||||
dd('Applying coupon code: ' . $this->coupon);
|
||||
|
@ -25,6 +25,7 @@ use App\Models\RecurringInvoiceInvitation;
|
||||
use App\Services\PdfMaker\Design as PdfDesignModel;
|
||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
||||
use App\Utils\HostedPDF\NinjaPdf;
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\PhantomJS\Phantom;
|
||||
@ -160,7 +161,13 @@ class CreateEntityPdf implements ShouldQueue
|
||||
$pdf = null;
|
||||
|
||||
try {
|
||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
||||
|
||||
if(config('ninja.invoiceninja_hosted_pdf_generation')){
|
||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
}
|
||||
else {
|
||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
nlog(print_r($e->getMessage(), 1));
|
||||
}
|
||||
|
@ -29,18 +29,27 @@ class BillingSubscriptionService
|
||||
$this->billing_subscription = $billing_subscription;
|
||||
}
|
||||
|
||||
public function completePurchase(PaymentHash $payment_hash)
|
||||
{
|
||||
|
||||
// create client subscription record
|
||||
//
|
||||
// create recurring invoice if is_recurring
|
||||
//
|
||||
// s
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function startTrial(array $data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function createInvoice($data): ?\App\Models\Invoice
|
||||
{
|
||||
$invoice_repo = new InvoiceRepository();
|
||||
|
||||
// $data = [
|
||||
// 'client_id' =>,
|
||||
// 'date' => Y-m-d,
|
||||
// 'invitations' => [
|
||||
// 'client_contact_id' => hashed_id
|
||||
// ],
|
||||
// 'line_items' => [],
|
||||
// ];
|
||||
$data['line_items'] = $this->createLineItems($data['quantity']);
|
||||
|
||||
/*
|
||||
|
37
app/Utils/HostedPDF/NinjaPdf.php
Normal file
37
app/Utils/HostedPDF/NinjaPdf.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Utils\HostedPDF;
|
||||
|
||||
use GuzzleHttp\RequestOptions;
|
||||
|
||||
class NinjaPdf
|
||||
{
|
||||
|
||||
private $url = 'https://pdf.invoicing.co/api/';
|
||||
|
||||
public function build($html)
|
||||
{
|
||||
|
||||
$client = new \GuzzleHttp\Client(['headers' =>
|
||||
[
|
||||
'X-Ninja-Token' => 'test_token_for_now',
|
||||
]
|
||||
]);
|
||||
|
||||
$response = $client->post($this->url,[
|
||||
RequestOptions::JSON => ['html' => $html]
|
||||
]);
|
||||
|
||||
return $response->getBody();
|
||||
}
|
||||
|
||||
}
|
@ -144,4 +144,5 @@ return [
|
||||
'flutter_canvas_kit' => env('FLUTTER_CANVAS_KIT', false),
|
||||
'webcron_secret' => env('WEBCRON_SECRET', false),
|
||||
'disable_auto_update' => env('DISABLE_AUTO_UPDATE', false),
|
||||
'invoiceninja_hosted_pdf_generation' => env('NINJA_HOSTED_PDF', false),
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user