Skip to content
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

Merge rc-v2 into develop #56

Merged
merged 22 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -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 -F testBranch=${{ github.event.pull_request.head.ref}}
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
on: ["push", "pull_request"]
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
name: Main Workflow

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Model/ConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/
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 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';

/**
* Returns configuration value for where to show apple pay
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
114 changes: 114 additions & 0 deletions Setup/Patch/Data/UpdateExpressDBPaths.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
/**
*
* Adyen ExpressCheckout Module
*
* Copyright (c) 2023 Adyen N.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <[email protected]>
*/
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'
);

$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';
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.1.3",
"version": "2.0.0",
"license": "MIT",
"repositories": [
{
Expand All @@ -11,7 +11,7 @@
}
],
"require": {
"adyen/module-payment": "^8"
"adyen/module-payment": "^9"
},
"require-dev": {
"phpunit/phpunit": "*",
Expand Down
4 changes: 2 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<system>
<section id="payment">
<group id="adyen_group_all_in_one">
<group id="adyen_configure_payment_methods">
<include path="Adyen_ExpressCheckout::system/adyen_hpp.xml"/>
<group id="adyen_accepting_payments">
<include path="Adyen_ExpressCheckout::system/adyen_online_checkout.xml"/>
</group>
</group>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="adyen_hpp">
<group id="adyen_hpp_express" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="200">
<group id="adyen_online_checkout">
<group id="adyen_express" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="50">
<label>Express Payments</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="show_google_pay_on" translate="label" type="multiselect" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Show GooglePay on</label>
<source_model>Adyen\ExpressCheckout\Model\Config\Source\ShortcutAreas</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/adyen_hpp/show_google_pay_on</config_path>
<config_path>payment/adyen_express/show_google_pay_on</config_path>
</field>
<field id="show_apple_pay_on" translate="label" type="multiselect" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Show ApplePay on</label>
<source_model>Adyen\ExpressCheckout\Model\Config\Source\ShortcutAreas</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/adyen_hpp/show_apple_pay_on</config_path>
<config_path>payment/adyen_express/show_apple_pay_on</config_path>
</field>
</group>
</group>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_ExpressCheckout" setup_version="1.1.3">
<module name="Adyen_ExpressCheckout" setup_version="2.0.0">
<sequence>
<module name="Adyen_Payment"/>
</sequence>
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/applepay/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ define([
const postData = {
email: shippingContact.emailAddress,
paymentMethod: {
method: 'adyen_hpp',
method: 'adyen_applepay',
additional_data: {
brand_code: 'applepay',
stateData: JSON.stringify(componentData)
Expand Down
3 changes: 2 additions & 1 deletion view/frontend/web/js/googlepay/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -411,6 +411,7 @@ define([
}.bind(this));
},


hossam-adyen marked this conversation as resolved.
Show resolved Hide resolved
setShippingInformation: function (paymentData) {
const shippingMethod = this.shippingMethods.find(function (method) {
return method.method_code === paymentData.shippingOptionData.id;
Expand Down