Disable funding soures for Pay Later preview

This commit is contained in:
Narek Zakarian 2022-11-17 16:58:58 +04:00
parent 7051e86003
commit 2775f7dd9d
4 changed files with 22 additions and 3 deletions

View file

@ -64,6 +64,7 @@ import MessageRenderer from "../../../ppcp-button/resources/js/modules/Renderer/
const disableFundingInput = jQuery('[name="ppcp[disable_funding][]"]');
let disabledSources = disableFundingInput.length > 0 ? disableFundingInput.val() : PayPalCommerceGatewaySettings.disabled_sources;
const isPayLaterButtonEnabled = payLaterButtonInput ? payLaterButtonInput.checked : PayPalCommerceGatewaySettings.is_pay_later_button_enabled
const payLaterButtonPreview = jQuery('#ppcpPayLaterButtonPreview');
const settings = {
'client-id': PayPalCommerceGatewaySettings.client_id,
'currency': PayPalCommerceGatewaySettings.currency,
@ -77,6 +78,10 @@ import MessageRenderer from "../../../ppcp-button/resources/js/modules/Renderer/
disabledSources = disabledSources.concat('credit')
}
if(payLaterButtonPreview?.length) {
disabledSources = Object.keys(PayPalCommerceGatewaySettings.all_funding_sources);
}
if (disabledSources?.length) {
settings['disable-funding'] = disabledSources;
}