-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2111 from dpfaffenbauer/issue/2107
[Checkout] introduce Payment Provider Validator to check if the selected one is still valid
- Loading branch information
Showing
6 changed files
with
95 additions
and
10 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
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
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
8 changes: 0 additions & 8 deletions
8
src/CoreShop/Bundle/PaymentBundle/Resources/config/services/resolver.yml
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/CoreShop/Component/Payment/Validator/PaymentProviderValidator.php
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* CoreShop | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - CoreShop Commercial License (CCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org) | ||
* @license https://www.coreshop.org/license GPLv3 and CCL | ||
* | ||
*/ | ||
|
||
namespace CoreShop\Component\Payment\Validator; | ||
|
||
use CoreShop\Component\Payment\Model\PaymentProviderInterface; | ||
use CoreShop\Component\Payment\Resolver\PaymentProviderResolverInterface; | ||
use CoreShop\Component\Resource\Model\ResourceInterface; | ||
|
||
class PaymentProviderValidator implements PaymentProviderValidatorInterface | ||
{ | ||
public function __construct(protected PaymentProviderResolverInterface $paymentProviderResolver) | ||
{ | ||
} | ||
|
||
public function isPaymentProviderValid( | ||
PaymentProviderInterface $paymentProvider, | ||
ResourceInterface $subject = null | ||
): bool { | ||
$validProviders = $this->paymentProviderResolver->resolvePaymentProviders($subject); | ||
|
||
return in_array( | ||
$paymentProvider->getId(), | ||
array_map(static function (PaymentProviderInterface $paymentProvider) { | ||
return $paymentProvider->getId(); | ||
}, $validProviders), | ||
true | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/CoreShop/Component/Payment/Validator/PaymentProviderValidatorInterface.php
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* CoreShop | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - CoreShop Commercial License (CCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org) | ||
* @license https://www.coreshop.org/license GPLv3 and CCL | ||
* | ||
*/ | ||
|
||
namespace CoreShop\Component\Payment\Validator; | ||
|
||
use CoreShop\Component\Payment\Model\PaymentProviderInterface; | ||
use CoreShop\Component\Resource\Model\ResourceInterface; | ||
|
||
interface PaymentProviderValidatorInterface | ||
{ | ||
public function isPaymentProviderValid( | ||
PaymentProviderInterface $paymentProvider, | ||
ResourceInterface $subject = null | ||
): bool; | ||
} |