Skip to content

Commit 2c70956

Browse files
Merge pull request #75 from Adyen/develop
Release 1.2.2
2 parents 406ce2c + 7edc260 commit 2c70956

23 files changed

+482
-87
lines changed

.github/workflows/main.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,54 @@ jobs:
1515
php-version: [8.2,8.3]
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

2222
- name: Use PHP ${{ matrix.php-version }}
2323
uses: shivammathur/setup-php@v2
2424
with:
2525
php-version: ${{ matrix.php-version }}
26-
tools: composer:v1
26+
tools: composer:v2
27+
28+
- name: Define Hyvä Checkout repositories
29+
run: |
30+
composer config repositories.hyva-themes/hyva-checkout git [email protected]:hyva-checkout/checkout.git
31+
composer config repositories.hyva-themes/magento2-theme-module git [email protected]:hyva-themes/magento2-theme-module.git
32+
composer config repositories.hyva-themes/magento2-reset-theme git [email protected]:hyva-themes/magento2-reset-theme.git
33+
composer config repositories.hyva-themes/magento2-email-theme git [email protected]:hyva-themes/magento2-email-module.git
34+
composer config repositories.hyva-default-theme git [email protected]:hyva-themes/magento2-default-theme.git
35+
36+
- name: Configure SSH access to Hyvä Gitlab
37+
env:
38+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
39+
HYVA_GITLAB_SSH_KEY: ${{ secrets.GITLAB_SSH_KEY }}
40+
run: |
41+
mkdir -p ~/.ssh
42+
ssh-keyscan gitlab.hyva.io >> ~/.ssh/known_hosts
43+
echo "${HYVA_GITLAB_SSH_KEY}" > ~/.ssh/hyva_id_rsa
44+
chmod 600 ~/.ssh/hyva_id_rsa
45+
ssh-agent -a ${SSH_AUTH_SOCK} > /dev/null
46+
ssh-add ~/.ssh/hyva_id_rsa
47+
48+
- name: Install the plugin
49+
run: |
50+
echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json
51+
composer install --prefer-dist
52+
env:
53+
CI: true
54+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
55+
MAGENTO_USERNAME: ${{ secrets.MAGENTO_USERNAME }}
56+
MAGENTO_PASSWORD: ${{ secrets.MAGENTO_PASSWORD }}
57+
58+
- name: Code Sniffer
59+
run: vendor/bin/phpcs .
60+
61+
- name: Run PHPUnit
62+
run: vendor/bin/phpunit --coverage-clover=build/clover.xml --log-junit=build/tests-log.xml -c Test/phpunit.xml Test/Unit
63+
64+
- name: Fix code coverage paths
65+
run: sed -i "s;`pwd`/;;g" build/*.xml
2766

2867
- name: SonarCloud Scan
2968
if: ${{ env.SONAR_TOKEN }}

Magewire/Payment/Method/AdyenPaymentComponent.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
use Hyva\Checkout\Model\Magewire\Component\Evaluation\EvaluationResult;
1818
use Hyva\Checkout\Model\Magewire\Component\EvaluationInterface;
1919
use Hyva\Checkout\Model\Magewire\Component\EvaluationResultFactory;
20+
use Magento\Checkout\Api\GuestPaymentInformationManagementInterface;
2021
use Magento\Checkout\Api\PaymentInformationManagementInterface;
2122
use Magento\Checkout\Model\Session;
23+
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
2224
use Magewirephp\Magewire\Component;
2325
use Psr\Log\LoggerInterface;
2426

@@ -49,6 +51,8 @@ abstract class AdyenPaymentComponent extends Component implements EvaluationInte
4951
protected StateData $stateData;
5052
protected PaymentMethods $paymentMethods;
5153
protected PaymentInformationManagementInterface $paymentInformationManagement;
54+
protected GuestPaymentInformationManagementInterface $guestPaymentInformationManagement;
55+
protected QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId;
5256
protected AdyenOrderPaymentStatusInterface $adyenOrderPaymentStatus;
5357
protected AdyenPaymentsDetailsInterface $adyenPaymentsDetails;
5458
protected CustomerGroupHandler $customerGroupHandler;
@@ -65,6 +69,8 @@ public function __construct(
6569
$this->stateData = $context->getStateData();
6670
$this->paymentMethods = $context->getPaymentMethods();
6771
$this->paymentInformationManagement = $context->getPaymentInformationManagement();
72+
$this->guestPaymentInformationManagement = $context->getGuestPaymentInformationManagement();
73+
$this->quoteIdToMaskedQuoteId = $this->context->getQuoteIdToMaskedQuoteId();
6874
$this->adyenOrderPaymentStatus = $context->getAdyenOrderPaymentStatus();
6975
$this->adyenPaymentsDetails = $context->getAdyenPaymentsDetails();
7076
$this->customerGroupHandler = $context->getCustomerGroupHandler();
@@ -100,10 +106,21 @@ public function placeOrder(array $data): void
100106
$stateDataReceived = $this->collectValidatedStateData($data);
101107
//Temporary (per request) storage of state data
102108
$this->stateData->setStateData($stateDataReceived, (int) $quoteId);
103-
$orderId = $this->paymentInformationManagement->savePaymentInformationAndPlaceOrder(
104-
$quoteId,
105-
$payment
106-
);
109+
110+
if ($this->userIsGuest()) {
111+
$email = $this->session->getQuote()->getCustomerEmail();
112+
$maskedQuoteId = $this->quoteIdToMaskedQuoteId->execute((int) $quoteId);
113+
$orderId = $this->guestPaymentInformationManagement->savePaymentInformationAndPlaceOrder(
114+
$maskedQuoteId,
115+
$email,
116+
$payment
117+
);
118+
} else {
119+
$orderId = $this->paymentInformationManagement->savePaymentInformationAndPlaceOrder(
120+
$quoteId,
121+
$payment
122+
);
123+
}
107124
$this->paymentStatus = $this->adyenOrderPaymentStatus->getOrderPaymentStatus(strval($orderId));
108125
} catch (\Exception $exception) {
109126
$this->paymentStatus = json_encode(['isRefused' => true]);

Model/Component/Payment/Context.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
use Adyen\Payment\Api\AdyenPaymentsDetailsInterface;
1010
use Adyen\Payment\Helper\StateData;
1111
use Adyen\Payment\Helper\Util\CheckoutStateDataValidator;
12+
use Magento\Checkout\Api\GuestPaymentInformationManagementInterface;
1213
use Magento\Checkout\Api\PaymentInformationManagementInterface;
1314
use Magento\Checkout\Model\Session;
1415
use Magento\Framework\ObjectManager\ContextInterface;
16+
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
1517
use Psr\Log\LoggerInterface;
1618

1719
class Context implements ContextInterface
@@ -23,6 +25,8 @@ public function __construct(
2325
private readonly StateData $stateData,
2426
private readonly PaymentMethods $paymentMethods,
2527
private readonly PaymentInformationManagementInterface $paymentInformationManagement,
28+
private readonly GuestPaymentInformationManagementInterface $guestPaymentInformationManagement,
29+
private readonly QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId,
2630
private readonly AdyenOrderPaymentStatusInterface $adyenOrderPaymentStatus,
2731
private readonly AdyenPaymentsDetailsInterface $adyenPaymentsDetails,
2832
private readonly CustomerGroupHandler $customerGroupHandler,
@@ -78,6 +82,22 @@ public function getPaymentInformationManagement(): PaymentInformationManagementI
7882
return $this->paymentInformationManagement;
7983
}
8084

85+
/**
86+
* @return PaymentInformationManagementInterface
87+
*/
88+
public function getGuestPaymentInformationManagement(): GuestPaymentInformationManagementInterface
89+
{
90+
return $this->guestPaymentInformationManagement;
91+
}
92+
93+
/**
94+
* @return QuoteIdToMaskedQuoteIdInterface
95+
*/
96+
public function getQuoteIdToMaskedQuoteId(): QuoteIdToMaskedQuoteIdInterface
97+
{
98+
return $this->quoteIdToMaskedQuoteId;
99+
}
100+
81101
/**
82102
* @return AdyenOrderPaymentStatusInterface
83103
*/

Model/CompositeConfigProvider.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Adyen\Hyva\Model;
6+
7+
use Magento\Checkout\Model\ConfigProviderInterface;
8+
class CompositeConfigProvider implements ConfigProviderInterface
9+
{
10+
/**
11+
* @param array $configProviders
12+
*/
13+
public function __construct(
14+
private readonly array $configProviders
15+
) { }
16+
17+
/**
18+
* @return array
19+
*/
20+
public function getConfig(): array
21+
{
22+
$config = [];
23+
24+
foreach ($this->configProviders as $configProvider) {
25+
$config = array_merge_recursive($config, $configProvider->getConfig());
26+
}
27+
28+
return $config;
29+
}
30+
}

Model/Configuration.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Adyen\Hyva\Model;
66

77
use Exception;
8-
use Magento\Checkout\Model\CompositeConfigProvider;
98
use Magento\Framework\DataObject;
109
use Magento\Framework\DataObjectFactory;
1110
use Psr\Log\LoggerInterface;
@@ -16,8 +15,8 @@ class Configuration
1615

1716
public function __construct(
1817
CompositeConfigProvider $configProvider,
19-
DataObjectFactory $dataObjectFactory,
20-
LoggerInterface $logger
18+
DataObjectFactory $dataObjectFactory,
19+
LoggerInterface $logger
2120
) {
2221
try {
2322
if (isset($configProvider->getConfig()['payment'])) {

0 commit comments

Comments
 (0)