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

Prepare release 3.17.0 #575

Merged
merged 31 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ee350e5
Merge pull request #563 from Adyen/develop-3
goran-stamenkovski-logeecom Oct 1, 2024
b7865db
Merge pull request #568 from Adyen/develop-3
goran-stamenkovski-logeecom Oct 15, 2024
586a4eb
Fix notification processing when merchantReference is missing
MarijaIv Oct 16, 2024
4e533f9
first commit
filipkojic Nov 18, 2024
613fc6a
Add Online Banking Finland payment method
filipkojic Nov 19, 2024
a90b2b1
Change Sofort data to Klarna Debit Risk data in database
filipkojic Nov 20, 2024
793ba74
Remove Dotpay payment method
filipkojic Nov 20, 2024
4ddea9f
Fix dal validation errors
AleksandarBoljanovic Nov 21, 2024
fd632ff
Add Online Banking Poland payment method
filipkojic Nov 21, 2024
4abea2a
Bancontact mobile payment method resolving issue
Nov 21, 2024
da2b35a
Bancontact mobile payment method resolving issue
Nov 22, 2024
5822cb9
Add fetching logos service for post update method
filipkojic Nov 25, 2024
66b7fc2
Add missing comments to different classes
filipkojic Nov 25, 2024
1abca11
Update plugin version
filipkojic Nov 25, 2024
90cb29c
Fix code review issues
filipkojic Nov 25, 2024
3125273
Fix code review issues
filipkojic Nov 26, 2024
0a7d4e1
Bancontact mobile payment method resolving issue
Nov 26, 2024
b49ed35
Fix code review issues
filipkojic Nov 27, 2024
9680ed1
Fix code review issues
filipkojic Nov 27, 2024
178e68d
Fix code review issues
filipkojic Nov 27, 2024
2f26dad
Fix code review issues
filipkojic Nov 27, 2024
b433a9c
Fix null pointer exception
filipkojic Nov 27, 2024
fca647f
Add log for missing payment entity
filipkojic Nov 27, 2024
6aff676
Merge remote-tracking branch 'origin/fix/main-3/CR-SET21' into develop-3
MarijaIv Nov 28, 2024
323ff5e
Merge remote-tracking branch 'origin/fix/dev-3-CS-5960' into develop-3
MarijaIv Nov 28, 2024
6ba3b97
Merge remote-tracking branch 'origin/fix/develop-3/CS-6135' into deve…
MarijaIv Nov 28, 2024
95b557e
Fixing PHP sniffer and SonarQube issues
MarijaIv Nov 28, 2024
13d3d2e
Fixing PHP sniffer issue
MarijaIv Nov 28, 2024
cb7cc6f
Ignore SonarQube issue
MarijaIv Nov 28, 2024
0b873c9
Ignore SonarQube issue
MarijaIv Nov 28, 2024
a0945e0
Temporary disable e2e tests
MarijaIv 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
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": "3.16.3",
"version": "3.17.0",
"type": "shopware-platform-plugin",
"license": "MIT",
"require": {
Expand Down
170 changes: 131 additions & 39 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 Down Expand Up @@ -174,6 +176,19 @@ public function update(UpdateContext $updateContext): void
if (\version_compare($currentVersion, '3.16.0', '<')) {
$this->updateTo3160($updateContext);
}

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

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

private function addPaymentMethod(PaymentMethods\PaymentMethodInterface $paymentMethod, Context $context): void
Expand All @@ -184,6 +199,30 @@ 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('Adyen\Shopware\Handlers\SofortPaymentMethodHandler');

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 @@ -198,8 +237,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 @@ -320,11 +357,11 @@ private function updateTo160(UpdateContext $updateContext): void
{
//Version 1.6.0 introduces applepay, paywithgoogle, dotpay and bancontact
foreach ([
new PaymentMethods\ApplePayPaymentMethod,
new PaymentMethods\GooglePayPaymentMethod,
new PaymentMethods\DotpayPaymentMethod,
new PaymentMethods\BancontactCardPaymentMethod
] as $method) {
new PaymentMethods\ApplePayPaymentMethod,
new PaymentMethods\GooglePayPaymentMethod,
new PaymentMethods\DotpayPaymentMethod,
new PaymentMethods\BancontactCardPaymentMethod
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand All @@ -341,9 +378,9 @@ private function updateTo200(UpdateContext $updateContext): void
{
//Version 2.0.0 introduces amazonpay, blik
foreach ([
new PaymentMethods\AmazonPayPaymentMethod,
new PaymentMethods\BlikPaymentMethod,
] as $method) {
new PaymentMethods\AmazonPayPaymentMethod,
new PaymentMethods\BlikPaymentMethod,
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand All @@ -360,23 +397,23 @@ private function updateTo300(UpdateContext $updateContext): void
{
//Version 3.0.0 introduces the following payment methods
foreach ([
new PaymentMethods\AfterpayDefaultPaymentMethod,
new PaymentMethods\AlipayPaymentMethod,
new PaymentMethods\AlipayHkPaymentMethod,
new PaymentMethods\ClearpayPaymentMethod,
new PaymentMethods\EpsPaymentMethod,
new PaymentMethods\Facilypay3xPaymentMethod,
new PaymentMethods\Facilypay4xPaymentMethod,
new PaymentMethods\Facilypay6xPaymentMethod,
new PaymentMethods\Facilypay10xPaymentMethod,
new PaymentMethods\Facilypay12xPaymentMethod,
new PaymentMethods\PaysafecardPaymentMethod,
new PaymentMethods\RatepayPaymentMethod,
new PaymentMethods\RatepayDirectdebitPaymentMethod,
new PaymentMethods\SwishPaymentMethod,
new PaymentMethods\TrustlyPaymentMethod,
new PaymentMethods\TwintPaymentMethod,
] as $method) {
new PaymentMethods\AfterpayDefaultPaymentMethod,
new PaymentMethods\AlipayPaymentMethod,
new PaymentMethods\AlipayHkPaymentMethod,
new PaymentMethods\ClearpayPaymentMethod,
new PaymentMethods\EpsPaymentMethod,
new PaymentMethods\Facilypay3xPaymentMethod,
new PaymentMethods\Facilypay4xPaymentMethod,
new PaymentMethods\Facilypay6xPaymentMethod,
new PaymentMethods\Facilypay10xPaymentMethod,
new PaymentMethods\Facilypay12xPaymentMethod,
new PaymentMethods\PaysafecardPaymentMethod,
new PaymentMethods\RatepayPaymentMethod,
new PaymentMethods\RatepayDirectdebitPaymentMethod,
new PaymentMethods\SwishPaymentMethod,
new PaymentMethods\TrustlyPaymentMethod,
new PaymentMethods\TwintPaymentMethod,
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand Down Expand Up @@ -426,15 +463,15 @@ private function updateTo370(UpdateContext $updateContext): void
* MB Way, Multibanco, WeChat Pay, MobilePay, Vipps, Affirm & PayBright
*/
foreach ([
new PaymentMethods\MbwayPaymentMethod(),
new PaymentMethods\MultibancoPaymentMethod(),
new PaymentMethods\WechatpayqrPaymentMethod(),
new PaymentMethods\WechatpaywebPaymentMethod(),
new PaymentMethods\MobilePayPaymentMethod(),
new PaymentMethods\VippsPaymentMethod(),
new PaymentMethods\AffirmPaymentMethod(),
new PaymentMethods\PayBrightPaymentMethod()
] as $method) {
new PaymentMethods\MbwayPaymentMethod(),
new PaymentMethods\MultibancoPaymentMethod(),
new PaymentMethods\WechatpayqrPaymentMethod(),
new PaymentMethods\WechatpaywebPaymentMethod(),
new PaymentMethods\MobilePayPaymentMethod(),
new PaymentMethods\VippsPaymentMethod(),
new PaymentMethods\AffirmPaymentMethod(),
new PaymentMethods\PayBrightPaymentMethod()
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand All @@ -454,8 +491,8 @@ private function updateTo3100(UpdateContext $updateContext): void
* Open Banking / Pay by Bank
*/
foreach ([
new PaymentMethods\OpenBankingPaymentMethod(),
] as $method) {
new PaymentMethods\OpenBankingPaymentMethod(),
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand Down Expand Up @@ -521,6 +558,61 @@ private function updateTo3160(UpdateContext $updateContext): void
);
}

private function updateTo3170(UpdateContext $updateContext): void
{
// Version 3.17.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 3.17.0 removes Dotpay
$paymentMethodHandler = 'Adyen\Shopware\Handlers\DotpayPaymentMethodHandler';
$this->deactivateAndRemovePaymentMethod($updateContext, $paymentMethodHandler);

// Version 3.17.0 replaces Sofort with Klarna Debit Risk
$paymentRepository = $this->container->get('payment_method.repository');
$paymentMethodId = $this->getPaymentMethodId('Adyen\Shopware\Handlers\SofortPaymentMethodHandler');
$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, 'Adyen\Shopware\Handlers\SofortPaymentMethodHandler');

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());
}

private function safeCopyAsset($source, $destination): bool
{
try {
Expand Down Expand Up @@ -588,4 +680,4 @@ private function deactivateAndRemovePaymentMethod(

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
}
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;
}
}
Loading
Loading