Skip to content

Commit

Permalink
Add authorisation id
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick477 committed Jun 13, 2019
1 parent 48be9f5 commit ee7c204
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/Action/CaptureAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ public function execute($request)
if ($this->mercanetBnpParibasBridge->isPostMethod()) {

$model['status'] = $this->mercanetBnpParibasBridge->paymentVerification() ?
PaymentInterface::STATE_COMPLETED : PaymentInterface::STATE_CANCELLED;
PaymentInterface::STATE_COMPLETED : PaymentInterface::STATE_CANCELLED
;

$model['authorisationId'] = $this->mercanetBnpParibasBridge->getAuthorisationId();

$request->setModel($model);

Expand Down
4 changes: 3 additions & 1 deletion src/Action/NotifyAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function execute($request)
/** @var PaymentInterface $payment */
$payment = $request->getFirstModel();

$payment->getDetails()['authorisationId'] = $this->mercanetBnpParibasBridge->getAuthorisationId();

Assert::isInstanceOf($payment, PaymentInterface::class);

$this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->apply(PaymentTransitions::TRANSITION_COMPLETE);
Expand Down Expand Up @@ -88,4 +90,4 @@ public function supports($request)
$request->getModel() instanceof \ArrayObject
;
}
}
}
14 changes: 11 additions & 3 deletions src/Bridge/MercanetBnpParibasBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ final class MercanetBnpParibasBridge implements MercanetBnpParibasBridgeInterfac
*/
private $environment;

/** @var Mercanet */
private $mercanet;

/**
* @param RequestStack $requestStack
*/
Expand All @@ -66,15 +69,20 @@ public function paymentVerification()
{
if ($this->isPostMethod()) {

$paymentResponse = new Mercanet($this->secretKey);
$paymentResponse->setResponse($_POST);
$this->mercanet = new Mercanet($this->secretKey);
$this->mercanet->setResponse($_POST);

return $paymentResponse->isValid();
return $this->mercanet->isValid();
}

return false;
}

public function getAuthorisationId()
{
return $this->mercanet->getAuthorisationId();
}

/**
* {@inheritDoc}
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Bridge/MercanetBnpParibasBridgeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function createMercanet($secretKey);
*/
public function paymentVerification();

public function getAuthorisationId();

/**
* @return bool
*/
Expand Down

0 comments on commit ee7c204

Please sign in to comment.