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 1.2.2 #75

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
43 changes: 41 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,54 @@ jobs:
php-version: [8.2,8.3]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v1
tools: composer:v2

- name: Define Hyvä Checkout repositories
run: |
composer config repositories.hyva-themes/hyva-checkout git [email protected]:hyva-checkout/checkout.git
composer config repositories.hyva-themes/magento2-theme-module git [email protected]:hyva-themes/magento2-theme-module.git
composer config repositories.hyva-themes/magento2-reset-theme git [email protected]:hyva-themes/magento2-reset-theme.git
composer config repositories.hyva-themes/magento2-email-theme git [email protected]:hyva-themes/magento2-email-module.git
composer config repositories.hyva-default-theme git [email protected]:hyva-themes/magento2-default-theme.git

- name: Configure SSH access to Hyvä Gitlab
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
HYVA_GITLAB_SSH_KEY: ${{ secrets.GITLAB_SSH_KEY }}
run: |
mkdir -p ~/.ssh
ssh-keyscan gitlab.hyva.io >> ~/.ssh/known_hosts
echo "${HYVA_GITLAB_SSH_KEY}" > ~/.ssh/hyva_id_rsa
chmod 600 ~/.ssh/hyva_id_rsa
ssh-agent -a ${SSH_AUTH_SOCK} > /dev/null
ssh-add ~/.ssh/hyva_id_rsa

- name: Install the plugin
run: |
echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json
composer install --prefer-dist
env:
CI: true
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
MAGENTO_USERNAME: ${{ secrets.MAGENTO_USERNAME }}
MAGENTO_PASSWORD: ${{ secrets.MAGENTO_PASSWORD }}

- name: Code Sniffer
run: vendor/bin/phpcs .

- name: Run PHPUnit
run: vendor/bin/phpunit --coverage-clover=build/clover.xml --log-junit=build/tests-log.xml -c Test/phpunit.xml Test/Unit

- name: Fix code coverage paths
run: sed -i "s;`pwd`/;;g" build/*.xml

- name: SonarCloud Scan
if: ${{ env.SONAR_TOKEN }}
Expand Down
25 changes: 21 additions & 4 deletions Magewire/Payment/Method/AdyenPaymentComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
use Hyva\Checkout\Model\Magewire\Component\Evaluation\EvaluationResult;
use Hyva\Checkout\Model\Magewire\Component\EvaluationInterface;
use Hyva\Checkout\Model\Magewire\Component\EvaluationResultFactory;
use Magento\Checkout\Api\GuestPaymentInformationManagementInterface;
use Magento\Checkout\Api\PaymentInformationManagementInterface;
use Magento\Checkout\Model\Session;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
use Magewirephp\Magewire\Component;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -49,6 +51,8 @@ abstract class AdyenPaymentComponent extends Component implements EvaluationInte
protected StateData $stateData;
protected PaymentMethods $paymentMethods;
protected PaymentInformationManagementInterface $paymentInformationManagement;
protected GuestPaymentInformationManagementInterface $guestPaymentInformationManagement;
protected QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId;
protected AdyenOrderPaymentStatusInterface $adyenOrderPaymentStatus;
protected AdyenPaymentsDetailsInterface $adyenPaymentsDetails;
protected CustomerGroupHandler $customerGroupHandler;
Expand All @@ -65,6 +69,8 @@ public function __construct(
$this->stateData = $context->getStateData();
$this->paymentMethods = $context->getPaymentMethods();
$this->paymentInformationManagement = $context->getPaymentInformationManagement();
$this->guestPaymentInformationManagement = $context->getGuestPaymentInformationManagement();
$this->quoteIdToMaskedQuoteId = $this->context->getQuoteIdToMaskedQuoteId();
$this->adyenOrderPaymentStatus = $context->getAdyenOrderPaymentStatus();
$this->adyenPaymentsDetails = $context->getAdyenPaymentsDetails();
$this->customerGroupHandler = $context->getCustomerGroupHandler();
Expand Down Expand Up @@ -100,10 +106,21 @@ public function placeOrder(array $data): void
$stateDataReceived = $this->collectValidatedStateData($data);
//Temporary (per request) storage of state data
$this->stateData->setStateData($stateDataReceived, (int) $quoteId);
$orderId = $this->paymentInformationManagement->savePaymentInformationAndPlaceOrder(
$quoteId,
$payment
);

if ($this->userIsGuest()) {
$email = $this->session->getQuote()->getCustomerEmail();
$maskedQuoteId = $this->quoteIdToMaskedQuoteId->execute((int) $quoteId);
$orderId = $this->guestPaymentInformationManagement->savePaymentInformationAndPlaceOrder(
$maskedQuoteId,
$email,
$payment
);
} else {
$orderId = $this->paymentInformationManagement->savePaymentInformationAndPlaceOrder(
$quoteId,
$payment
);
}
$this->paymentStatus = $this->adyenOrderPaymentStatus->getOrderPaymentStatus(strval($orderId));
} catch (\Exception $exception) {
$this->paymentStatus = json_encode(['isRefused' => true]);
Expand Down
20 changes: 20 additions & 0 deletions Model/Component/Payment/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
use Adyen\Payment\Api\AdyenPaymentsDetailsInterface;
use Adyen\Payment\Helper\StateData;
use Adyen\Payment\Helper\Util\CheckoutStateDataValidator;
use Magento\Checkout\Api\GuestPaymentInformationManagementInterface;
use Magento\Checkout\Api\PaymentInformationManagementInterface;
use Magento\Checkout\Model\Session;
use Magento\Framework\ObjectManager\ContextInterface;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
use Psr\Log\LoggerInterface;

class Context implements ContextInterface
Expand All @@ -23,6 +25,8 @@ public function __construct(
private readonly StateData $stateData,
private readonly PaymentMethods $paymentMethods,
private readonly PaymentInformationManagementInterface $paymentInformationManagement,
private readonly GuestPaymentInformationManagementInterface $guestPaymentInformationManagement,
private readonly QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId,
private readonly AdyenOrderPaymentStatusInterface $adyenOrderPaymentStatus,
private readonly AdyenPaymentsDetailsInterface $adyenPaymentsDetails,
private readonly CustomerGroupHandler $customerGroupHandler,
Expand Down Expand Up @@ -78,6 +82,22 @@ public function getPaymentInformationManagement(): PaymentInformationManagementI
return $this->paymentInformationManagement;
}

/**
* @return PaymentInformationManagementInterface
*/
public function getGuestPaymentInformationManagement(): GuestPaymentInformationManagementInterface
{
return $this->guestPaymentInformationManagement;
}

/**
* @return QuoteIdToMaskedQuoteIdInterface
*/
public function getQuoteIdToMaskedQuoteId(): QuoteIdToMaskedQuoteIdInterface
{
return $this->quoteIdToMaskedQuoteId;
}

/**
* @return AdyenOrderPaymentStatusInterface
*/
Expand Down
30 changes: 30 additions & 0 deletions Model/CompositeConfigProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Adyen\Hyva\Model;

use Magento\Checkout\Model\ConfigProviderInterface;
class CompositeConfigProvider implements ConfigProviderInterface
{
/**
* @param array $configProviders
*/
public function __construct(
private readonly array $configProviders
) { }

/**
* @return array
*/
public function getConfig(): array
{
$config = [];

foreach ($this->configProviders as $configProvider) {
$config = array_merge_recursive($config, $configProvider->getConfig());
}

return $config;
}
}
5 changes: 2 additions & 3 deletions Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Adyen\Hyva\Model;

use Exception;
use Magento\Checkout\Model\CompositeConfigProvider;
use Magento\Framework\DataObject;
use Magento\Framework\DataObjectFactory;
use Psr\Log\LoggerInterface;
Expand All @@ -16,8 +15,8 @@ class Configuration

public function __construct(
CompositeConfigProvider $configProvider,
DataObjectFactory $dataObjectFactory,
LoggerInterface $logger
DataObjectFactory $dataObjectFactory,
LoggerInterface $logger
) {
try {
if (isset($configProvider->getConfig()['payment'])) {
Expand Down
Loading
Loading