Skip to content

Commit

Permalink
Only set subscription start_time if passed (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
willcurry authored May 29, 2024
1 parent 4146c7f commit 378ac23
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Traits/PayPalAPI/Subscriptions/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand All @@ -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,
Expand Down

0 comments on commit 378ac23

Please sign in to comment.