Skip to content

Commit

Permalink
[14.x] Add ability to ignore incomplete payments (#1524)
Browse files Browse the repository at this point in the history
* Ignore incomplete payments

* Update HandlesPaymentFailures.php

---------

Co-authored-by: Taylor Otwell <taylorotwell@gmail.com>
  • Loading branch information
driesvints and taylorotwell authored Apr 7, 2023
1 parent b14c8db commit 325c8f0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Concerns/HandlesPaymentFailures.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

trait HandlesPaymentFailures
{
/**
* Indicates if incomplete payments should be confirmed automatically.
*
* @var bool
*/
protected $confirmIncompletePayment = true;

/**
* The options to be used when confirming a payment intent.
*
Expand All @@ -30,7 +37,7 @@ trait HandlesPaymentFailures
*/
public function handlePaymentFailure(Subscription $subscription, $paymentMethod = null)
{
if ($subscription->hasIncompletePayment()) {
if ($this->confirmIncompletePayment && $subscription->hasIncompletePayment()) {
try {
$subscription->latestPayment()->validate();
} catch (IncompletePayment $e) {
Expand Down Expand Up @@ -69,9 +76,22 @@ public function handlePaymentFailure(Subscription $subscription, $paymentMethod
}
}

$this->confirmIncompletePayment = true;
$this->paymentConfirmationOptions = [];
}

/**
* Prevent automatic confirmation of incomplete payments.
*
* @return $this
*/
public function ignoreIncompletePayments()
{
$this->confirmIncompletePayment = false;

return $this;
}

/**
* Specify the options to be used when confirming a payment intent.
*
Expand Down

0 comments on commit 325c8f0

Please sign in to comment.