From 378ac23b264c02481d15ece97a041520fc0814da Mon Sep 17 00:00:00 2001 From: Will Curry Date: Wed, 29 May 2024 12:03:10 +0100 Subject: [PATCH] Only set subscription start_time if passed (#640) --- src/Traits/PayPalAPI/Subscriptions/Helpers.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Traits/PayPalAPI/Subscriptions/Helpers.php b/src/Traits/PayPalAPI/Subscriptions/Helpers.php index ecba57c1..3bc60833 100644 --- a/src/Traits/PayPalAPI/Subscriptions/Helpers.php +++ b/src/Traits/PayPalAPI/Subscriptions/Helpers.php @@ -66,11 +66,8 @@ trait Helpers */ public function setupSubscription(string $customer_name, string $customer_email, string $start_date = '') { - $start_date = !empty($start_date) ? Carbon::parse($start_date)->toIso8601String() : Carbon::now()->toIso8601String(); - $body = [ 'plan_id' => $this->billing_plan['id'], - 'start_time' => $start_date, 'quantity' => 1, 'subscriber' => [ 'name' => [ @@ -80,6 +77,10 @@ public function setupSubscription(string $customer_name, string $customer_email, ], ]; + if (!empty($start_date)) { + $body['start_time'] = Carbon::parse($start_date)->toIso8601String(); + } + if ($this->has_setup_fee) { $body['plan'] = [ 'payment_preferences' => $this->payment_preferences,