diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 182dcb0c93..6f74313cb8 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -18,6 +18,7 @@ use App\Models\Invoice; use App\Models\InvoiceInvitation; use App\Services\PdfMaker\Design; use App\Services\PdfMaker\PdfMaker; +use App\Utils\HostedPDF\NinjaPdf; use App\Utils\HtmlEngine; use App\Utils\Ninja; use App\Utils\PhantomJS\Phantom; @@ -133,6 +134,10 @@ class PreviewController extends BaseController if (config('ninja.phantomjs_pdf_generation')) { return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true)); } + + if(config('ninja.invoiceninja_hosted_pdf_generation')){ + return (new NinjaPdf())->build($maker->getCompiledHTML(true)); + } //else $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); @@ -216,6 +221,10 @@ class PreviewController extends BaseController if (config('ninja.phantomjs_pdf_generation')) { return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true)); } + + if(config('ninja.invoiceninja_hosted_pdf_generation')){ + return (new NinjaPdf())->build($maker->getCompiledHTML(true)); + } $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index f70bf4fbb1..03ef21bb33 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -241,7 +241,7 @@ class BaseDriver extends AbstractPaymentDriver event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); - BillingSubscriptionService::completePurchase($this->payment_hash); + (new BillingSubscriptionService)->completePurchase($this->payment_hash); return $payment->service()->applyNumber()->save(); } diff --git a/app/Services/BillingSubscription/BillingSubscriptionService.php b/app/Services/BillingSubscription/BillingSubscriptionService.php index d93f65f41d..62eba98640 100644 --- a/app/Services/BillingSubscription/BillingSubscriptionService.php +++ b/app/Services/BillingSubscription/BillingSubscriptionService.php @@ -32,11 +32,17 @@ class BillingSubscriptionService public function completePurchase(PaymentHash $payment_hash) { + if (!property_exists($payment_hash, 'billing_context')) { + return; + } + + // At this point we have some state carried from the billing page + // to this, available as $payment_hash->data->billing_context. Make something awesome ⭐ + // create client subscription record // // create recurring invoice if is_recurring // - // s } @@ -53,7 +59,6 @@ class BillingSubscriptionService $data['line_items'] = $this->createLineItems($data['quantity']); /* - If trial_enabled -> return early -- what we need to know that we don't already @@ -118,13 +123,5 @@ class BillingSubscriptionService //scan for any notification we are required to send } - public static function completePurchase(PaymentHash $payment_hash) - { - if (!property_exists($payment_hash, 'billing_context')) { - return; - } - // At this point we have some state carried from the billing page - // to this, available as $payment_hash->data->billing_context. Make something awesome ⭐ - } } diff --git a/app/Utils/HostedPDF/NinjaPdf.php b/app/Utils/HostedPDF/NinjaPdf.php index f0137fd459..7c5de140b4 100644 --- a/app/Utils/HostedPDF/NinjaPdf.php +++ b/app/Utils/HostedPDF/NinjaPdf.php @@ -21,6 +21,9 @@ class NinjaPdf public function build($html) { +nlog("building remotely"); + + $client = new \GuzzleHttp\Client(['headers' => [ 'X-Ninja-Token' => 'test_token_for_now',