Skip to content

Commit

Permalink
PPI-1045 - Relaxed strict null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cyl3x committed Dec 19, 2024
1 parent 2d0c707 commit 45bfa77
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Component.register('swag-paypal-payment-actions', {
},

setPaymentActionAmounts() {
if (this.relatedResources === null) {
if (!this.relatedResources) {
return;
}

Expand Down Expand Up @@ -106,7 +106,7 @@ Component.register('swag-paypal-payment-actions', {
},

setShowVoidButton() {
if (this.relatedResources === null) {
if (!this.relatedResources) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ Component.register('swag-paypal-payment-details-v2', {

setPayments() {
const payments = this.paypalOrder.purchase_units[0].payments;
if (payments === null) {
if (!payments) {
return;
}

const rawAuthorizations = payments.authorizations;
const rawCaptures = payments.captures;
const rawRefunds = payments.refunds;

if (rawAuthorizations !== null) {
if (rawAuthorizations) {
rawAuthorizations.forEach((authorization) => {
this.pushPayment('authorization', authorization);
const authStatus = authorization.status;
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 45bfa77

Please sign in to comment.