Skip to content

Commit

Permalink
- Bugfix: Renamed PaymentFailure exception to PaymentFailed.
Browse files Browse the repository at this point in the history
- Added PaymentFailed::requiresConfirmation exception state.
  • Loading branch information
davidrushton committed Oct 1, 2019
1 parent d987181 commit a93d1cb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 17 additions & 3 deletions src/Exceptions/PaymentFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -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) {
Expand Down

0 comments on commit a93d1cb

Please sign in to comment.