diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..afa5271 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,17 @@ +name: Adyen Magento 2 Express Checkout Plugin E2E Trigger Workflow +run-name: Headless E2E tests for ${{ github.event.pull_request.head.ref}} + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: [main, develop] + +jobs: + test: + runs-on: ubuntu-latest + if: ${{ github.actor != 'renovate[bot]' || github.actor != 'lgtm-com[bot]' }} + env: + GITHUB_TOKEN: ${{ secrets.ADYEN_AUTOMATION_BOT_TEST_ACCESS_TOKEN }} + steps: + - name: Run E2E Tests + run: gh workflow run e2e-test-express-checkout.yml -R Adyen/adyen-magento2 \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 75992fa..d97912f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,6 @@ -on: ["push", "pull_request"] +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] name: Main Workflow jobs: diff --git a/Model/ConfigurationInterface.php b/Model/ConfigurationInterface.php index 2397fab..6539ed9 100644 --- a/Model/ConfigurationInterface.php +++ b/Model/ConfigurationInterface.php @@ -22,9 +22,9 @@ */ interface ConfigurationInterface { - public const SHOW_APPLE_PAY_ON_CONFIG_PATH = 'payment/adyen_hpp/show_apple_pay_on'; - public const SHOW_GOOGLE_PAY_ON_CONFIG_PATH = 'payment/adyen_hpp/show_google_pay_on'; - public const APPLE_PAY_BUTTON_COLOR_CONFIG_PATH = 'payment/adyen_hpp/apple_pay_button_color'; + public const SHOW_APPLE_PAY_ON_CONFIG_PATH = 'payment/adyen_express/show_apple_pay_on'; + public const SHOW_GOOGLE_PAY_ON_CONFIG_PATH = 'payment/adyen_express/show_google_pay_on'; + public const APPLE_PAY_BUTTON_COLOR_CONFIG_PATH = 'payment/adyen_express/apple_pay_button_color'; /** * Returns configuration value for where to show apple pay diff --git a/README.md b/README.md index 8594381..a2565e6 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ bin/magento cache:clean ## Configuration Steps 1. Add the payment method in your [Customer Area](https://docs.adyen.com/payment-methods#add-payment-methods-to-your-account). -2. Make sure that Alternative payment methods are activated in your [Magento configuration](https://docs.adyen.com/plugins/magento-2/set-up-the-payment-methods-in-magento#alternative-payment-methods). -3. In the Magento admin page, go to Alternative payment methods > Express Payments > Show Google Pay on > Select one or all of your desired options. +2. Make sure that Payment methods are activated in your [Magento configuration](https://docs.adyen.com/plugins/adobe-commerce/set-up-the-payment-methods-in-adobe-commerce/). +3. In the Magento admin page, go to Accepting Payments > Online Checkout > Express Payments > Show Google Pay on > Select one or all of your desired options. 4. For Apple Pay: [Use Adyen's Apple Pay Certificate to go live](https://docs.adyen.com/payment-methods/apple-pay/web-component#going-live), without designing your Apple Pay integration. 5. For Google Pay: Set up [Google Pay](https://docs.adyen.com/payment-methods/google-pay/web-component#before-you-go-live). diff --git a/Setup/Patch/Data/UpdateExpressDBPaths.php b/Setup/Patch/Data/UpdateExpressDBPaths.php new file mode 100644 index 0000000..294ef89 --- /dev/null +++ b/Setup/Patch/Data/UpdateExpressDBPaths.php @@ -0,0 +1,121 @@ + + */ +declare(strict_types=1); + +namespace Adyen\ExpressCheckout\Setup\Patch\Data; + +use Magento\Framework\App\Config\ReinitableConfigInterface; +use Magento\Framework\App\Config\Storage\WriterInterface; +use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Framework\Setup\Patch\DataPatchInterface; +use Magento\Framework\Setup\Patch\PatchVersionInterface; + +class UpdateExpressDBPaths implements DataPatchInterface, PatchVersionInterface +{ + private ModuleDataSetupInterface $moduleDataSetup; + private WriterInterface $configWriter; + private ReinitableConfigInterface $reinitableConfig; + + public function __construct( + ModuleDataSetupInterface $moduleDataSetup, + WriterInterface $configWriter, + ReinitableConfigInterface $reinitableConfig + ) { + $this->moduleDataSetup = $moduleDataSetup; + $this->configWriter = $configWriter; + $this->reinitableConfig = $reinitableConfig; + } + + public function apply(): void + { + $this->moduleDataSetup->getConnection()->startSetup(); + + // Update Apple Pay config path + $this->updateConfigValue( + $this->moduleDataSetup, + 'payment/adyen_hpp/show_apple_pay_on', + 'payment/adyen_express/show_apple_pay_on' + ); + + // Update Google Pay config path + $this->updateConfigValue( + $this->moduleDataSetup, + 'payment/adyen_hpp/show_google_pay_on', + 'payment/adyen_express/show_google_pay_on' + ); + + // Update Google Pay config path + $this->updateConfigValue( + $this->moduleDataSetup, + 'payment/adyen_hpp/apple_pay_button_color', + 'payment/adyen_express/apple_pay_button_color' + ); + + $this->moduleDataSetup->getConnection()->endSetup(); + } + + private function updateConfigValue( + ModuleDataSetupInterface $setup, + string $oldPath, + string $newPath + ): void { + $config = $this->findConfig($setup, $oldPath); + + if ($config !== false) { + $this->configWriter->save( + $newPath, + $config['value'], + $config['scope'], + $config['scope_id'] + ); + } + + $this->reinitableConfig->reinit(); + } + + private function findConfig(ModuleDataSetupInterface $setup, string $path): mixed + { + $configDataTable = $setup->getTable('core_config_data'); + $connection = $setup->getConnection(); + + $select = $connection->select() + ->from($configDataTable) + ->where( + 'path = ?', + $path + ); + + $matchingConfigs = $connection->fetchAll($select); + return reset($matchingConfigs); + } + + /** + * @inheritdoc + */ + public function getAliases(): array + { + return []; + } + + /** + * @inheritdoc + */ + public static function getDependencies(): array + { + return []; + } + + public static function getVersion(): string + { + return '2.0.0'; + } +} diff --git a/composer.json b/composer.json index f91b33a..96cf2fa 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "adyen/adyen-magento2-expresscheckout", "description": "Official Adyen Magento2 plugin to add express payment method shortcuts.", "type": "magento2-module", - "version": "1.2.0", + "version": "2.0.0", "license": "MIT", "repositories": [ { @@ -11,7 +11,7 @@ } ], "require": { - "adyen/module-payment": "^8" + "adyen/module-payment": "^9" }, "require-dev": { "phpunit/phpunit": "*", diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 696ef3f..efd63ab 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -14,8 +14,8 @@
- - + +
diff --git a/etc/adminhtml/system/adyen_hpp.xml b/etc/adminhtml/system/adyen_online_checkout.xml similarity index 79% rename from etc/adminhtml/system/adyen_hpp.xml rename to etc/adminhtml/system/adyen_online_checkout.xml index 3bd184a..af098a4 100755 --- a/etc/adminhtml/system/adyen_hpp.xml +++ b/etc/adminhtml/system/adyen_online_checkout.xml @@ -11,33 +11,33 @@ */ --> - - + + Magento\Config\Block\System\Config\Form\Fieldset Magento\Config\Block\System\Config\Form\Fieldset - + Adyen\ExpressCheckout\Model\Config\Source\ShortcutAreas 1 - payment/adyen_hpp/show_google_pay_on + payment/adyen_express/show_google_pay_on Magento\Config\Block\System\Config\Form\Fieldset - - + + Adyen\ExpressCheckout\Model\Config\Source\ShortcutAreas 1 - payment/adyen_hpp/show_apple_pay_on + payment/adyen_express/show_apple_pay_on Adyen\ExpressCheckout\Model\Config\Source\ApplePay\ButtonColor - payment/adyen_hpp/apple_pay_button_color + payment/adyen_express/apple_pay_button_color Apple Pay documentation.]]> diff --git a/etc/module.xml b/etc/module.xml index 77d3477..fd01369 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -11,7 +11,7 @@ */ --> - + diff --git a/view/frontend/web/js/applepay/button.js b/view/frontend/web/js/applepay/button.js index 243089c..f75d394 100644 --- a/view/frontend/web/js/applepay/button.js +++ b/view/frontend/web/js/applepay/button.js @@ -481,7 +481,7 @@ define([ const postData = { email: shippingContact.emailAddress, paymentMethod: { - method: 'adyen_hpp', + method: 'adyen_applepay', additional_data: { brand_code: 'applepay', stateData: JSON.stringify(componentData) diff --git a/view/frontend/web/js/googlepay/button.js b/view/frontend/web/js/googlepay/button.js index cc19c9c..f8bf8e3 100644 --- a/view/frontend/web/js/googlepay/button.js +++ b/view/frontend/web/js/googlepay/button.js @@ -380,7 +380,7 @@ define([ shippingAddress: this.mapAddress(paymentData.shippingAddress), billingAddress: this.mapAddress(paymentData.paymentMethodData.info.billingAddress), paymentMethod: { - method: 'adyen_hpp', + method: 'adyen_googlepay', additional_data: { brand_code: self.googlePayComponent.props.type, stateData: JSON.stringify(componentData)