-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PAYOSWXP-158: Hide PayPal v1 if v2 is active
- Loading branch information
1 parent
ca924bf
commit c2fd9b8
Showing
4 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/Components/PaymentFilter/PaypalPaymentMethodFilter.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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PayonePayment\Components\PaymentFilter; | ||
|
||
use PayonePayment\Components\PaymentFilter\Exception\PaymentMethodNotAllowedException; | ||
use PayonePayment\PaymentMethod\PayonePaypal; | ||
use PayonePayment\PaymentMethod\PayonePaypalV2; | ||
use Shopware\Core\Checkout\Payment\PaymentMethodCollection; | ||
use Shopware\Core\Checkout\Payment\PaymentMethodEntity; | ||
|
||
class PaypalPaymentMethodFilter extends DefaultPaymentFilterService | ||
{ | ||
protected function additionalChecks(PaymentMethodCollection $methodCollection, PaymentFilterContext $filterContext): void | ||
{ | ||
$paypalV1 = $methodCollection->get(PayonePaypal::UUID); | ||
$paypalV2 = $methodCollection->get(PayonePaypalV2::UUID); | ||
|
||
if ($paypalV1 instanceof PaymentMethodEntity && $paypalV2 instanceof PaymentMethodEntity) { | ||
throw new PaymentMethodNotAllowedException('PayPal: PayPal v1 is not allowed if v2 is active.'); | ||
} | ||
} | ||
} |
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