Skip to content

Commit 32ede81

Browse files
Merge branch 'main-4' into feature-4/CR-SET-45
2 parents 589c2b8 + 6b99f92 commit 32ede81

8 files changed

Lines changed: 66 additions & 21 deletions

File tree

.github/workflows/e2e/adyen-integration-tools-tests/projects/common/redirect/KlarnaPaymentPage.js

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,36 @@ export default class KlarnaPaymentPage {
99
this.closeButton = page.getByLabel('Close');
1010
this.confirmAndPayButton = page.getByTestId('confirm-and-pay');
1111

12-
this.chooseHowToPayDialog = page.getByRole('dialog', {
13-
name: /choose how to pay/i,
14-
});
15-
this.cardRadioOption = page.getByRole('radio', { name: /^card/i });
16-
this.continueButton = page.getByRole('button', { name: /^continue$/i });
12+
this.offersSelectorDialog = page.locator('#offers-selector-dialog');
13+
this.payInFullRadioOption = this.offersSelectorDialog
14+
.getByRole('radio', { name: /^pay in full/i })
15+
.first();
16+
this.offersSelectorContinueButton = page.getByTestId(
17+
'offers-selector-continue-button'
18+
);
19+
20+
this.payNowSelectorDialog = page.locator(
21+
'#offers-selector-pay-now-selector-dialog'
22+
);
23+
this.cardRadioOption = this.payNowSelectorDialog
24+
.getByRole('radio', { name: /^card/i })
25+
.first();
26+
this.payNowSelectorContinueButton = page.getByTestId(
27+
'offers-selector-pay-now-selector-continue-button'
28+
);
29+
30+
this.threeDsSubmitButton = page
31+
.getByRole('dialog')
32+
.filter({ has: page.locator('iframe') })
33+
.frameLocator('iframe')
34+
.getByRole('button', { name: /^submit$/i });
1735
}
1836

19-
async makeKlarnaPayment(phoneNumber, paynow = false) {
37+
async makeKlarnaPayment(
38+
phoneNumber,
39+
paynow = false,
40+
threeDsChallenge = paynow
41+
) {
2042
await this.waitForKlarnaLoad();
2143
await this.phoneNumberVerificationDialog.waitFor({ state: 'attached' });
2244
await this.genericInputField.click();
@@ -27,13 +49,20 @@ export default class KlarnaPaymentPage {
2749
await this.genericInputField.fill('111111');
2850

2951
if (paynow) {
30-
await this.chooseHowToPayDialog.waitFor({ state: 'visible' });
52+
await this.offersSelectorDialog.waitFor({ state: 'visible' });
53+
await this.payInFullRadioOption.click();
54+
await this.offersSelectorContinueButton.click();
55+
await this.payNowSelectorDialog.waitFor({ state: 'visible' });
3156
await this.cardRadioOption.click();
32-
await this.continueButton.click();
57+
await this.payNowSelectorContinueButton.click();
3358
}
3459

3560
await this.confirmAndPayButton.waitFor({ state: 'visible' });
3661
await this.confirmAndPayButton.click();
62+
63+
if (threeDsChallenge) {
64+
await this.threeDsSubmitButton.click();
65+
}
3766
}
3867

3968
async cancelKlarnaPayment() {

.github/workflows/e2e/adyen-integration-tools-tests/projects/data/PaymentResources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export default class PaymentResources {
189189
countryCode: "NL",
190190
countryName: "Netherlands",
191191
stateCode: "NH",
192-
phoneNumber: "0612345678",
192+
phoneNumber: "+31689124321",
193193
dateOfBirth: "10071970",
194194
gender: "M",
195195
},

.github/workflows/e2e/adyen-integration-tools-tests/projects/shopware/pageObjects/plugin/Result.page.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ export class ResultPage extends SPRBasePage {
1313
return (await this.pageHeader.innerText());
1414
}
1515

16-
async waitForRedirection() {
17-
await this.page.waitForNavigation({
18-
url: / *\/checkout\/finish/,
19-
timeout: 20000,
16+
async waitForRedirection({ timeout = 20000 } = {}) {
17+
await this.page.waitForURL(/\/checkout\/finish/, {
18+
timeout,
2019
});
2120
}
2221
}

.github/workflows/e2e/adyen-integration-tools-tests/projects/shopware/tests/KlarnaPayment.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test.describe.parallel("Payment via Klarna", () => {
4949

5050
test("Pay Klarna Pay Over Time should succeed", async ({ page }) => {
5151
const klarnaPaymentPage = await proceedToKlarnaPayOverTime(page);
52-
await klarnaPaymentPage.makeKlarnaPayment(user.phoneNumber, false);
52+
await klarnaPaymentPage.makeKlarnaPayment(user.phoneNumber, false, true);
5353
await verifySuccessfulPayment(page);
5454
});
5555

.github/workflows/templates/docker-compose.playwright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3'
22

33
services:
44
playwright:
5-
image: mcr.microsoft.com/playwright:v1.62.1-noble
5+
image: mcr.microsoft.com/playwright:v1.63.0-noble
66
networks:
77
- localnetwork
88
shm_size: 1gb

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77
],
88
"description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen",
9-
"version": "4.6.6",
9+
"version": "4.6.7",
1010
"type": "shopware-platform-plugin",
1111
"license": "MIT",
1212
"require": {

src/Handlers/AbstractPaymentMethodHandler.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,13 @@ public function pay(
299299
}
300300
$countStoredStateData = $this->paymentStateDataService->countStoredStateData($salesChannelContext);
301301
$countStateData += $countStoredStateData;
302-
//If condition to check more than 1 PM
303-
if ($countStateData > 1 || ($countStateData === 1 && static::getPaymentMethodCode() !== 'giftcard')) {
302+
/*
303+
* An Adyen order is only required when the payment is split into multiple /payments calls,
304+
* which can only happen if at least one giftcard has been redeemed.
305+
*/
306+
if ($countStoredStateData > 0 &&
307+
($countStateData > 1 || static::getPaymentMethodCode() !== 'giftcard')
308+
) {
304309
$adyenOrderResponse = $this->createAdyenOrder($salesChannelContext, $transaction);
305310
$this->handleAdyenOrderPayment($transaction, $adyenOrderResponse, $salesChannelContext);
306311
}

src/Service/NotificationService.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function isDuplicateNotification(array $notification): bool
7575
if (!empty($notification['pspReference'])) {
7676
$filters[] = new EqualsFilter('pspreference', $notification['pspReference']);
7777
}
78-
if (!empty($notification['success'])) {
79-
$filters[] = new EqualsFilter('success', $notification['success']);
78+
if (isset($notification['success'])) {
79+
$filters[] = new EqualsFilter('success', $this->isSuccessful($notification['success']));
8080
}
8181
if (!empty($notification['eventCode'])) {
8282
$filters[] = new EqualsFilter('eventCode', $notification['eventCode']);
@@ -113,7 +113,7 @@ public function insertNotification(array $notification): void
113113
$fields['eventCode'] = $notification['eventCode'];
114114
}
115115
if (isset($notification['success'])) {
116-
$fields['success'] = "true" === $notification['success'];
116+
$fields['success'] = $this->isSuccessful($notification['success']);
117117
}
118118
if (isset($notification['paymentMethod'])) {
119119
$fields['paymentMethod'] = $notification['paymentMethod'];
@@ -372,4 +372,16 @@ public function canBeRescheduled(NotificationEntity $notification): bool
372372

373373
return false;
374374
}
375+
376+
/**
377+
* Normalises the success flag of a notification.
378+
*
379+
* @param mixed $success
380+
*
381+
* @return bool
382+
*/
383+
private function isSuccessful(mixed $success): bool
384+
{
385+
return true === $success || 'true' === $success;
386+
}
375387
}

0 commit comments

Comments
 (0)