-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[12.x] Implement new proration and pending updates (#949)
Implement new proration and pending updates
- Loading branch information
1 parent
d7c2345
commit 7018689
Showing
9 changed files
with
325 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Laravel\Cashier\Concerns; | ||
|
||
trait InteractsWithPaymentBehavior | ||
{ | ||
/** | ||
* Set the payment behavior for any subscription updates. | ||
* | ||
* @var string | ||
*/ | ||
protected $paymentBehavior = 'allow_incomplete'; | ||
|
||
/** | ||
* Allow subscription changes even if payment fails. | ||
* | ||
* @return $this | ||
*/ | ||
public function allowPaymentFailures() | ||
{ | ||
$this->paymentBehavior = 'allow_incomplete'; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set any subscription change as pending until payment is successful. | ||
* | ||
* @return $this | ||
*/ | ||
public function pendingIfPaymentFails() | ||
{ | ||
$this->paymentBehavior = 'pending_if_incomplete'; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Prevent any subscription change if payment is unsuccessful. | ||
* | ||
* @return $this | ||
*/ | ||
public function errorIfPaymentFails() | ||
{ | ||
$this->paymentBehavior = 'error_if_incomplete'; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Determine the payment behavior when updating the subscription. | ||
* | ||
* @return string | ||
*/ | ||
public function paymentBehavior() | ||
{ | ||
return $this->paymentBehavior; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.