From 45bfa77bab1006af4d110278f0ba24e580511d27 Mon Sep 17 00:00:00 2001 From: Michel Bade Date: Thu, 19 Dec 2024 15:50:24 +0100 Subject: [PATCH] PPI-1045 - Relaxed strict null checks --- CHANGELOG.md | 1 + CHANGELOG_de-DE.md | 1 + .../swag-paypal-payment-actions/index.js | 4 +-- .../swag-paypal-payment-details-v1/index.js | 2 +- .../swag-paypal-payment-details-v2/index.js | 34 ++++++------------- 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b92a6d29d..1f5c3d58c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 9.6.5 - PPI-1025 - Improves the performance of the installment banner in the Storefront - PPI-1043 - Fixes an issue, where a payment method is toggled twice in the Administration +- PPI-1045 - Fixes an issue, where a payment was not refundable in some cases # 9.6.4 - PPI-930 - Fixes a issue, where with a selected sales channel the inherited configuration was not working correctly diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index c8c08d422..041218755 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,6 +1,7 @@ # 9.6.5 - PPI-1025 - Verbessert die Performance des Ratenzahlungsbanners in der Storefront - PPI-1043 - Behebt ein Problem, bei dem eine Zahlungsmethode doppelt umgeschalten wurde +- PPI-1045 - Behebt ein Problem, bei dem in manchen Fällen die Zahlung nicht erstattbar war # 9.6.4 - PPI-930 - Behebt ein Problem, bei dem bei einem ausgewähltem Verkaufskanal die vererbte Konfiguration nicht korrekt funktionierte diff --git a/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-actions/index.js b/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-actions/index.js index e5c202ee1..27538ec60 100644 --- a/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-actions/index.js +++ b/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-actions/index.js @@ -64,7 +64,7 @@ Component.register('swag-paypal-payment-actions', { }, setPaymentActionAmounts() { - if (this.relatedResources === null) { + if (!this.relatedResources) { return; } @@ -106,7 +106,7 @@ Component.register('swag-paypal-payment-actions', { }, setShowVoidButton() { - if (this.relatedResources === null) { + if (!this.relatedResources) { return; } diff --git a/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-details-v1/index.js b/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-details-v1/index.js index 5ff8a365f..cbd7e98d2 100644 --- a/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-details-v1/index.js +++ b/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-details-v1/index.js @@ -98,7 +98,7 @@ Component.register('swag-paypal-payment-details-v1', { setRelatedResources() { const rawRelatedResources = this.paymentResource.transactions[0].related_resources; - if (rawRelatedResources === null) { + if (!rawRelatedResources) { return; } diff --git a/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-details-v2/index.js b/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-details-v2/index.js index d38b389b7..d813d4caf 100644 --- a/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-details-v2/index.js +++ b/src/Resources/app/administration/src/module/swag-paypal-payment/component/swag-paypal-payment-details-v2/index.js @@ -103,7 +103,7 @@ Component.register('swag-paypal-payment-details-v2', { setPayments() { const payments = this.paypalOrder.purchase_units[0].payments; - if (payments === null) { + if (!payments) { return; } @@ -111,7 +111,7 @@ Component.register('swag-paypal-payment-details-v2', { const rawCaptures = payments.captures; const rawRefunds = payments.refunds; - if (rawAuthorizations !== null) { + if (rawAuthorizations) { rawAuthorizations.forEach((authorization) => { this.pushPayment('authorization', authorization); const authStatus = authorization.status; @@ -127,7 +127,7 @@ Component.register('swag-paypal-payment-details-v2', { }); } - if (rawCaptures !== null) { + if (rawCaptures) { rawCaptures.forEach((capture) => { this.pushPayment('capture', capture); const captureAmount = Number(capture.amount.value); @@ -136,7 +136,7 @@ Component.register('swag-paypal-payment-details-v2', { }); } - if (rawRefunds !== null) { + if (rawRefunds) { rawRefunds.forEach((refund) => { this.pushPayment('refund', refund); this.refundableAmount -= Number(refund.amount.value); @@ -169,31 +169,17 @@ Component.register('swag-paypal-payment-details-v2', { getTransactionFee(type, payment) { if (type === 'capture') { - const sellerReceivableBreakdown = payment.seller_receivable_breakdown; - if (sellerReceivableBreakdown === null) { - return null; + const paypalFee = payment.seller_receivable_breakdown?.paypal_fee; + if (paypalFee) { + return `${paypalFee.value} ${paypalFee.currency_code}`; } - - const paypalFee = sellerReceivableBreakdown.paypal_fee; - if (paypalFee == null) { - return null; - } - - return `${paypalFee.value} ${paypalFee.currency_code}`; } if (type === 'refund') { - const sellerPayableBreakdown = payment.seller_payable_breakdown; - if (sellerPayableBreakdown === null) { - return null; + const paypalFee = payment.seller_payable_breakdown?.paypal_fee; + if (paypalFee) { + return `${paypalFee.value} ${paypalFee.currency_code}`; } - - const paypalFee = sellerPayableBreakdown.paypal_fee; - if (paypalFee === null) { - return null; - } - - return `${paypalFee.value} ${paypalFee.currency_code}`; } return null;