Skip to content

Commit

Permalink
Merge branch 'main' into ECP-9357
Browse files Browse the repository at this point in the history
  • Loading branch information
candemiralp authored Dec 30, 2024
2 parents cdc4494 + 3ab803c commit 21433bf
Show file tree
Hide file tree
Showing 37 changed files with 687 additions and 313 deletions.
20 changes: 0 additions & 20 deletions .github/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/docker-compose.e2e.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
playwright:
image: mcr.microsoft.com/playwright:v1.49.0
image: mcr.microsoft.com/playwright:v1.49.1
shm_size: 1gb
ipc: host
cap_add:
Expand Down
158 changes: 0 additions & 158 deletions Controller/Adminhtml/Configuration/DownloadApplePayCertificate.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\Controller\Adminhtml\Configuration;

use Adyen\Payment\Logger\AdyenLogger;
use Exception;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Filesystem\Io\File;

class DownloadApplePayDomainAssociationFile extends Action
{
const FILE_NAME = 'apple-developer-merchantid-domain-association';
const REMOTE_PATH = 'https://bae81f955b.cdn.adyen.com/checkoutshopper/.well-known';
const PUB_PATH = 'pub';
const WELL_KNOWN_PATH = '.well-known';

public function __construct(
private readonly Context $context,
private readonly DirectoryList $directoryList,
private readonly File $fileIo,
private readonly AdyenLogger $adyenLogger
) {
parent::__construct($context);
}

/**
* @return ResultInterface|ResponseInterface
* @throws FileSystemException
*/
public function execute(): ResultInterface|ResponseInterface
{
$redirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$redirect->setUrl($this->_redirect->getRefererUrl());

try {
$pubPath = $this->directoryList->getPath(self::PUB_PATH);

$this->fileIo->checkAndCreateFolder(
sprintf("%s/%s", $pubPath, self::WELL_KNOWN_PATH),
0700
);

$source = sprintf("%s/%s", self::REMOTE_PATH, self::FILE_NAME);
$destination = sprintf("%s/%s/%s", $pubPath, self::WELL_KNOWN_PATH, self::FILE_NAME);

$file = $this->fileIo->read($source, $destination);

if (!$file) {
$errorMessage =
__('Error while downloading Apple Pay domain association file from the remote source!');
$this->adyenLogger->error(sprintf("%s %s", $errorMessage, $source));
$this->messageManager->addErrorMessage($errorMessage);
} else {
$successMessage = __('Apple Pay domain association file has been downloaded successfully!');
$this->adyenLogger->addAdyenDebug($successMessage);
$this->messageManager->addSuccessMessage($successMessage);
}
} catch (Exception $e) {
$errorMessage =
__('Unknown error while downloading Apple Pay domain association file!');
$this->adyenLogger->error(sprintf("%s %s", $errorMessage, $e->getMessage()));
$this->messageManager->addErrorMessage($errorMessage);
}

return $redirect;
}
}
2 changes: 1 addition & 1 deletion Gateway/Http/Client/TransactionCancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function placeRequest(TransferInterface $transferObject): array
$headers['idempotencyExtraData'] ?? null
);
$requestOptions['idempotencyKey'] = $idempotencyKey;
$requestOptions['headers'] = $this->adyenHelper->buildRequestHeaders();
$requestOptions['headers'] = $headers;
$this->adyenHelper->logRequest($request, Client::API_CHECKOUT_VERSION, '/cancels');
$request['applicationInfo'] = $this->adyenHelper->buildApplicationInfo($client);
$paymentCancelRequest = new PaymentCancelRequest($request);
Expand Down
6 changes: 4 additions & 2 deletions Gateway/Http/Client/TransactionCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ public function placeRequest(TransferInterface $transferObject): array
{
$request = $transferObject->getBody();
$headers = $transferObject->getHeaders();
$idempotencyKeyExtraData = $headers['idempotencyExtraData'];
unset($headers['idempotencyExtraData']);
$clientConfig = $transferObject->getClientConfig();

$client = $this->adyenHelper->initializeAdyenClientWithClientConfig($clientConfig);
$service = $this->adyenHelper->initializeModificationsApi($client);

$requestOptions['headers'] = $this->adyenHelper->buildRequestHeaders();
$requestOptions['headers'] = $headers;
$request['applicationInfo'] = $this->adyenHelper->buildApplicationInfo($client);

if (array_key_exists(self::MULTIPLE_AUTHORIZATIONS, $request)) {
Expand All @@ -86,7 +88,7 @@ public function placeRequest(TransferInterface $transferObject): array

$idempotencyKey = $this->idempotencyHelper->generateIdempotencyKey(
$request,
$headers['idempotencyExtraData'] ?? null
$idempotencyKeyExtraData ?? null
);
$requestOptions['idempotencyKey'] = $idempotencyKey;

Expand Down
8 changes: 5 additions & 3 deletions Gateway/Http/Client/TransactionPaymentLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ public function placeRequest(TransferInterface $transferObject): array
{
$request = $transferObject->getBody();
$headers = $transferObject->getHeaders();
$idempotencyKeyExtraData = $headers['idempotencyExtraData'] ?? null;
unset($headers['idempotencyExtraData']);
$clientConfig = $transferObject->getClientConfig();

$client = $this->adyenHelper->initializeAdyenClientWithClientConfig($clientConfig);
$service = new PaymentLinksApi($client);
$service = $this->adyenHelper->initializePaymentLinksApi($client);

// If the payment links call is already done return the request
if (!empty($request['resultCode'])) {
Expand All @@ -68,11 +70,11 @@ public function placeRequest(TransferInterface $transferObject): array

$idempotencyKey = $this->idempotencyHelper->generateIdempotencyKey(
$request,
$headers['idempotencyExtraData'] ?? null
$idempotencyKeyExtraData
);

$requestOptions['idempotencyKey'] = $idempotencyKey;
$requestOptions['headers'] = $this->adyenHelper->buildRequestHeaders();
$requestOptions['headers'] = $headers;
$request['applicationInfo'] = $this->adyenHelper->buildApplicationInfo($client);

$this->adyenHelper->logRequest($request, Client::API_CHECKOUT_VERSION, '/paymentLinks');
Expand Down
9 changes: 7 additions & 2 deletions Gateway/Http/Client/TransactionRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function placeRequest(TransferInterface $transferObject): array
{
$requests = $transferObject->getBody();
$headers = $transferObject->getHeaders();
$idempotencyKeyExtraData = $headers['idempotencyExtraData'];
unset($headers['idempotencyExtraData']);
$clientConfig = $transferObject->getClientConfig();

$client = $this->adyenHelper->initializeAdyenClientWithClientConfig($clientConfig);
Expand All @@ -66,10 +68,11 @@ public function placeRequest(TransferInterface $transferObject): array
$responseData = [];
$idempotencyKey = $this->idempotencyHelper->generateIdempotencyKey(
$request,
$headers['idempotencyExtraData'] ?? null
$idempotencyKeyExtraData ?? null
);
$requestOptions['idempotencyKey'] = $idempotencyKey;
$requestOptions['headers'] = $this->adyenHelper->buildRequestHeaders();
$requestOptions['headers'] = $headers;

$this->adyenHelper->logRequest($request, Client::API_CHECKOUT_VERSION, '/refunds');
$request['applicationInfo'] = $this->adyenHelper->buildApplicationInfo($client);
$paymentRefundRequest = new PaymentRefundRequest($request);
Expand All @@ -88,6 +91,8 @@ public function placeRequest(TransferInterface $transferObject): array
$this->adyenHelper->logResponse($responseData);
} catch (AdyenException $e) {
$this->adyenHelper->logAdyenException($e);
$responseData['error'] = $e->getMessage();
$responseData['errorCode'] = $e->getAdyenErrorCode();
}
$responses[] = $responseData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\Gateway\Request;
namespace Adyen\Payment\Gateway\Request\Header;

use Adyen\Payment\Helper\Data;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Payment\Gateway\Request\BuilderInterface;

class HeaderDataBuilder implements BuilderInterface
class HeaderDataBuilder implements BuilderInterface, HeaderDataBuilderInterface
{
const FRONTENDTYPE = 'external-platform-frontendtype';
const FRONTENDTYPE_HEADLESS = 'headless';

/**
* @var Data
*/
Expand Down
Loading

0 comments on commit 21433bf

Please sign in to comment.