Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/Payum/Payum
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Mar 25, 2016
2 parents 82b70d6 + ea912c8 commit ea73ea8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
12 changes: 5 additions & 7 deletions Action/CaptureAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public function execute($request)

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

if ($model['status']) {
return;
}

if ($model['customer']) {
} else {
if (is_array($model['card'])) {
return;
}

if (false == $model['card']) {
$obtainToken = new ObtainToken($request->getToken());
$obtainToken->setModel($model);
Expand All @@ -36,9 +36,7 @@ public function execute($request)

}

if (false == $model['status']) {
$this->gateway->execute(new CreateCharge($model));
}
$this->gateway->execute(new CreateCharge($model));
}

/**
Expand Down
35 changes: 31 additions & 4 deletions Tests/Action/CaptureActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function shouldBeSubClassOfGatewayAwareAction()
/**
* @test
*/
public function shouldDoNothingIfModelHasAlreadyUsedToken()
public function shouldDoNothingIfPaymentHasStatus()
{
$model = array(
'card' => array('foo', 'bar'),
);
$model = [
'status' => Constants::STATUS_SUCCEEDED,
];

$gatewayMock = $this->createGatewayMock();
$gatewayMock
Expand Down Expand Up @@ -157,6 +157,33 @@ public function shouldSubExecuteCreateChargeIfCustomerSet()
$action->execute(new Capture($model));
}

/**
* @test
*/
public function shouldSubExecuteCreateChargeIfCreditCardSetExplisitly()
{
$model = [
'card' => [
'number' => '4111111111111111',
'exp_month' => '10',
'exp_year' => '20',
'cvc' => '123',
],
];

$gatewayMock = $this->createGatewayMock();
$gatewayMock
->expects($this->once())
->method('execute')
->with($this->isInstanceOf(CreateCharge::class))
;

$action = new CaptureAction();
$action->setGateway($gatewayMock);

$action->execute(new Capture($model));
}

/**
* @test
*/
Expand Down

0 comments on commit ea73ea8

Please sign in to comment.