1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #5166 from turbo124/v5-develop

Hosted PDF
This commit is contained in:
David Bomba 2021-03-18 11:56:19 +11:00 committed by GitHub
commit 2415a3cf32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 76 additions and 11 deletions

View File

@ -1 +1 @@
5.1.26
5.1.27

View File

@ -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);

View File

@ -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));
}

View File

@ -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']);
/*

View 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();
}
}

View File

@ -13,7 +13,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.1.26',
'app_version' => '5.1.27',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),
@ -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),
];