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 version 4.2.0 #578

Merged
merged 28 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8f25655
Fix notification processing when merchantReference is missing
MarijaIv Oct 16, 2024
7d5dce2
Fix dal validation errors
AleksandarBoljanovic Nov 15, 2024
5e979cf
Add Online Banking Finland payment method
filipkojic Nov 21, 2024
8f30695
Add Klarna Debit Risk
filipkojic Nov 21, 2024
6f4c984
Replace Sofort with Klarna Debit Risk payment method
filipkojic Nov 22, 2024
a151729
Remove Dotpay from code
filipkojic Nov 22, 2024
24c3e7b
Add migration for Dotpay deactivation
filipkojic Nov 22, 2024
f12096d
Add Online Banking Poland payment method
filipkojic Nov 22, 2024
828eb11
Add fetching logos service for post update method
filipkojic Nov 25, 2024
556e81f
Add missing comments to different classes
filipkojic Nov 25, 2024
717ee09
Update plugin version
filipkojic Nov 25, 2024
ebdafc4
Bancontact mobile payment method resolving issue
Nov 25, 2024
ee67e7c
Fix code review issues
filipkojic Nov 25, 2024
dd52aee
Fix code review issues
filipkojic Nov 26, 2024
eafa8e5
Bancontact mobile payment method resolving issue
Nov 26, 2024
064758b
Fix code review issues
filipkojic Nov 27, 2024
4b0e584
Fix null pointer exception
filipkojic Nov 27, 2024
9f5e841
Add log for missing payment entity
filipkojic Nov 27, 2024
26f2b31
Add Klarna activation on update
filipkojic Nov 28, 2024
4a44545
Merge branch 'feature/CRSET-24-bancontact' into prepare-release
Nov 28, 2024
9002a5f
Merge branch 'fix/CS-5960' into prepare-release
Nov 28, 2024
1eb58a7
Merge branch 'fix/CS-6135' into prepare-release
Nov 28, 2024
35fd098
Fixing PHP sniffer and SonarQube issues
MarijaIv Nov 28, 2024
f80ee4a
Ignore SonarQube issue
MarijaIv Nov 28, 2024
b0b828f
Update mcr.microsoft.com/playwright Docker tag to v1.49.0
MarijaIv Nov 29, 2024
e07607c
Update mcr.microsoft.com/playwright Docker tag to v1.48.2
MarijaIv Nov 29, 2024
f6d2e89
Temporary disable e2e tests
MarijaIv Nov 29, 2024
507d0fe
Merge pull request #577 from Adyen/prepare-release
goran-stamenkovski-logeecom Nov 29, 2024
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
3 changes: 2 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
timeout-minutes: 20
strategy:
fail-fast: false
if: ${{ github.actor != 'renovate[bot]' || github.actor != 'lgtm-com[bot]' }}
# if: ${{ github.actor != 'renovate[bot]' || github.actor != 'lgtm-com[bot]' }}
if: false
# Prevent bots from initiating E2E pipeline
steps:
- name: Clone Code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
playwright:
image: mcr.microsoft.com/playwright:v1.48.0-focal
image: mcr.microsoft.com/playwright:v1.48.2-focal
networks:
- localnetwork
shm_size: 1gb
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ The plugin integrates card component (Secured Fields) using Adyen Checkout for a
- Blik
- Billie
- Clearpay
- Dotpay
- Electronic Payment Service (EPS)
- Gift cards
- GiroPay
Expand All @@ -52,6 +51,7 @@ The plugin integrates card component (Secured Fields) using Adyen Checkout for a
- Klarna Pay Later
- Klarna Pay Now
- Klarna Pay Over Time
- Klarna Debit Risk
- MB Way
- MobilePay
- Multibanco
Expand All @@ -61,13 +61,14 @@ The plugin integrates card component (Secured Fields) using Adyen Checkout for a
- PaySafeCard
- RatePay, RatePay Direct Debit
- SEPA Direct Debit
- Sofort
- Swish
- Trustly
- Twint
- Vipps
- WeChat Pay
- Open Banking / Pay by Bank
- Online Banking Finland
- Online Banking Poland

## API Library
This module is using the Adyen APIs Library for PHP for all (API) connections to Adyen.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen",
"version": "4.1.3",
"version": "4.2.0",
"type": "shopware-platform-plugin",
"license": "MIT",
"require": {
Expand Down
107 changes: 105 additions & 2 deletions src/AdyenPaymentShopware6.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use Adyen\Shopware\Entity\Notification\NotificationEntityDefinition;
use Adyen\Shopware\Entity\PaymentResponse\PaymentResponseEntityDefinition;
use Adyen\Shopware\Entity\PaymentStateData\PaymentStateDataEntityDefinition;
use Adyen\Shopware\Handlers\KlarnaDebitRiskPaymentMethodHandler;
use Adyen\Shopware\PaymentMethods\KlarnaDebitRiskPaymentMethod;
use Adyen\Shopware\Service\ConfigurationService;
use Shopware\Core\Checkout\Payment\PaymentMethodEntity;
use Shopware\Core\Framework\Plugin;
Expand All @@ -47,6 +49,8 @@

class AdyenPaymentShopware6 extends Plugin
{
public const SOFORT = 'Adyen\Shopware\Handlers\SofortPaymentMethodHandler';

public function install(InstallContext $installContext): void
{
foreach (PaymentMethods\PaymentMethods::PAYMENT_METHODS as $paymentMethod) {
Expand Down Expand Up @@ -134,6 +138,19 @@ public function update(UpdateContext $updateContext): void
if (\version_compare($currentVersion, '4.1.0', '<')) {
$this->updateTo410($updateContext);
}

if (\version_compare($currentVersion, '4.2.0', '<')) {
$this->updateTo420($updateContext);
}
}

public function postUpdate(UpdateContext $updateContext): void
{
$currentVersion = $updateContext->getCurrentPluginVersion();
if (\version_compare($currentVersion, '4.2.0', '<')) {
$handler = $this->container->get("Adyen\Shopware\Service\FetchLogosService");
$handler->getHandler()->run();
}
}

private function addPaymentMethod(PaymentMethods\PaymentMethodInterface $paymentMethod, Context $context): void
Expand All @@ -144,6 +161,31 @@ private function addPaymentMethod(PaymentMethods\PaymentMethodInterface $payment
$pluginIdProvider = $this->container->get(PluginIdProvider::class);
$pluginId = $pluginIdProvider->getPluginIdByBaseClass(get_class($this), $context);

/** @var EntityRepository $paymentRepository */
$paymentRepository = $this->container->get('payment_method.repository');

// Rename if Klarna Debit Risk doesnt exist from previous installations
if ($paymentMethod->getPaymentHandler() === KlarnaDebitRiskPaymentMethodHandler::class
&& $paymentMethodId === null) {
$sofortMethodId = $this->getPaymentMethodId(self::SOFORT);

if ($sofortMethodId) {
// update Sofort to Klarna Debit Risk
$method = new PaymentMethods\KlarnaDebitRiskPaymentMethod();

$paymentMethodData = [
'id' => $sofortMethodId,
'handlerIdentifier' => $method->getPaymentHandler(),
'name' => $method->getName(),
'description' => $method->getDescription(),
];

$paymentRepository->update([$paymentMethodData], $context);

return;
}
}

// Payment method exists already, set the pluginId
if ($paymentMethodId) {
$this->setPluginId($paymentMethodId, $pluginId, $context);
Expand All @@ -158,8 +200,6 @@ private function addPaymentMethod(PaymentMethods\PaymentMethodInterface $payment
'afterOrderEnabled' => true
];

/** @var EntityRepository $paymentRepository */
$paymentRepository = $this->container->get('payment_method.repository');
$paymentRepository->create([$paymentData], $context);
}

Expand Down Expand Up @@ -481,6 +521,69 @@ private function updateTo410(UpdateContext $updateContext): void
);
}

private function updateTo420(UpdateContext $updateContext): void
{
// Version 4.2.0 introduces Online Banking Finland and Online Banking Poland
$paymentMethods = [
new PaymentMethods\OnlineBankingFinlandPaymentMethod(),
new PaymentMethods\OnlineBankingPolandPaymentMethod(),
];

foreach ($paymentMethods as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
);

$this->setPaymentMethodIsActive(
true,
$updateContext->getContext(),
$method
);
}

// Version 4.2.0 removes Dotpay
$paymentMethodHandler = 'Adyen\Shopware\Handlers\DotpayPaymentMethodHandler';
$this->deactivateAndRemovePaymentMethod($updateContext, $paymentMethodHandler);

// Version 4.2.0 replaces Sofort with Klarna Debit Risk
$paymentRepository = $this->container->get('payment_method.repository');
$paymentMethodId = $this->getPaymentMethodId(self::SOFORT);
$klarnaDebitRisktMethodId = $this->getPaymentMethodId(
'Adyen\Shopware\Handlers\KlarnaDebitRiskPaymentMethodHandler'
);

// If Sofort does not exist, return
if (!$paymentMethodId) {
return;
}

if ($klarnaDebitRisktMethodId !== null) {
// Klarna Debit Risk exists, deactivate Sofort and skip renaming
$this->deactivateAndRemovePaymentMethod($updateContext, self::SOFORT);
// activate Klarna Debit Risk
$this->setPaymentMethodIsActive(
true,
$updateContext->getContext(),
new PaymentMethods\KlarnaDebitRiskPaymentMethod()
);

return;
}

// Update Sofort to Klarna Debit Risk
$method = new PaymentMethods\KlarnaDebitRiskPaymentMethod();

$paymentMethodData = [
'id' => $paymentMethodId,
'handlerIdentifier' => $method->getPaymentHandler(),
'name' => $method->getName(),
'description' => $method->getDescription(),
];

$paymentRepository->update([$paymentMethodData], $updateContext->getContext());
}

/**
* @param UpdateContext $updateContext
* @param string $paymentMethodHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@

namespace Adyen\Shopware\Core\Checkout\Order\Aggregate\OrderTransaction;

use Adyen\Shopware\Entity\AdyenPayment\AdyenPaymentEntityDefinition;
use Adyen\Shopware\Entity\PaymentCapture\PaymentCaptureEntityDefinition;
use Adyen\Shopware\Entity\PaymentResponse\PaymentResponseEntityDefinition;
use Adyen\Shopware\Entity\Refund\RefundEntityDefinition;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Framework\Api\Context\SalesChannelApiSource;
use Shopware\Core\Framework\DataAbstractionLayer\EntityExtension;
Expand All @@ -49,14 +52,47 @@ public function extendFields(FieldCollection $collection): void
'order_transaction_id'
);

$refundField = new OneToManyAssociationField(
'adyenRefund',
RefundEntityDefinition::class,
'order_transaction_id'
);

$captureField = new OneToManyAssociationField(
'adyenCapture',
PaymentCaptureEntityDefinition::class,
'order_transaction_id'
);

$paymentField = new OneToManyAssociationField(
'adyenPayment',
AdyenPaymentEntityDefinition::class,
'order_transaction_id'
);

// Ensure the data is not available via the Store API in older Shopware versions.
if (!class_exists(ApiAware::class) &&
class_exists(Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected::class)) {
$field->addFlags(
new Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected(SalesChannelApiSource::class)
);

$refundField->addFlags(
new Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected(SalesChannelApiSource::class)
);

$captureField->addFlags(
new Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected(SalesChannelApiSource::class)
);

$paymentField->addFlags(
new Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected(SalesChannelApiSource::class)
);
}

$collection->add($field);
$collection->add($refundField);
$collection->add($captureField);
$collection->add($paymentField);
}
}
24 changes: 23 additions & 1 deletion src/Entity/AdyenPayment/AdyenPaymentEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace Adyen\Shopware\Entity\AdyenPayment;

use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity;
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;

Expand Down Expand Up @@ -96,6 +97,11 @@ class AdyenPaymentEntity extends Entity
*/
protected $updatedAt;

/**
* @var OrderTransactionEntity
*/
protected OrderTransactionEntity $orderTransaction;

/**
* @return string
*/
Expand Down Expand Up @@ -171,7 +177,7 @@ public function getOrderTransactionId(): string
/**
* @param int $orderTransactionId
*/
public function setEventCode(int $orderTransactionId): void
public function setOrderTransactionId(int $orderTransactionId): void
{
$this->orderTransactionId = $orderTransactionId;
}
Expand Down Expand Up @@ -279,4 +285,20 @@ public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}

/**
* @return OrderTransactionEntity
*/
public function getOrderTransaction(): OrderTransactionEntity
{
return $this->orderTransaction;
}

/**
* @param OrderTransactionEntity $orderTransaction
*/
public function setOrderTransaction(OrderTransactionEntity $orderTransaction): void
{
$this->orderTransaction = $orderTransaction;
}
}
8 changes: 1 addition & 7 deletions src/Entity/AdyenPayment/AdyenPaymentEntityDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@

use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\LongTextField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IntField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\DateTimeField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\UpdatedAtField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
Expand Down Expand Up @@ -65,11 +63,7 @@ protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()),
(new FkField(
'order_transaction_id',
'orderTransactionId',
OrderTransactionDefinition::class
))->addFlags(new Required()),
new IdField('order_transaction_id', 'orderTransactionId'),
new StringField('pspreference', 'pspreference'),
new StringField('original_reference', 'originalReference'),
new StringField('merchant_reference', 'merchantReference'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
Expand Down Expand Up @@ -58,11 +57,7 @@ protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()),
(new FkField(
'order_transaction_id',
'orderTransactionId',
OrderTransactionDefinition::class
))->addFlags(new Required()),
new IdField('order_transaction_id', 'orderTransactionId'),
new StringField('psp_reference', 'pspReference'),
(new IntField('amount', 'amount'))->addFlags(new Required()),
(new StringField('source', 'source'))->addFlags(new Required()),
Expand Down
Loading
Loading