diff --git a/app/Http/Requests/Subscription/StoreSubscriptionRequest.php b/app/Http/Requests/Subscription/StoreSubscriptionRequest.php index fe8de051fcd2..8f8df53f400c 100644 --- a/app/Http/Requests/Subscription/StoreSubscriptionRequest.php +++ b/app/Http/Requests/Subscription/StoreSubscriptionRequest.php @@ -53,7 +53,7 @@ class StoreSubscriptionRequest extends Request 'allow_plan_changes' => ['sometimes'], 'plan_map' => ['sometimes'], 'refund_period' => ['sometimes'], - 'webhook_configuration' => ['sometimes'], + 'webhook_configuration' => ['array'], 'name' => Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id) ]; } @@ -62,11 +62,11 @@ class StoreSubscriptionRequest extends Request { $input = $this->all(); - if(array_key_exists('webhook_configuration', $input) && (!is_object(json_decode($input['webhook_configuration'])))) - $input['webhook_configuration'] = new \stdClass; + // if(array_key_exists('webhook_configuration', $input) && (!is_object(json_decode($input['webhook_configuration'])))) + // $input['webhook_configuration'] = new \stdClass; - if(!array_key_exists('webhook_configuration', $input)) - $input['webhook_configuration'] = new \stdClass; + // if(!array_key_exists('webhook_configuration', $input)) + // $input['webhook_configuration'] = new \stdClass; $this->replace($input); } diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php index 2fb57e602878..3b7beb19d156 100644 --- a/app/Models/Subscription.php +++ b/app/Models/Subscription.php @@ -48,7 +48,7 @@ class Subscription extends BaseModel protected $casts = [ 'is_deleted' => 'boolean', 'plan_map' => 'object', - 'webhook_configuration' => 'object', + 'webhook_configuration' => 'array', 'updated_at' => 'timestamp', 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 5979fa33342b..31c6b91f5be4 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -103,8 +103,8 @@ class SubscriptionService //execute any webhooks $this->triggerWebhook(); - if(property_exists($this->subscription->webhook_configuration, 'post_purchase_url') && strlen($this->subscription->webhook_configuration->post_purchase_url) >=1) - return redirect($this->subscription->webhook_configuration->post_purchase_url); + 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']); return redirect('/client/recurring_invoices/'.$recurring_invoice->hashed_id); }