diff --git a/VERSION.txt b/VERSION.txt
index 09543ba2c390..eeb25c4a8c70 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-5.1.33
\ No newline at end of file
+5.1.34
\ No newline at end of file
diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php
index d9ffe3792038..41e832f03576 100644
--- a/app/DataMapper/CompanySettings.php
+++ b/app/DataMapper/CompanySettings.php
@@ -600,6 +600,7 @@ class CompanySettings extends BaseSettings
'$client.city_state_postal',
'$client.country',
'$contact.email',
+ '$client.phone',
],
'company_details' => [
'$company.name',
diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php
index e64bac17a292..8451e1d7a3e5 100644
--- a/app/Http/Controllers/InvoiceController.php
+++ b/app/Http/Controllers/InvoiceController.php
@@ -795,7 +795,7 @@ class InvoiceController extends BaseController
$file_path = $invoice->service()->getInvoicePdf($contact);
-nlog($file_path);
+ nlog($file_path);
return response()->download($file_path, basename($file_path));
}
diff --git a/app/Jobs/Mail/PaymentFailureMailer.php b/app/Jobs/Mail/PaymentFailureMailer.php
index 1fb0f000db5c..bce2f69c3656 100644
--- a/app/Jobs/Mail/PaymentFailureMailer.php
+++ b/app/Jobs/Mail/PaymentFailureMailer.php
@@ -11,12 +11,12 @@
namespace App\Jobs\Mail;
+use App\Jobs\Mail\NinjaMailer;
use App\Jobs\Mail\NinjaMailerJob;
use App\Jobs\Mail\NinjaMailerObject;
use App\Libraries\MultiDB;
use App\Mail\Admin\EntityNotificationMailer;
use App\Mail\Admin\PaymentFailureObject;
-use App\Mail\NinjaMailer;
use App\Models\User;
use App\Utils\Traits\Notifications\UserNotifies;
use Illuminate\Bus\Queueable;
diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php
index 748b27de0234..57ca3011ab06 100644
--- a/app/Models/Subscription.php
+++ b/app/Models/Subscription.php
@@ -20,6 +20,16 @@ class Subscription extends BaseModel
{
use HasFactory, SoftDeletes;
+ protected $hidden = [
+ 'id',
+ 'user_id',
+ 'assigned_user_id',
+ 'company_id',
+ 'product_ids',
+ 'recurring_product_ids',
+ 'group_id',
+ ];
+
protected $fillable = [
'assigned_user_id',
'product_ids',
diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php
index 79c031a1718b..581a5da1fa8c 100644
--- a/app/Services/Invoice/GenerateDeliveryNote.php
+++ b/app/Services/Invoice/GenerateDeliveryNote.php
@@ -17,7 +17,9 @@ use App\Models\Design;
use App\Models\Invoice;
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\PhantomJS\Phantom;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\Pdf\PdfMaker;
use Illuminate\Support\Facades\Storage;
@@ -58,6 +60,10 @@ class GenerateDeliveryNote
$file_path = sprintf('%s%s_delivery_note.pdf', $this->invoice->client->invoice_filepath(), $this->invoice->number);
+ if (config('ninja.phantomjs_pdf_generation')) {
+ return (new Phantom)->generate($this->invoice->invitations->first());
+ }
+
$design = Design::find($design_id);
$html = new HtmlEngine($this->invoice->invitations->first());
@@ -86,7 +92,12 @@ class GenerateDeliveryNote
// Storage::makeDirectory($this->invoice->client->invoice_filepath(), 0775);
- $pdf = $this->makePdf(null, null, $maker->getCompiledHTML());
+ if(config('ninja.invoiceninja_hosted_pdf_generation')){
+ $pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
+ }
+ else {
+ $pdf = $this->makePdf(null, null, $maker->getCompiledHTML());
+ }
if (config('ninja.log_pdf_html')) {
info($maker->getCompiledHTML());
diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php
index 72e47ceecd49..6f056e7e900f 100644
--- a/app/Services/Invoice/InvoiceService.php
+++ b/app/Services/Invoice/InvoiceService.php
@@ -263,7 +263,7 @@ class InvoiceService
{
if ((int)$this->invoice->balance == 0) {
- InvoiceWorkflowSettings::dispatch($this->invoice);
+ InvoiceWorkflowSettings::dispatchNow($this->invoice);
$this->setStatus(Invoice::STATUS_PAID);
}
diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php
index c81b87bd434d..d2fc2eefed5c 100644
--- a/app/Services/Payment/UpdateInvoicePayment.php
+++ b/app/Services/Payment/UpdateInvoicePayment.php
@@ -12,6 +12,7 @@
namespace App\Services\Payment;
use App\Events\Invoice\InvoiceWasUpdated;
+use App\Jobs\Invoice\InvoiceWorkflowSettings;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\PaymentHash;
@@ -83,6 +84,8 @@ class UpdateInvoicePayment
->updateStatus()
->save();
+ InvoiceWorkflowSettings::dispatchNow($invoice);
+
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars()));
});
diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php
index 9932e4029cef..4e7dd9447d55 100644
--- a/app/Services/Subscription/SubscriptionService.php
+++ b/app/Services/Subscription/SubscriptionService.php
@@ -15,7 +15,9 @@ use App\DataMapper\InvoiceItem;
use App\Factory\InvoiceFactory;
use App\Factory\InvoiceToRecurringInvoiceFactory;
use App\Factory\RecurringInvoiceFactory;
+use App\Jobs\Util\SubscriptionWebhookHandler;
use App\Jobs\Util\SystemLogger;
+use App\Models\Client;
use App\Models\ClientContact;
use App\Models\ClientSubscription;
use App\Models\Invoice;
@@ -27,6 +29,7 @@ use App\Models\SystemLog;
use App\Repositories\InvoiceRepository;
use App\Repositories\RecurringInvoiceRepository;
use App\Repositories\SubscriptionRepository;
+use App\Utils\Ninja;
use App\Utils\Traits\CleanLineItems;
use App\Utils\Traits\MakesHash;
use GuzzleHttp\RequestOptions;
@@ -70,7 +73,16 @@ class SubscriptionService
->save();
//execute any webhooks
- $this->triggerWebhook();
+
+ $context = [
+ 'context' => 'recurring_purchase',
+ 'recurring_invoice' => $recurring_invoice->hashed_id,
+ 'invoice' => $this->encodePrimaryKey($payment_hash->fee_invoice_id),
+ 'client' => $recurring_invoice->client->hashed_id,
+ 'subscription' => $this->subscription->hashed_id,
+ ];
+
+ $this->triggerWebhook($context);
if(array_key_exists('post_purchase_url', $this->subscription->webhook_configuration) && strlen($this->subscription->webhook_configuration['post_purchase_url']) >=1)
return redirect($this->subscription->webhook_configuration['post_purchase_url']);
@@ -79,9 +91,17 @@ class SubscriptionService
}
else
{
+ $invoice = Invoice::find($payment_hash->fee_invoice_id);
+
+ $context = [
+ 'context' => 'single_purchase',
+ 'invoice' => $this->encodePrimaryKey($payment_hash->fee_invoice_id),
+ 'client' => $invoice->client->hashed_id,
+ 'subscription' => $this->subscription->hashed_id,
+ ];
//execute any webhooks
- $this->triggerWebhook();
+ $this->triggerWebhook($context);
if(array_key_exists('post_purchase_url', $this->subscription->webhook_configuration) && strlen($this->subscription->webhook_configuration['post_purchase_url']) >=1)
return redirect($this->subscription->webhook_configuration['post_purchase_url']);
@@ -124,11 +144,19 @@ class SubscriptionService
->start()
->save();
- //execute any webhooks
- $this->triggerWebhook();
+ $context = [
+ 'context' => 'trial',
+ 'recurring_invoice' => $recurring_invoice->hashed_id,
+ 'client' => $recurring_invoice->client->hashed_id,
+ 'subscription' => $this->subscription->hashed_id,
+ ];
- if(array_key_exists('post_purchase_url', $this->subscription->webhook_configuration) && strlen($this->subscription->webhook_configuration['post_purchase_url']) >=1)
- return redirect($this->subscription->webhook_configuration['post_purchase_url']);
+ //execute any webhooks
+ $this->triggerWebhook($context);
+
+ if(array_key_exists('return_url', $this->subscription->webhook_configuration) && strlen($this->subscription->webhook_configuration['return_url']) >=1){
+ return redirect($this->subscription->webhook_configuration['return_url']);
+ }
return redirect('/client/recurring_invoices/'.$recurring_invoice->hashed_id);
}
@@ -208,30 +236,45 @@ class SubscriptionService
// }
//@todo - need refactor
- public function triggerWebhook()
+ public function triggerWebhook($context)
{
- //hit the webhook to after a successful onboarding
- // $body = [
- // 'subscription' => $this->subscription,
- // 'client_subscription' => $this->client_subscription,
- // 'client' => $this->client_subscription->client->toArray(),
- // ];
+ $body = array_merge($context, [
+ 'company_key' => $this->subscription->company->company_key,
+ 'account_key' => $this->subscription->company->account->key,
+ 'db' => $this->subscription->company->db,
+ ]);
+
+ $headers = [
+ 'Content-Type' => 'application/json',
+ 'X-Requested-With' => 'XMLHttpRequest',
+ ];
- // $client = new \GuzzleHttp\Client(['headers' => $this->subscription->webhook_configuration->post_purchase_headers]);
+ $client = new \GuzzleHttp\Client(
+ [
+ 'headers' => $headers,
+ ]);
- // $response = $client->{$this->subscription->webhook_configuration->post_purchase_rest_method}($this->subscription->post_purchase_url,[
- // RequestOptions::JSON => ['body' => $body]
- // ]);
+ try {
+ $response = $client->{$this->subscription->webhook_configuration['post_purchase_rest_method']}($this->subscription->webhook_configuration['post_purchase_url'],[
+ RequestOptions::JSON => ['body' => $body], RequestOptions::ALLOW_REDIRECTS => false
+ ]);
+ }
+ catch(\Exception $e)
+ {
- // SystemLogger::dispatch(
- // $body,
- // SystemLog::CATEGORY_WEBHOOK,
- // SystemLog::EVENT_WEBHOOK_RESPONSE,
- // SystemLog::TYPE_WEBHOOK_RESPONSE,
- // $this->client_subscription->client,
- // );
+ }
+
+ $client = \App\Models\Client::find($this->decodePrimaryKey($body['client']));
+
+ SystemLogger::dispatch(
+ $body,
+ SystemLog::CATEGORY_WEBHOOK,
+ SystemLog::EVENT_WEBHOOK_RESPONSE,
+ SystemLog::TYPE_WEBHOOK_RESPONSE,
+ $client,
+ );
}
diff --git a/app/Transformers/SubscriptionTransformer.php b/app/Transformers/SubscriptionTransformer.php
index 5fd60c134297..8ad12f5334d0 100644
--- a/app/Transformers/SubscriptionTransformer.php
+++ b/app/Transformers/SubscriptionTransformer.php
@@ -65,6 +65,7 @@ class SubscriptionTransformer extends EntityTransformer
'created_at' => (int)$subscription->created_at,
'updated_at' => (int)$subscription->updated_at,
'archived_at' => (int)$subscription->deleted_at,
+ 'plan_map' => '', //@deprecated 03/04/2021
];
}
diff --git a/config/ninja.php b/config/ninja.php
index 0b385471f4f6..9f868a7a5b1d 100644
--- a/config/ninja.php
+++ b/config/ninja.php
@@ -14,7 +14,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', ''),
- 'app_version' => '5.1.33',
+ 'app_version' => '5.1.34',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),
@@ -142,7 +142,7 @@ return [
'expanded_logging' => env('EXPANDED_LOGGING', false),
'snappdf_chromium_path' => env('SNAPPDF_CHROMIUM_PATH', false),
'v4_migration_version' => '4.5.35',
- 'flutter_canvas_kit' => env('FLUTTER_CANVAS_KIT', 'selfhosted-html'),
+ 'flutter_renderer' => env('FLUTTER_RENDERER', 'selfhosted-html'),
'webcron_secret' => env('WEBCRON_SECRET', false),
'disable_auto_update' => env('DISABLE_AUTO_UPDATE', false),
'invoiceninja_hosted_pdf_generation' => env('NINJA_HOSTED_PDF', false),
diff --git a/database/migrations/2021_04_05_115345_add_trial_duration_to_accounts_table.php b/database/migrations/2021_04_05_115345_add_trial_duration_to_accounts_table.php
new file mode 100644
index 000000000000..bdee046183ca
--- /dev/null
+++ b/database/migrations/2021_04_05_115345_add_trial_duration_to_accounts_table.php
@@ -0,0 +1,30 @@
+unsignedInteger('trial_duration')->nullable();
+ });
+
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ }
+}
diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php
index dfd798e2c1ee..84eb079a0141 100644
--- a/resources/views/index/index.blade.php
+++ b/resources/views/index/index.blade.php
@@ -146,9 +146,9 @@
- @if(config('ninja.flutter_canvas_kit') == 'hosted')
+ @if(config('ninja.flutter_renderer') == 'hosted')
- @elseif(config('ninja.flutter_canvas_kit') == 'selfhosted-canvaskit')
+ @elseif(config('ninja.flutter_renderer') == 'selfhosted-canvaskit')
@else