From a93d1cbf369ede7d866f5960625a586b19a5cce4 Mon Sep 17 00:00:00 2001 From: David Rushton Date: Tue, 1 Oct 2019 15:59:06 +0100 Subject: [PATCH] - Bugfix: Renamed PaymentFailure exception to PaymentFailed. - Added PaymentFailed::requiresConfirmation exception state. --- README.md | 6 ++++++ src/Exceptions/PaymentFailed.php | 20 +++++++++++++++++--- src/Payment.php | 8 ++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3468a95..3fafb89 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,12 @@ try { } ``` +## Changelog + +#### v1.1.0 +- Bugfix: Renamed PaymentFailure exception to PaymentFailed. +- Added PaymentFailed::requiresConfirmation exception state. + ## Author [Papertank Limited](http://papertank.com) diff --git a/src/Exceptions/PaymentFailed.php b/src/Exceptions/PaymentFailed.php index e9f441a..6524c7c 100644 --- a/src/Exceptions/PaymentFailed.php +++ b/src/Exceptions/PaymentFailed.php @@ -4,10 +4,10 @@ use Origami\Stripe\Payment; -class PaymentFailure extends IncompletePayment +class PaymentFailed extends IncompletePayment { /** - * Create a new PaymentFailure instance. + * Create a new PaymentFailed instance. * * @param \Origami\Stripe\Payment $payment * @return self @@ -21,7 +21,21 @@ public static function invalidPaymentMethod(Payment $payment) } /** - * Create a new PaymentFailure instance. + * Create a new PaymentFailed instance. + * + * @param \Origami\Stripe\Payment $payment + * @return self + */ + public static function requiresConfirmation(Payment $payment) + { + return new self( + $payment, + 'The payment attempt failed and requires additional confirmation to re-attempt.' + ); + } + + /** + * Create a new PaymentFailed instance. * * @param \Origami\Stripe\Payment $payment * @return self diff --git a/src/Payment.php b/src/Payment.php index 40dd458..a28c4a2 100644 --- a/src/Payment.php +++ b/src/Payment.php @@ -5,7 +5,7 @@ use Money\Money; use Money\Currency; use Stripe\PaymentIntent; -use Origami\Stripe\Exceptions\PaymentFailure; +use Origami\Stripe\Exceptions\PaymentFailed; use Origami\Stripe\Exceptions\PaymentActionRequired; class Payment @@ -179,12 +179,12 @@ public function isSuccessful() * @return void * * @throws \Origami\Stripe\Exceptions\PaymentActionRequired - * @throws \Origami\Stripe\Exceptions\PaymentFailure + * @throws \Origami\Stripe\Exceptions\PaymentFailed */ public function validate() { if ($this->requiresPaymentMethod()) { - throw PaymentFailure::invalidPaymentMethod($this); + throw PaymentFailed::invalidPaymentMethod($this); } elseif ($this->requiresAction()) { throw PaymentActionRequired::incomplete($this); } @@ -200,7 +200,7 @@ public function confirm($params = null, $options = null) public function capture(Money $amount = null, array $params = [], $options = null) { if (!$this->hasStatus('requires_capture')) { - throw PaymentFailure::unableToCapture($this); + throw PaymentFailed::unableToCapture($this); } if (!$amount) {