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 3.17.1 #583

Merged
merged 30 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d0b4c27
Update supported version
MarijaIv Nov 29, 2024
e1beaef
Ratepay payment method resolving issue
Nov 29, 2024
c84ff7a
Ratepay payment method resolving issue
Dec 2, 2024
16fecd4
Ratepay payment method resolving issue
Dec 2, 2024
5ebe70b
Add form fields for Billie
filipkojic Dec 2, 2024
5c0876f
Pass company name to frontend in subscriber method
filipkojic Dec 2, 2024
78abbdb
Ratepay payment method resolving issue
Dec 2, 2024
50ee327
Implement Billie payment method
filipkojic Dec 3, 2024
b8e06c3
Fix reinstallation flow
filipkojic Dec 4, 2024
6c07fdc
Fix reinstallation flow by deleting all plugin tables
filipkojic Dec 4, 2024
90af629
Merge remote-tracking branch 'origin/main-3' into prepare-release-3
Dec 4, 2024
d79ffdd
Merge remote-tracking branch 'origin/feature/develop-3-CRSET24-ratepa…
Dec 4, 2024
65c4d9c
Change redirect url for Billie payment method
Dec 4, 2024
03b18a0
Add required fields and messages
filipkojic Dec 4, 2024
bd49d8e
Fix label for fields
filipkojic Dec 4, 2024
29c6bf7
Revert "Change redirect url for Billie payment method"
Dec 4, 2024
baf4c2a
Merge branch 'fix/main-3/CR-24-1' into prepare-release-3
Dec 4, 2024
4ae5ed2
Fix Bancontact mobile behavior
Dec 4, 2024
c4b4fad
Merge branch 'fix/develop-3-bancontact-mobile' into prepare-release-3
Dec 4, 2024
89b4bd4
Fixing PHP code sniffer issues
Dec 5, 2024
90b9ee9
Build storefront js
filipkojic Dec 5, 2024
474af70
Add support to Shopware 6.4.* versions
Dec 5, 2024
fe671a7
Version bump
Dec 5, 2024
b6e6581
Add support to Shopware 6.4.* versions
Dec 5, 2024
203ed24
Fix the issue with no web components on the checkout
Dec 5, 2024
5b45ece
Merge branch 'fix/main-3/CS-6247' into prepare-release-3
Dec 6, 2024
56273bf
Add scripts for deleting installed.php to composer.json
filipkojic Dec 6, 2024
698d218
Merge branch 'fix/main-3/CS-6204' into prepare-release-3
Dec 9, 2024
efc1045
Ignore SonarQube issues
Dec 9, 2024
41e80d5
Merge pull request #581 from Adyen/prepare-release-3
goran-stamenkovski-logeecom Dec 9, 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
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
}
],
"description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen",
"version": "3.17.0",
"version": "3.17.1",
"type": "shopware-platform-plugin",
"license": "MIT",
"require": {
"shopware/core": "~6.4.0 || ~6.5.0",
"shopware/storefront": "~6.4.0 || ~6.5.0",
"shopware/core": "~6.4.11 || ~6.5.0",
"shopware/storefront": "~6.4.11 || ~6.5.0",
"adyen/php-api-library": "^17.5.0",
"adyen/php-webhook-module": "0.8.0",
"ext-json": "*"
Expand Down Expand Up @@ -48,5 +48,13 @@
"allow-plugins": {
"symfony/*": true
}
},
"scripts": {
"post-install-cmd": [
"rm -f vendor/composer/installed.php"
],
"post-update-cmd": [
"rm -f vendor/composer/installed.php"
]
}
}
8 changes: 7 additions & 1 deletion src/AdyenPaymentShopware6.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@

namespace Adyen\Shopware;

use Adyen\Shopware\Entity\AdyenPayment\AdyenPaymentEntityDefinition;
use Adyen\Shopware\Entity\Notification\NotificationEntityDefinition;
use Adyen\Shopware\Entity\PaymentCapture\PaymentCaptureEntityDefinition;
use Adyen\Shopware\Entity\PaymentResponse\PaymentResponseEntityDefinition;
use Adyen\Shopware\Entity\PaymentStateData\PaymentStateDataEntityDefinition;
use Adyen\Shopware\Entity\Refund\RefundEntityDefinition;
use Adyen\Shopware\Handlers\KlarnaDebitRiskPaymentMethodHandler;
use Adyen\Shopware\PaymentMethods\KlarnaDebitRiskPaymentMethod;
use Adyen\Shopware\Service\ConfigurationService;
Expand Down Expand Up @@ -318,7 +321,10 @@ private function removePluginData()
$tables = [
NotificationEntityDefinition::ENTITY_NAME,
PaymentStateDataEntityDefinition::ENTITY_NAME,
PaymentResponseEntityDefinition::ENTITY_NAME
PaymentResponseEntityDefinition::ENTITY_NAME,
AdyenPaymentEntityDefinition::ENTITY_NAME,
PaymentCaptureEntityDefinition::ENTITY_NAME,
RefundEntityDefinition::ENTITY_NAME
];
$connection = $this->container->get(Connection::class);
foreach ($tables as $table) {
Expand Down
68 changes: 60 additions & 8 deletions src/Handlers/AbstractPaymentMethodHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@
use Adyen\AdyenException;
use Adyen\Client;
use Adyen\Model\Checkout\CheckoutPaymentMethod;
use Adyen\Model\Checkout\Company;
use Adyen\Model\Checkout\EncryptedOrderData;
use Adyen\Model\Checkout\LineItem;
use Adyen\Model\Checkout\PaymentRequest;
use Adyen\Shopware\Models\PaymentRequest as IntegrationPaymentRequest;
use Adyen\Model\Checkout\Address;
use Adyen\Model\Checkout\Amount;
use Adyen\Model\Checkout\BrowserInfo;
use Adyen\Model\Checkout\Name;
use Adyen\Model\Checkout\PaymentResponse;
use Adyen\Service\Checkout\PaymentsApi;
use Adyen\Shopware\PaymentMethods\RatepayDirectdebitPaymentMethod;
use Adyen\Shopware\PaymentMethods\RatepayPaymentMethod;
use Adyen\Shopware\Util\CheckoutStateDataValidator;
use Adyen\Shopware\Exception\PaymentCancelledException;
use Adyen\Shopware\Exception\PaymentFailedException;
Expand All @@ -46,6 +49,7 @@
use Adyen\Shopware\Service\PaymentStateDataService;
use Adyen\Shopware\Service\Repository\SalesChannelRepository;
use Adyen\Shopware\Util\Currency;
use Adyen\Shopware\Util\RatePayDeviceFingerprintParamsProvider;
use Psr\Log\LoggerInterface;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStateHandler;
use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct;
Expand Down Expand Up @@ -112,6 +116,11 @@ abstract class AbstractPaymentMethodHandler implements AsynchronousPaymentHandle
*/
protected $checkoutStateDataValidator;

/**
* @var RatePayDeviceFingerprintParamsProvider
*/
protected $ratePayFingerprintParamsProvider;

/**
* @var PaymentStateDataService
*/
Expand Down Expand Up @@ -203,6 +212,7 @@ public function __construct(
ClientService $clientService,
Currency $currency,
CheckoutStateDataValidator $checkoutStateDataValidator,
RatePayDeviceFingerprintParamsProvider $ratePayFingerprintParamsProvider,
PaymentStateDataService $paymentStateDataService,
SalesChannelRepository $salesChannelRepository,
PaymentResponseHandler $paymentResponseHandler,
Expand All @@ -220,6 +230,7 @@ public function __construct(
$this->currency = $currency;
$this->configurationService = $configurationService;
$this->checkoutStateDataValidator = $checkoutStateDataValidator;
$this->ratePayFingerprintParamsProvider = $ratePayFingerprintParamsProvider;
$this->paymentStateDataService = $paymentStateDataService;
$this->salesChannelRepository = $salesChannelRepository;
$this->paymentResponseHandler = $paymentResponseHandler;
Expand Down Expand Up @@ -280,6 +291,14 @@ public function pay(
*/
$stateData = $requestStateData ?? $storedStateData ?? [];

$companyName = $dataBag->get('companyName');
$registrationNumber = $dataBag->get('registrationNumber');

$billieData = [
'companyName' => $companyName,
'registrationNumber' => $registrationNumber,
];

/*
* If there are more than one stateData and /payments calls have been completed,
* check the remaining order amount for final /payments call.
Expand All @@ -292,14 +311,22 @@ public function pay(
$transaction,
$stateData,
$this->remainingAmount,
$this->orderRequestData
$this->orderRequestData,
$billieData
);
//make /payments call
$this->paymentsCall($salesChannelContext, $request, $transaction);
//Remove all state data if stored or from giftcard
if ($storedStateData) {
$this->paymentStateDataService->deletePaymentStateDataFromId($storedStateData['id']);
}

$paymentMethodType = $stateData['paymentMethod']['type'];
if ($paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE ||
$paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE
) {
$this->ratePayFingerprintParamsProvider->clear();
}
}

$orderNumber = $transaction->getOrder()->getOrderNumber();
Expand Down Expand Up @@ -349,7 +376,11 @@ private function getReturnUrl(AsyncPaymentTransactionStruct $transaction): strin

return $this->symfonyRouter->generate(
'payment.adyen.proxy-finalize-transaction',
['_sw_payment_token' => $token, 'orderId' => $transaction->getOrder()->getId()],
[
'_sw_payment_token' => $token,
'orderId' => $transaction->getOrder()->getId(),
'transactionId' => $transaction->getOrderTransaction()->getId()
],
UrlGeneratorInterface::ABSOLUTE_URL
);
}
Expand Down Expand Up @@ -393,17 +424,17 @@ public function finalize(
* @param array $request
* @param int|null $partialAmount
* @param array|null $adyenOrderData
* @return PaymentRequest
* @return IntegrationPaymentRequest
*/
protected function preparePaymentsRequest(
SalesChannelContext $salesChannelContext,
AsyncPaymentTransactionStruct $transaction,
array $request = [],
?int $partialAmount = null,
?array $adyenOrderData = []
): PaymentRequest {
): IntegrationPaymentRequest {

$paymentRequest = new PaymentRequest($request);
$paymentRequest = new IntegrationPaymentRequest($request);

if (!empty($request['additionalData'])) {
$stateDataAdditionalData = $request['additionalData'];
Expand Down Expand Up @@ -587,6 +618,19 @@ protected function preparePaymentsRequest(
$paymentRequest->setShopperIP($shopperIp);
$paymentRequest->setShopperReference($shopperReference);

if (!empty($request['billieData'])) {
$billieData = $request['billieData'];

$companyName = $billieData['companyName'] ?? '';
$registrationNumber = $billieData['registrationNumber'] ?? '';

$company = new Company();
$company
->setRegistrationNumber($registrationNumber)
->setName($companyName);
$paymentRequest->setCompany($company);
}

//Building payment data
$amount = $partialAmount ?: $this->currency->sanitize(
$transaction->getOrder()->getPrice()->getTotalPrice(),
Expand All @@ -602,6 +646,12 @@ protected function preparePaymentsRequest(
$paymentRequest->setMerchantAccount(
$this->configurationService->getMerchantAccount($salesChannelContext->getSalesChannel()->getId())
);
if ($paymentMethodType === RatepayPaymentMethod::RATEPAY_PAYMENT_METHOD_TYPE ||
$paymentMethodType === RatepayDirectdebitPaymentMethod::RATEPAY_DIRECTDEBIT_PAYMENT_METHOD_TYPE
) {
$paymentRequest->setDeviceFingerprint($this->ratePayFingerprintParamsProvider->getToken());
}

if ($paymentMethodType === 'bcmc_mobile') {
$paymentRequest->setReturnUrl($this->getReturnUrl($transaction));
} else {
Expand Down Expand Up @@ -719,9 +769,11 @@ private function getPaymentRequest(
$transaction,
$stateData,
$partialAmount,
$orderRequestData
$orderRequestData,
$billieData = []
) {
$transactionId = $transaction->getOrderTransaction()->getId();
$stateData['billieData'] = $billieData;
try {
$request = $this->preparePaymentsRequest(
$salesChannelContext,
Expand All @@ -747,7 +799,7 @@ private function getPaymentRequest(

private function paymentsCall(
SalesChannelContext $salesChannelContext,
PaymentRequest $request,
IntegrationPaymentRequest $request,
AsyncPaymentTransactionStruct $transaction
): void {
$transactionId = $transaction->getOrderTransaction()->getId();
Expand Down
13 changes: 9 additions & 4 deletions src/Handlers/ResultHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,15 @@ public function processResult(
}

$result = $this->paymentResponseHandlerResult->createFromPaymentResponse($paymentResponse);

if ('RedirectShopper' === $result->getResultCode()) {
$requestResponse = $request->getMethod() === 'GET' ? $request->query->all() : $request->request->all();

$requestResponse = $request->getMethod() === 'GET' ? $request->query->all() : $request->request->all();

if ('RedirectShopper' === $result->getResultCode() ||
(
$salesChannelContext->getPaymentMethod()->getFormattedHandlerIdentifier() ===
'handler_adyen_bancontactmobilepaymentmethodhandler' &&
$requestResponse['redirectResult']
)
) {
$details = DataArrayValidator::getArrayOnlyWithApprovedKeys($requestResponse, [
self::PA_RES,
self::MD,
Expand Down
Loading
Loading