-
Notifications
You must be signed in to change notification settings - Fork 0
Introduce placeholder express methods #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maxparkergene
wants to merge
6
commits into
develop
Choose a base branch
from
feature/cls-placeholder-express
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
41d9545
Introduce placeholder express methods
maxparkergene 03877bc
Added Adyen requirement
maxparkergene ba2d42a
Creation of checks to prevent calling Adyen API multiple times
maxparkergene 5ef0b29
Fix issue with failing phpstan tests
maxparkergene 2ebc258
Fix issue with version of Magento Coding Standards
maxparkergene 4d50cce
Update to use Module\Manager to determine Adyen_ExpressCheckout enabl…
maxparkergene File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 +1,5 @@ | ||
| module.exports = { | ||
| extends: './vendor/magento/magento-coding-standard/eslint/.eslintrc', | ||
| ignorePatterns: ['view/frontend/web/js/checkout'], | ||
| root: true | ||
| }; |
This file contains hidden or 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,54 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
| namespace BlueFinch\CheckoutAdyen\Plugin\CustomerData; | ||
|
|
||
| use Adyen\Payment\Api\AdyenPaymentMethodManagementInterface; | ||
| use Magento\Checkout\CustomerData\Cart as Subject; | ||
| use Magento\Checkout\Model\Session; | ||
| use Magento\Framework\Module\Manager; | ||
|
|
||
| class AddAdyenExpressMethods | ||
| { | ||
| public const PAYMENT_METHODS_KEY = 'bluefinch_adyen_payment_methods'; | ||
|
|
||
| /** | ||
| * Cart constructor | ||
| * | ||
| * @param AdyenPaymentMethodManagementInterface $adyenPaymentMethodManagement | ||
| * @param Session $checkoutSession | ||
| * @param Manager $moduleManager | ||
| */ | ||
| public function __construct( | ||
| private readonly AdyenPaymentMethodManagementInterface $adyenPaymentMethodManagement, | ||
| private readonly Session $checkoutSession, | ||
| private readonly Manager $moduleManager | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * Intercept getSectionData and Adyen Payment methods. | ||
| * | ||
| * @param Subject $subject | ||
| * @param array $result | ||
| * @return array | ||
| */ | ||
| public function afterGetSectionData( | ||
| Subject $subject, | ||
| array $result | ||
| ): array { | ||
|
|
||
| // Only run if no Adyen Express methods are enabled otherwise we'd be duplicating the Adyen API request. | ||
| if (!$this->moduleManager->isEnabled('Adyen_ExpressCheckout')) { | ||
| $quoteId = (string) $this->checkoutSession->getQuoteId(); | ||
| $paymentMethods = $quoteId ? | ||
| json_decode( | ||
| $this->adyenPaymentMethodManagement->getPaymentMethods($quoteId), | ||
| true | ||
| ) : []; | ||
| $result[self::PAYMENT_METHODS_KEY] = $paymentMethods; | ||
| } | ||
|
|
||
| return $result; | ||
| } | ||
| } |
This file contains hidden or 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,29 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
| namespace BlueFinch\CheckoutAdyen\Plugin\CustomerData; | ||
|
|
||
| use BlueFinch\CheckoutAdyen\Plugin\CustomerData\AddAdyenExpressMethods; | ||
| use Adyen\ExpressCheckout\Plugin\CustomerData\Cart as Subject; | ||
|
|
||
| class Cart | ||
| { | ||
| /** | ||
| * If the Adyen Express has already added the payment methods then we can set use them without having | ||
| * to call Adyen's API again. | ||
| * | ||
| * @param Subject $subject | ||
| * @param array $result | ||
| * @return array | ||
| */ | ||
| public function afterAfterGetSectionData( | ||
| Subject $subject, | ||
| array $result | ||
| ): array { | ||
| if (isset($result[Subject::PAYMENT_METHODS_KEY])) { | ||
| $result[AddAdyenExpressMethods::PAYMENT_METHODS_KEY] = $result[Subject::PAYMENT_METHODS_KEY]; | ||
| } | ||
|
|
||
| return $result; | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.