From 55fec84e1de5c680def3b713eff14155fd0a74fe Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 18 Jan 2023 13:24:08 +1100 Subject: [PATCH] Fixes for subscription cron where URL/REST method is not set --- app/Jobs/Cron/SubscriptionCron.php | 2 ++ app/Utils/Traits/SubscriptionHooker.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/app/Jobs/Cron/SubscriptionCron.php b/app/Jobs/Cron/SubscriptionCron.php index 1242a63cbc08..beee6f82d7f2 100644 --- a/app/Jobs/Cron/SubscriptionCron.php +++ b/app/Jobs/Cron/SubscriptionCron.php @@ -45,6 +45,7 @@ class SubscriptionCron $invoices = Invoice::where('is_deleted', 0) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('balance', '>', 0) + ->where('is_proforma',0) ->whereDate('due_date', '<=', now()->addDay()->startOfDay()) ->whereNull('deleted_at') ->whereNotNull('subscription_id') @@ -74,6 +75,7 @@ class SubscriptionCron $invoices = Invoice::where('is_deleted', 0) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('balance', '>', 0) + ->where('is_proforma',0) ->whereDate('due_date', '<=', now()->addDay()->startOfDay()) ->whereNull('deleted_at') ->whereNotNull('subscription_id') diff --git a/app/Utils/Traits/SubscriptionHooker.php b/app/Utils/Traits/SubscriptionHooker.php index 52b05fbb1e48..e23fa58a4eff 100644 --- a/app/Utils/Traits/SubscriptionHooker.php +++ b/app/Utils/Traits/SubscriptionHooker.php @@ -27,6 +27,9 @@ trait SubscriptionHooker 'X-Requested-With' => 'XMLHttpRequest', ]; + if(!isset($subscription->webhook_configuration['post_purchase_url']) && !isset($subscription->webhook_configuration['post_purchase_rest_method'])) + return; + if (count($subscription->webhook_configuration['post_purchase_headers']) >= 1) { $headers = array_merge($headers, $subscription->webhook_configuration['post_purchase_headers']); }