Skip to content

Commit

Permalink
Merge pull request #334 from 202ecommerce/feature/45842-bnpl_eligibility
Browse files Browse the repository at this point in the history
refs #45842 hide payment option if bnpl is not eligible
  • Loading branch information
bogdan202 authored Jun 14, 2024
2 parents 750075a + 0fe5ec7 commit 22c0083
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions 202/_dev/js/bnpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const BNPL = {
BNPL.button.style.display = 'none';
}

totPaypalBnplSdkButtons.Buttons({
const paypalButton = totPaypalBnplSdkButtons.Buttons({
fundingSource: totPaypalBnplSdkButtons.FUNDING.PAYLATER,

style: {
Expand All @@ -124,8 +124,23 @@ const BNPL = {
BNPL.sendData(data);
},

}).render(this.button);
});

if (!paypalButton.isEligible()) {
const paymentOption = document.querySelector('[data-module-name="paypal_bnpl"]');

if (paymentOption) {
const paymentOptionRow = paymentOption.closest('.payment-option');

if (paymentOptionRow) {
paymentOptionRow.style.display = 'none';
}
}

return;
}

paypalButton.render(this.button);
let event = new Event('paypal-after-init-bnpl-button');
document.dispatchEvent(event);
},
Expand Down

0 comments on commit 22c0083

Please sign in to comment.