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

Release 9.0.5 #2411

Merged
merged 11 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ configure: n98-magerun2.phar
bin/magento config:set payment/adyen_cc_vault/require_cvc 1
bin/magento config:set payment/adyen_abstract/client_key_test "${ADYEN_CLIENT_KEY}"
bin/magento config:set payment/adyen_abstract/notification_username 'admin'
bin/magento config:set payment/adyen_abstract/payment_methods_active 1
./n98-magerun2.phar config:store:set --encrypt payment/adyen_abstract/notification_password '1234' > /dev/null
./n98-magerun2.phar config:store:set --encrypt payment/adyen_abstract/api_key_test "${ADYEN_API_KEY}" > /dev/null

Expand Down Expand Up @@ -103,6 +104,13 @@ graphql:
@cd ${MAGENTO_ROOT}/dev/tests/api-functional && \
${MAGENTO_ROOT}/vendor/bin/phpunit --prepend ${GRAPHQL_PHP} --configuration ${GRAPHQL_XML} ${GRAPHQL_SUITE}

# REST API tests
restapi:
@cd ${MAGENTO_ROOT}/dev/tests/api-functional && \
${MAGENTO_ROOT}/vendor/bin/phpunit --prepend /data/extensions/workdir/Test/phpunit_rest.php \
--configuration ${MAGENTO_ROOT}/dev/tests/api-functional/phpunit_rest.xml.dist \
${MAGENTO_ROOT}/vendor/adyen/module-payment/Test/api-functional/Webapi

# Destroy services
clean:
docker-compose -f workflows/templates/docker-compose.yml down --volumes --rmi local
Expand Down
39 changes: 18 additions & 21 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,29 @@ jobs:

- name: Install plugin
run: docker exec -u www-data magento2-container make plugin

- name: Kill Cron Jobs
run: docker exec magento2-container /etc/init.d/cron stop

# The commented out section will be re-enabled with ECP-8686

# - name: Checkout developer module
# uses: actions/checkout@v3
# with:
# repository: Adyen/adyen-magento2-dev
# ref: 'main'
# token: ${{ secrets.ADYEN_AUTOMATION_BOT_TEST_ACCESS_TOKEN }}
# path: Developer

# - name: Make the folder for dev module
# run: docker exec -u www-data magento2-container mkdir -p /var/www/html/app/code/Adyen
- name: Checkout developer module
uses: actions/checkout@v3
with:
repository: Adyen/adyen-magento2-dev
ref: 'main'
token: ${{ secrets.ADYEN_AUTOMATION_BOT_TEST_ACCESS_TOKEN }}
path: Developer

# - name: Copy dev module into Docker container
# run: docker cp ./Developer magento2-container:/var/www/html/app/code/Adyen
- name: Make the folder for dev module
run: docker exec -u www-data magento2-container mkdir -p /var/www/html/app/code/Adyen

# - name: Change ownership of developer module folder
# run: docker exec magento2-container chown -R www-data:www-data /var/www/html/app/code/Adyen/Developer
- name: Copy dev module into Docker container
run: docker cp ./Developer magento2-container:/var/www/html/app/code/Adyen

# - name: Enable developer module
# run: docker exec -u www-data magento2-container make dev-module

# - name: Kill Cron Jobs
# run: docker exec magento2-container /etc/init.d/cron stop
- name: Change ownership of developer module folder
run: docker exec magento2-container chown -R www-data:www-data /var/www/html/app/code/Adyen/Developer

- name: Enable developer module
run: docker exec -u www-data magento2-container make dev-module
- name: Switch to production mode
run: docker exec -u www-data magento2-container make production

Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/restapi-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: REST API Tests
on: [pull_request]

jobs:
build:
strategy:
matrix:
php-version: ["8.1"]
magento-version: ["2.4.5"]
runs-on: ubuntu-latest
env:
PHP_VERSION: ${{ matrix.php-version }}
MAGENTO_VERSION: ${{ matrix.magento-version }}
ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}

steps:
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento

- name: Start web server in background
run: docker-compose -f .github/workflows/templates/docker-compose.yml up -d web
env:
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
ADYEN_API_KEY: ${{secrets.ADYEN_API_KEY}}
ADYEN_CLIENT_KEY: ${{secrets.ADYEN_CLIENT_KEY}}

- name: Setup permissions
run: docker exec magento2-container make fs

- name: Check install
run: docker exec magento2-container make sys-check

- name: Install plugin
run: docker exec -u www-data magento2-container make plugin

- run: docker exec magento2-container /etc/init.d/cron stop

- name: Run REST API tests
run: docker exec magento2-container make restapi
3 changes: 2 additions & 1 deletion Api/AdyenDonationsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ interface AdyenDonationsInterface
/**
* Build and send donation payment request
*
* @param int $orderId
* @param string $payload
* @return void
*/
public function donate(string $payload): void;
public function donate(int $orderId, string $payload): void;
}
4 changes: 2 additions & 2 deletions Api/GuestAdyenDonationsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ interface GuestAdyenDonationsInterface
/**
* Build and send donation payment request for guest shoppers
*
* @param string $cartId
* @param string $payload
* @param string $orderId
* @return void
*/
public function donate(string $payload, string $orderId): void;
public function donate(string $cartId, string $payload): void;
}
83 changes: 30 additions & 53 deletions Block/Checkout/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Helper\PaymentResponseHandler;
use Adyen\Payment\Model\Ui\AdyenCheckoutSuccessConfigProvider;
use Magento\Checkout\Model\Session;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Quote\Model\QuoteIdToMaskedQuoteId;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
Expand All @@ -25,62 +28,22 @@

class Success extends Template
{

/**
* @var Order $order
*/
protected $order;
protected CheckoutSession $checkoutSession;
protected CustomerSession $customerSession;
protected OrderFactory $orderFactory;
protected Data $adyenHelper;
protected StoreManagerInterface $storeManager;
private Config $configHelper;
private SerializerInterface $serializerInterface;
private AdyenCheckoutSuccessConfigProvider $configProvider;
private QuoteIdToMaskedQuoteId $quoteIdToMaskedQuoteId;

/**
* @var Session
*/
protected $checkoutSession;

/**
* @var OrderFactory
*/
protected $orderFactory;


/**
* @var Data
*/
protected $adyenHelper;

/**
* @var StoreManagerInterface
*/
protected $storeManager;

/**
* @var Config
*/
private $configHelper;

/**
* @var SerializerInterface
*/
private $serializerInterface;

/**
* @var AdyenCheckoutSuccessConfigProvider
*/
private $configProvider;

/**
* Success constructor.
*
* @param Context $context
* @param Session $checkoutSession
* @param OrderFactory $orderFactory
* @param Data $adyenHelper
* @param Config $configHelper
* @param StoreManagerInterface $storeManager
* @param array $data
*/
public function __construct(
Context $context,
Session $checkoutSession,
CheckoutSession $checkoutSession,
CustomerSession $customerSession,
QuoteIdToMaskedQuoteId $quoteIdToMaskedQuoteId,
OrderFactory $orderFactory,
Data $adyenHelper,
Config $configHelper,
Expand All @@ -90,6 +53,8 @@ public function __construct(
array $data = []
) {
$this->checkoutSession = $checkoutSession;
$this->customerSession = $customerSession;
$this->quoteIdToMaskedQuoteId = $quoteIdToMaskedQuoteId;
$this->orderFactory = $orderFactory;
$this->adyenHelper = $adyenHelper;
$this->configHelper = $configHelper;
Expand Down Expand Up @@ -204,4 +169,16 @@ public function getOrder()
return $this->order;
}

/**
* @throws NoSuchEntityException
*/
public function getMaskedQuoteId(): ?string
{
return $this->quoteIdToMaskedQuoteId->execute($this->getOrder()->getQuoteId());
}

public function getIsCustomerLoggedIn(): bool
{
return $this->customerSession->isLoggedIn();
}
}
22 changes: 12 additions & 10 deletions Console/Command/EnablePaymentMethodsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

namespace Adyen\Payment\Console\Command;

use Adyen\Payment\Helper\PaymentMethods;
use Adyen\Payment\Helper\Config;
use Adyen\Payment\Helper\PaymentMethodsFactory;
use Adyen\Payment\Helper\ConfigFactory;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class EnablePaymentMethodsCommand extends Command
{
private PaymentMethods $paymentMethods;
private PaymentMethodsFactory $paymentMethodsFactory;

private Config $configHelper;
private ConfigFactory $configHelperFactory;

public function __construct(
PaymentMethods $paymentMethods,
Config $configHelper
PaymentMethodsFactory $paymentMethodsFactory,
ConfigFactory $configHelperFactory
) {
$this->paymentMethods = $paymentMethods;
$this->configHelper = $configHelper;
$this->paymentMethodsFactory = $paymentMethodsFactory;
$this->configHelperFactory = $configHelperFactory;
parent::__construct();
}

Expand All @@ -35,12 +35,14 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): void
{
$output->writeln('Starting enabling payment methods.');
$availablePaymentMethods = $this->paymentMethods->getAdyenPaymentMethods();
$paymentMethods = $this->paymentMethodsFactory->create();
$availablePaymentMethods = $paymentMethods->getAdyenPaymentMethods();
$configHelper = $this->configHelperFactory->create();

foreach ($availablePaymentMethods as $paymentMethod) {
$value = '1';
$field = 'active';
$this->configHelper->setConfigData($value, $field, $paymentMethod);
$configHelper->setConfigData($value, $field, $paymentMethod);
$output->writeln("Enabled payment method: {$paymentMethod}");
}

Expand Down
4 changes: 2 additions & 2 deletions Gateway/Request/CaptureDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function build(array $buildSubject): array

//Check additionaldata
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
$openInvoiceFields = $this->openInvoiceHelper->getOpenInvoiceData($order);
$openInvoiceFields = $this->openInvoiceHelper->getOpenInvoiceDataForOrder($order);
$requestBody = array_merge($requestBody, $openInvoiceFields);
}
$request['body'] = $requestBody;
Expand Down Expand Up @@ -179,7 +179,7 @@ public function buildPartialOrMultipleCaptureData($payment, $currency, $adyenOrd
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod(
$adyenOrderPayment[OrderPaymentInterface::PAYMENT_METHOD]
)) {
$openInvoiceFields = $this->openInvoiceHelper->getOpenInvoiceData($payment);
$openInvoiceFields = $this->openInvoiceHelper->getOpenInvoiceDataForLastInvoice($payment);
$authToCapture = array_merge($authToCapture, $openInvoiceFields);
}

Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/CheckoutDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function build(array $buildSubject): array
$payment->getMethod() === AdyenPayByLinkConfigProvider::CODE
) {

$openInvoiceFields = $this->openInvoiceHelper->getOpenInvoiceData($order);
$openInvoiceFields = $this->openInvoiceHelper->getOpenInvoiceDataForOrder($order);
$requestBody = array_merge($requestBody, $openInvoiceFields);

if (isset($brandCode) &&
Expand Down
11 changes: 4 additions & 7 deletions Gateway/Request/RefundDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
use Adyen\Payment\Model\ResourceModel\Invoice\CollectionFactory;
use Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory as PaymentCollectionFactory;
use Adyen\Payment\Observer\AdyenPaymentMethodDataAssignObserver;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Payment\Gateway\Request\BuilderInterface;
use Magento\Payment\Model\InfoInterface;
use Magento\Sales\Model\Order\Creditmemo;
use Magento\Sales\Model\Order\Payment;

/**
* Class CustomerDataBuilder
Expand All @@ -36,20 +34,17 @@ class RefundDataBuilder implements BuilderInterface
private Data $adyenHelper;
private Config $configHelper;
private PaymentCollectionFactory $orderPaymentCollectionFactory;
protected CollectionFactory $adyenInvoiceCollectionFactory;
private ChargedCurrency $chargedCurrency;

public function __construct(
Data $adyenHelper,
PaymentCollectionFactory $orderPaymentCollectionFactory,
CollectionFactory $adyenInvoiceCollectionFactory,
ChargedCurrency $chargedCurrency,
Config $configHelper,
OpenInvoice $openInvoiceHelper
) {
$this->adyenHelper = $adyenHelper;
$this->orderPaymentCollectionFactory = $orderPaymentCollectionFactory;
$this->adyenInvoiceCollectionFactory = $adyenInvoiceCollectionFactory;
$this->chargedCurrency = $chargedCurrency;
$this->configHelper = $configHelper;
$this->openInvoiceHelper = $openInvoiceHelper;
Expand All @@ -60,6 +55,7 @@ public function build(array $buildSubject): array
$paymentDataObject = SubjectReader::readPayment($buildSubject);

$order = $paymentDataObject->getOrder();
/** @var Payment $payment */
$payment = $paymentDataObject->getPayment();
$orderAmountCurrency = $this->chargedCurrency->getOrderAmountCurrency($payment->getOrder(), false);

Expand Down Expand Up @@ -168,11 +164,12 @@ public function build(array $buildSubject): array
);

if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($brandCode)) {
$openInvoiceFieldsCreditMemo = $this->openInvoiceHelper->getOpenInvoiceData($creditMemo->getOrder());
$openInvoiceFieldsCreditMemo = $this->openInvoiceHelper->getOpenInvoiceDataForCreditMemo($payment);
//There is only one payment, so we add the fields to the first(and only) result
$requestBody[0] = array_merge($requestBody[0], $openInvoiceFieldsCreditMemo);
}
}

$request['clientConfig'] = ["storeId" => $payment->getOrder()->getStoreId()];
$request['body'] = $requestBody;

Expand Down
3 changes: 3 additions & 0 deletions Gateway/Response/PaymentPosCloudHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function handle(array $handlingSubject, array $response)
// do not send order confirmation mail
$payment->getOrder()->setCanSendNewEmailFlag(false);

if (!empty($paymentResponse) && isset($paymentResponse['Response']['Result'])) {
$payment->setAdditionalInformation('resultCode', $paymentResponse['Response']['Result']);
}

if (!empty($paymentResponse['Response']['AdditionalResponse']))
{
Expand Down
Loading