From c24b18141b62e885d913e3f5794d0fa34312fecd Mon Sep 17 00:00:00 2001 From: k15 Date: Fri, 23 Feb 2024 10:11:48 +0700 Subject: [PATCH] fix : added a condition whether create billing from subscription helper was successful or not. --- src/Traits/PayPalAPI/Subscriptions/Helpers.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Traits/PayPalAPI/Subscriptions/Helpers.php b/src/Traits/PayPalAPI/Subscriptions/Helpers.php index 0b5333f9..4cd49eb0 100644 --- a/src/Traits/PayPalAPI/Subscriptions/Helpers.php +++ b/src/Traits/PayPalAPI/Subscriptions/Helpers.php @@ -398,7 +398,11 @@ protected function addBillingPlan(string $name, string $description, array $bill ], ]; - $this->billing_plan = $this->createPlan($plan_params, $request_id); + $billingPlan = $this->createPlan($plan_params, $request_id); + if ($error = data_get($billingPlan, 'error', false)) { + throw new \RuntimeException(data_get($error, 'details.0.description', 'Failed to add billing plan')); + } + $this->billing_plan = $billingPlan; } /**