Skip to content

Commit

Permalink
Pass payment_behavior from Subscription to SubscriptionItem
Browse files Browse the repository at this point in the history
  • Loading branch information
skeemer committed Feb 4, 2024
1 parent 7e3de19 commit 09e1b19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/Concerns/InteractsWithPaymentBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,17 @@ public function paymentBehavior()
{
return $this->paymentBehavior;
}

/**
* Set the payment behavior for any subscription updates.
*
* @param string $paymentBehavior
* @return $this
*/
public function setPaymentBehavior($paymentBehavior)
{
$this->paymentBehavior = $paymentBehavior;

return $this;
}
}
15 changes: 12 additions & 3 deletions src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,10 @@ public function incrementQuantity($count = 1, $price = null)
$this->guardAgainstIncomplete();

if ($price) {
$this->findItemOrFail($price)->setProrationBehavior($this->prorationBehavior)->incrementQuantity($count);
$this->findItemOrFail($price)
->setPaymentBehavior($this->paymentBehavior)
->setProrationBehavior($this->prorationBehavior)
->incrementQuantity($count);

return $this->refresh();
}
Expand Down Expand Up @@ -478,7 +481,10 @@ public function decrementQuantity($count = 1, $price = null)
$this->guardAgainstIncomplete();

if ($price) {
$this->findItemOrFail($price)->setProrationBehavior($this->prorationBehavior)->decrementQuantity($count);
$this->findItemOrFail($price)
->setPaymentBehavior($this->paymentBehavior)
->setProrationBehavior($this->prorationBehavior)
->decrementQuantity($count);

return $this->refresh();
}
Expand All @@ -502,7 +508,10 @@ public function updateQuantity($quantity, $price = null)
$this->guardAgainstIncomplete();

if ($price) {
$this->findItemOrFail($price)->setProrationBehavior($this->prorationBehavior)->updateQuantity($quantity);
$this->findItemOrFail($price)
->setPaymentBehavior($this->paymentBehavior)
->setProrationBehavior($this->prorationBehavior)
->updateQuantity($quantity);

return $this->refresh();
}
Expand Down

0 comments on commit 09e1b19

Please sign in to comment.