UNPKG

@automattic/wpcom-checkout

Version:
35 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.filterAppropriatePaymentMethods = filterAppropriatePaymentMethods; const index_1 = require("./index"); function filterAppropriatePaymentMethods({ paymentMethodObjects, allowedPaymentMethods, }) { let isPayPalPPCPEnabled = false; return paymentMethodObjects .filter((methodObject) => { const slug = (0, index_1.readCheckoutPaymentMethodSlug)(methodObject.id); if (!slug) { return false; } if (!(0, index_1.isPaymentMethodEnabled)(slug, allowedPaymentMethods)) { return false; } if (slug === 'paypal-js') { isPayPalPPCPEnabled = true; } return true; }) .filter((methodObject) => { // Only allow one of 'paypal-express' or 'paypal-js' in checkout. We // don't want to confuse users with both options, even if they are both // available. 'paypal-js' takes precedence. const slug = (0, index_1.readCheckoutPaymentMethodSlug)(methodObject.id); if (!slug) { return false; } if (isPayPalPPCPEnabled && slug === 'paypal-express') { return false; } return true; }); } //# sourceMappingURL=filter-appropriate-payment-methods.js.map