diff --git a/src/Concerns/HandlesPaymentFailures.php b/src/Concerns/HandlesPaymentFailures.php index c364bd9c..4618f633 100644 --- a/src/Concerns/HandlesPaymentFailures.php +++ b/src/Concerns/HandlesPaymentFailures.php @@ -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. * @@ -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) { @@ -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. *