Skip to content

Commit

Permalink
[stripe] error not detected in some cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Sep 15, 2016
1 parent 764d427 commit 1ed05ec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Action/StatusAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public function execute($request)

$model = ArrayObject::ensureArrayObject($request->getModel());

if ($model['error']) {
$request->markFailed();

return;
}

if (false == $model['status'] && false == $model['card']) {
$request->markNew();

Expand Down
26 changes: 23 additions & 3 deletions Tests/Action/StatusActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

class StatusActionTest extends GenericActionTest
{
protected $requestClass = 'Payum\Core\Request\GetHumanStatus';
protected $requestClass = GetHumanStatus::class;

protected $actionClass = 'Payum\Stripe\Action\StatusAction';
protected $actionClass = StatusAction::class;

/**
* @test
Expand All @@ -19,13 +19,33 @@ public function shouldMarkNewIfDetailsEmpty()
{
$action = new StatusAction();

$model = array();
$model = [];

$action->execute($status = new GetHumanStatus($model));

$this->assertTrue($status->isNew());
}

/**
* @test
*/
public function shouldMarkFailedIfDetailsHasErrorSet()
{
$action = new StatusAction();

$model = [
'error' => [
'type' => 'invalid_request_error',
'message' => 'Amount must be at least 50 cents',
'param' => 'amount',
],
];

$action->execute($status = new GetHumanStatus($model));

$this->assertTrue($status->isFailed());
}

/**
* @test
*/
Expand Down

0 comments on commit 1ed05ec

Please sign in to comment.