Skip to content

Commit

Permalink
Fixing Sonarcloud complains about ApplePayService (#2846)
Browse files Browse the repository at this point in the history
* sonarcloud reliability issues fix

* changeset
  • Loading branch information
ribeiroguilherme authored Sep 11, 2024
1 parent 08102bd commit ae665f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-carrots-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@adyen/adyen-web': patch
---

Fixing reliability Sonarcloud issues related to ApplePayService
27 changes: 19 additions & 8 deletions packages/lib/src/components/ApplePay/ApplePayService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,34 @@ class ApplePayService {
this.options = options;

this.session = new ApplePaySession(options.version, paymentRequest);
/* eslint-disable @typescript-eslint/no-misused-promises */
this.session.onvalidatemerchant = event => this.onvalidatemerchant(event, options.onValidateMerchant);
this.session.onpaymentauthorized = event => this.onpaymentauthorized(event, options.onPaymentAuthorized);
this.session.oncancel = event => this.oncancel(event, options.onCancel);
this.session.onvalidatemerchant = event => {
void this.onvalidatemerchant(event, options.onValidateMerchant);
};
this.session.onpaymentauthorized = event => {
void this.onpaymentauthorized(event, options.onPaymentAuthorized);
};

this.session.oncancel = event => {
this.oncancel(event, options.onCancel);
};

if (typeof options.onPaymentMethodSelected === 'function') {
this.session.onpaymentmethodselected = event => this.onpaymentmethodselected(event, options.onPaymentMethodSelected);
this.session.onpaymentmethodselected = event => {
void this.onpaymentmethodselected(event, options.onPaymentMethodSelected);
};
}

if (typeof options.onShippingContactSelected === 'function') {
this.session.onshippingcontactselected = event => this.onshippingcontactselected(event, options.onShippingContactSelected);
this.session.onshippingcontactselected = event => {
void this.onshippingcontactselected(event, options.onShippingContactSelected);
};
}

if (typeof options.onShippingMethodSelected === 'function') {
this.session.onshippingmethodselected = event => this.onshippingmethodselected(event, options.onShippingMethodSelected);
this.session.onshippingmethodselected = event => {
void this.onshippingmethodselected(event, options.onShippingMethodSelected);
};
}
/* eslint-enable @typescript-eslint/no-misused-promises */
}

/**
Expand Down

0 comments on commit ae665f0

Please sign in to comment.