-
-
Notifications
You must be signed in to change notification settings - Fork 155
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 #2614 from dpfaffenbauer/issue/2561
[PaymentProvider] fix payment provider rule action and add payment provider rule condition
- Loading branch information
Showing
10 changed files
with
135 additions
and
22 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
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
53 changes: 53 additions & 0 deletions
53
...mentBundle/Resources/public/pimcore/js/paymentproviderrule/actions/paymentProviderRule.js
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,53 @@ | ||
/* | ||
* CoreShop. | ||
* | ||
* This source file is subject to the GNU General Public License version 3 (GPLv3) | ||
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt | ||
* files that are distributed with this source code. | ||
* | ||
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org) | ||
* @license https://www.coreshop.org/license GPLv3 and CCL | ||
* | ||
*/ | ||
|
||
pimcore.registerNS('coreshop.paymentproviderrule.actions.paymentProviderRule'); | ||
|
||
coreshop.paymentproviderrule.actions.paymentProviderRule = Class.create(coreshop.rules.conditions.abstract, { | ||
type: 'paymentProviderRule', | ||
|
||
getForm: function () { | ||
var me = this; | ||
|
||
var rule = { | ||
xtype: 'combo', | ||
fieldLabel: t('coreshop_action_paymentProviderRule'), | ||
typeAhead: true, | ||
listWidth: 100, | ||
width: 500, | ||
store: { | ||
type: 'coreshop_payment_provider_rules' | ||
}, | ||
displayField: 'name', | ||
valueField: 'id', | ||
forceSelection: true, | ||
multiselect: true, | ||
triggerAction: 'all', | ||
name: 'paymentProviderRule', | ||
maxHeight: 400, | ||
delimiter: false, | ||
value: me.data.paymentProviderRule | ||
}; | ||
|
||
if (this.data && this.data.paymentProviderRule) { | ||
rule.value = this.data.paymentProviderRule; | ||
} | ||
|
||
this.form = new Ext.form.Panel({ | ||
items: [ | ||
rule | ||
] | ||
}); | ||
|
||
return this.form; | ||
} | ||
}); |
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
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
49 changes: 49 additions & 0 deletions
49
src/CoreShop/Component/Payment/Rule/Condition/PaymentProviderRuleConditionChecker.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,49 @@ | ||
<?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\Rule\Condition; | ||
|
||
use CoreShop\Component\Payment\Model\PayableInterface; | ||
use CoreShop\Component\Payment\Model\PaymentProviderInterface; | ||
use CoreShop\Component\Payment\Model\PaymentProviderRuleInterface; | ||
use CoreShop\Component\Resource\Repository\RepositoryInterface; | ||
use CoreShop\Component\Rule\Condition\RuleValidationProcessorInterface; | ||
|
||
class PaymentProviderRuleConditionChecker extends AbstractConditionChecker | ||
{ | ||
public function __construct( | ||
protected RuleValidationProcessorInterface $ruleValidationProcessor, | ||
protected RepositoryInterface $paymentProviderRuleRepository, | ||
) { | ||
} | ||
|
||
public function isPaymentProviderRuleValid( | ||
PaymentProviderInterface $paymentProvider, | ||
PayableInterface $payable, | ||
array $configuration | ||
): bool { | ||
$paymentProviderRuleId = $configuration['paymentProviderRule']; | ||
$paymentProviderRule = $this->paymentProviderRuleRepository->find($paymentProviderRuleId); | ||
|
||
if ($paymentProviderRule instanceof PaymentProviderRuleInterface) { | ||
return $this->ruleValidationProcessor->isValid($paymentProvider, $paymentProviderRule, ['payable' => $payable]); | ||
} | ||
|
||
return false; | ||
} | ||
} |