-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebaf6f2
commit 4f5bd4f
Showing
21 changed files
with
242 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
|
@@ -10,42 +12,31 @@ | |
|
||
namespace BitBag\MercanetBnpParibasPlugin\Action; | ||
|
||
use BitBag\MercanetBnpParibasPlugin\Legacy\SimplePayment; | ||
use BitBag\MercanetBnpParibasPlugin\Bridge\MercanetBnpParibasBridgeInterface; | ||
use BitBag\MercanetBnpParibasPlugin\Legacy\SimplePayment; | ||
use Payum\Core\Action\ActionInterface; | ||
use Payum\Core\ApiAwareInterface; | ||
use Payum\Core\Bridge\Spl\ArrayObject; | ||
use Payum\Core\Exception\RequestNotSupportedException; | ||
use Payum\Core\Exception\UnsupportedApiException; | ||
use Payum\Core\GatewayAwareTrait; | ||
use Payum\Core\Payum; | ||
use Payum\Core\Request\Capture; | ||
use Payum\Core\Security\TokenInterface; | ||
use Sylius\Component\Core\Model\PaymentInterface; | ||
use Sylius\Component\Order\Model\OrderInterface; | ||
use Webmozart\Assert\Assert; | ||
use Payum\Core\Payum; | ||
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
final class CaptureAction implements ActionInterface, ApiAwareInterface | ||
{ | ||
use GatewayAwareTrait; | ||
|
||
/** | ||
* @var Payum | ||
*/ | ||
/** @var Payum */ | ||
private $payum; | ||
|
||
/** | ||
* @var MercanetBnpParibasBridgeInterface | ||
*/ | ||
/** @var MercanetBnpParibasBridgeInterface */ | ||
private $mercanetBnpParibasBridge; | ||
|
||
/** | ||
* @param Payum $payum | ||
*/ | ||
public function __construct(Payum $payum) | ||
{ | ||
$this->payum = $payum; | ||
|
@@ -61,7 +52,7 @@ public function setApi($mercanetBnpParibasBridge): void | |
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @inheritDoc | ||
* | ||
* @param Capture $request | ||
*/ | ||
|
@@ -78,12 +69,10 @@ public function execute($request): void | |
/** @var TokenInterface $token */ | ||
$token = $request->getToken(); | ||
|
||
$transactionReference = isset($model['transactionReference']) ? $model['transactionReference'] : null; | ||
$transactionReference = $model['transactionReference'] ?? null; | ||
|
||
if ($transactionReference !== null) { | ||
|
||
if ($this->mercanetBnpParibasBridge->isPostMethod()) { | ||
|
||
$model['status'] = $this->mercanetBnpParibasBridge->paymentVerification() ? | ||
PaymentInterface::STATE_COMPLETED : PaymentInterface::STATE_CANCELLED | ||
; | ||
|
@@ -96,7 +85,6 @@ public function execute($request): void | |
} | ||
|
||
if ($model['status'] === PaymentInterface::STATE_COMPLETED) { | ||
|
||
return; | ||
} | ||
} | ||
|
@@ -121,7 +109,7 @@ public function execute($request): void | |
/** @var OrderInterface $order */ | ||
$order = $payment->getOrder(); | ||
|
||
$transactionReference = "MercanetWS" . uniqid() . "OR" . $order->getNumber(); | ||
$transactionReference = 'MercanetWS' . uniqid() . 'OR' . $order->getNumber(); | ||
|
||
$model['transactionReference'] = $transactionReference; | ||
|
||
|
@@ -134,7 +122,7 @@ public function execute($request): void | |
$targetUrl, | ||
$currencyCode, | ||
$transactionReference, | ||
$automaticResponseUrl | ||
$automaticResponseUrl, | ||
); | ||
|
||
$request->setModel($model); | ||
|
@@ -151,12 +139,12 @@ private function createNotifyToken($gatewayName, $model) | |
{ | ||
return $this->payum->getTokenFactory()->createNotifyToken( | ||
$gatewayName, | ||
$model | ||
$model, | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @inheritDoc | ||
*/ | ||
public function supports($request) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
|
@@ -10,23 +12,19 @@ | |
|
||
namespace BitBag\MercanetBnpParibasPlugin\Action; | ||
|
||
use Payum\Core\GatewayAwareInterface; | ||
use Payum\Core\GatewayAwareTrait; | ||
use Payum\Core\Action\ActionInterface; | ||
use Payum\Core\Exception\RequestNotSupportedException; | ||
use Payum\Core\GatewayAwareInterface; | ||
use Payum\Core\GatewayAwareTrait; | ||
use Payum\Core\Model\PaymentInterface; | ||
use Payum\Core\Request\Convert; | ||
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
final class ConvertPaymentAction implements ActionInterface, GatewayAwareInterface | ||
{ | ||
use GatewayAwareTrait; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @inheritDoc | ||
* | ||
* @param Convert $request | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
|
@@ -16,15 +18,12 @@ | |
use Payum\Core\Exception\RequestNotSupportedException; | ||
use Payum\Core\Exception\UnsupportedApiException; | ||
use Payum\Core\GatewayAwareTrait; | ||
use Sylius\Component\Core\Model\PaymentInterface; | ||
use Payum\Core\Request\Notify; | ||
use SM\Factory\FactoryInterface; | ||
use Sylius\Component\Core\Model\PaymentInterface; | ||
use Sylius\Component\Payment\PaymentTransitions; | ||
use Webmozart\Assert\Assert; | ||
use SM\Factory\FactoryInterface; | ||
|
||
/** | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
final class NotifyAction implements ActionInterface, ApiAwareInterface | ||
{ | ||
use GatewayAwareTrait; | ||
|
@@ -38,13 +37,14 @@ public function __construct(FactoryInterface $stateMachineFactory) | |
$this->stateMachineFactory = $stateMachineFactory; | ||
} | ||
|
||
/** | ||
* @param $request Notify | ||
*/ | ||
public function execute($request): void | ||
{ | ||
/** @var $request Notify */ | ||
RequestNotSupportedException::assertSupports($this, $request); | ||
|
||
if ($this->mercanetBnpParibasBridge->paymentVerification()) { | ||
|
||
/** @var PaymentInterface $payment */ | ||
$payment = $request->getFirstModel(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
|
@@ -11,32 +13,24 @@ | |
namespace BitBag\MercanetBnpParibasPlugin\Action; | ||
|
||
use Payum\Core\Action\ActionInterface; | ||
use Payum\Core\Request\GetStatusInterface; | ||
use Payum\Core\Bridge\Spl\ArrayObject; | ||
use Payum\Core\Exception\RequestNotSupportedException; | ||
use Payum\Core\Request\GetStatusInterface; | ||
use Sylius\Component\Core\Model\PaymentInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
final class StatusAction implements ActionInterface | ||
{ | ||
|
||
private RequestStack $requestStack; | ||
|
||
/** | ||
* @param RequestStack $requestStack | ||
*/ | ||
public function __construct(RequestStack $requestStack) | ||
{ | ||
$this->requestStack = $requestStack; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @inheritDoc | ||
* | ||
* @param GetStatusInterface $request | ||
*/ | ||
|
@@ -49,25 +43,22 @@ public function execute($request): void | |
/** @var Request $requestCurrent */ | ||
$requestCurrent = $this->requestStack->getCurrentRequest(); | ||
|
||
$transactionReference = isset($model['transactionReference']) ? $model['transactionReference'] : null; | ||
$transactionReference = $model['transactionReference'] ?? null; | ||
|
||
$status = isset($model['status']) ? $model['status'] : null; | ||
$status = $model['status'] ?? null; | ||
|
||
if ((null === $transactionReference) && !$requestCurrent->isMethod('POST')) { | ||
|
||
$request->markNew(); | ||
|
||
return; | ||
} | ||
|
||
if ($status === PaymentInterface::STATE_CANCELLED) { | ||
|
||
$request->markCanceled(); | ||
|
||
return; | ||
} | ||
if ($status === PaymentInterface::STATE_COMPLETED) { | ||
|
||
$request->markCaptured(); | ||
|
||
return; | ||
|
@@ -77,7 +68,7 @@ public function execute($request): void | |
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @inheritDoc | ||
*/ | ||
public function supports($request) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
|
@@ -13,10 +15,7 @@ | |
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
*/ | ||
final class BitBagMercanetBnpParibasPlugin extends Bundle | ||
{ | ||
use SyliusPluginTrait; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
|
@@ -11,16 +13,12 @@ | |
namespace BitBag\MercanetBnpParibasPlugin\Bridge; | ||
|
||
use BitBag\MercanetBnpParibasPlugin\Legacy\Mercanet; | ||
use BitBag\MercanetBnpParibasPlugin\Legacy\ShaComposer; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use BitBag\MercanetBnpParibasPlugin\Legacy\ShaComposer; | ||
|
||
/** | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
final class MercanetBnpParibasBridge implements MercanetBnpParibasBridgeInterface | ||
{ | ||
|
||
private RequestStack $requestStack; | ||
|
||
/** @phpstan-ignore-next-line We should not change our business logic now*/ | ||
|
@@ -48,7 +46,6 @@ public function createMercanet(ShaComposer $secretKey): Mercanet | |
public function paymentVerification(): bool | ||
{ | ||
if ($this->isPostMethod()) { | ||
|
||
$this->mercanet = new Mercanet($this->secretKey); | ||
$this->mercanet->setResponse($_POST); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
|
@@ -13,9 +15,6 @@ | |
use BitBag\MercanetBnpParibasPlugin\Legacy\Mercanet; | ||
use BitBag\MercanetBnpParibasPlugin\Legacy\ShaComposer; | ||
|
||
/** | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
interface MercanetBnpParibasBridgeInterface | ||
{ | ||
/** @phpstan-ignore-next-line We should not change our business logic now*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
|
@@ -15,13 +17,10 @@ | |
use Symfony\Component\DependencyInjection\Extension\Extension; | ||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; | ||
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
*/ | ||
final class BitBagMercanetBnpParibasExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* @inheritdoc | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
|
Oops, something went wrong.