2024-10-29 12:39:44 +01:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2024-12-09 12:04:02 +01:00
|
|
|
|
2025-01-27 11:14:24 +01:00
|
|
|
import SettingsCard from '../../../ReusableComponents/SettingsCard';
|
|
|
|
import { PaymentMethodsBlock } from '../../../ReusableComponents/SettingsBlocks';
|
|
|
|
import { PaymentHooks } from '../../../../data';
|
|
|
|
import { useActiveModal } from '../../../../data/common/hooks';
|
|
|
|
import Modal from '../Components/Payment/Modal';
|
2024-10-29 12:39:44 +01:00
|
|
|
|
2024-10-25 14:35:16 +02:00
|
|
|
const TabPaymentMethods = () => {
|
2025-01-16 14:48:04 +01:00
|
|
|
const { paymentMethodsPayPalCheckout } =
|
|
|
|
PaymentHooks.usePaymentMethodsPayPalCheckout();
|
|
|
|
const { paymentMethodsOnlineCardPayments } =
|
|
|
|
PaymentHooks.usePaymentMethodsOnlineCardPayments();
|
|
|
|
const { paymentMethodsAlternative } =
|
|
|
|
PaymentHooks.usePaymentMethodsAlternative();
|
2024-12-03 18:06:23 +04:00
|
|
|
|
2025-01-27 11:32:21 +01:00
|
|
|
const { setPersistent, changePaymentSettings } = PaymentHooks.useStore();
|
2025-01-22 15:53:00 +01:00
|
|
|
|
2025-01-16 14:48:04 +01:00
|
|
|
const { activeModal, setActiveModal } = useActiveModal();
|
2024-10-29 12:39:44 +01:00
|
|
|
|
2025-01-09 00:16:12 +01:00
|
|
|
const getActiveMethod = () => {
|
|
|
|
if ( ! activeModal ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const allMethods = [
|
2025-01-16 14:48:04 +01:00
|
|
|
...paymentMethodsPayPalCheckout,
|
|
|
|
...paymentMethodsOnlineCardPayments,
|
|
|
|
...paymentMethodsAlternative,
|
2025-01-09 00:16:12 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
return allMethods.find( ( method ) => method.id === activeModal );
|
|
|
|
};
|
|
|
|
|
2024-10-29 12:39:44 +01:00
|
|
|
return (
|
|
|
|
<div className="ppcp-r-payment-methods">
|
|
|
|
<SettingsCard
|
2025-01-02 13:55:32 +01:00
|
|
|
id="ppcp-paypal-checkout-card"
|
2024-10-29 12:39:44 +01:00
|
|
|
title={ __( 'PayPal Checkout', 'woocommerce-paypal-payments' ) }
|
|
|
|
description={ __(
|
|
|
|
'Select your preferred checkout option with PayPal for easy payment processing.',
|
|
|
|
'woocommerce-paypal-payments'
|
|
|
|
) }
|
|
|
|
icon="icon-checkout-standard.svg"
|
2024-12-08 09:33:49 +01:00
|
|
|
contentContainer={ false }
|
2024-10-29 12:39:44 +01:00
|
|
|
>
|
2024-12-08 09:33:49 +01:00
|
|
|
<PaymentMethodsBlock
|
2025-01-16 14:48:04 +01:00
|
|
|
paymentMethods={ paymentMethodsPayPalCheckout }
|
2025-01-02 13:55:32 +01:00
|
|
|
onTriggerModal={ setActiveModal }
|
2024-12-08 09:33:49 +01:00
|
|
|
/>
|
2024-10-29 12:39:44 +01:00
|
|
|
</SettingsCard>
|
|
|
|
<SettingsCard
|
2025-01-02 13:55:32 +01:00
|
|
|
id="ppcp-card-payments-card"
|
2024-10-29 12:39:44 +01:00
|
|
|
title={ __(
|
|
|
|
'Online Card Payments',
|
|
|
|
'woocommerce-paypal-payments'
|
|
|
|
) }
|
|
|
|
description={ __(
|
|
|
|
'Select your preferred card payment options for efficient payment processing.',
|
|
|
|
'woocommerce-paypal-payments'
|
|
|
|
) }
|
|
|
|
icon="icon-checkout-online-methods.svg"
|
2024-12-08 09:33:49 +01:00
|
|
|
contentContainer={ false }
|
2024-10-29 12:39:44 +01:00
|
|
|
>
|
2024-12-08 09:33:49 +01:00
|
|
|
<PaymentMethodsBlock
|
2025-01-16 14:48:04 +01:00
|
|
|
paymentMethods={ paymentMethodsOnlineCardPayments }
|
2025-01-02 13:55:32 +01:00
|
|
|
onTriggerModal={ setActiveModal }
|
2024-12-08 09:33:49 +01:00
|
|
|
/>
|
2024-10-29 12:39:44 +01:00
|
|
|
</SettingsCard>
|
|
|
|
<SettingsCard
|
2025-01-02 13:55:32 +01:00
|
|
|
id="ppcp-alternative-payments-card"
|
2024-10-29 12:39:44 +01:00
|
|
|
title={ __(
|
|
|
|
'Alternative Payment Methods',
|
|
|
|
'woocommerce-paypal-payments'
|
|
|
|
) }
|
|
|
|
description={ __(
|
|
|
|
'With alternative payment methods, customers across the globe can pay with their bank accounts and other local payment methods.',
|
|
|
|
'woocommerce-paypal-payments'
|
|
|
|
) }
|
|
|
|
icon="icon-checkout-alternative-methods.svg"
|
2024-12-08 09:33:49 +01:00
|
|
|
contentContainer={ false }
|
2024-10-29 12:39:44 +01:00
|
|
|
>
|
2024-12-08 09:33:49 +01:00
|
|
|
<PaymentMethodsBlock
|
2025-01-16 14:48:04 +01:00
|
|
|
paymentMethods={ paymentMethodsAlternative }
|
2025-01-02 13:55:32 +01:00
|
|
|
onTriggerModal={ setActiveModal }
|
2024-12-08 09:33:49 +01:00
|
|
|
/>
|
2024-10-29 12:39:44 +01:00
|
|
|
</SettingsCard>
|
2025-01-02 13:55:32 +01:00
|
|
|
|
2025-01-09 00:16:12 +01:00
|
|
|
{ activeModal && (
|
|
|
|
<Modal
|
|
|
|
method={ getActiveMethod() }
|
|
|
|
setModalIsVisible={ () => setActiveModal( null ) }
|
|
|
|
onSave={ ( methodId, settings ) => {
|
2025-01-27 11:32:21 +01:00
|
|
|
changePaymentSettings( methodId, {
|
2025-01-22 15:53:00 +01:00
|
|
|
title: settings.checkoutPageTitle,
|
|
|
|
description: settings.checkoutPageDescription,
|
|
|
|
} );
|
|
|
|
|
2025-01-23 12:29:41 +01:00
|
|
|
if ( 'paypalShowLogo' in settings ) {
|
2025-01-27 11:15:37 +01:00
|
|
|
// TODO: Create a dedicated setter for this value.
|
2025-01-23 12:29:41 +01:00
|
|
|
setPersistent(
|
|
|
|
'paypalShowLogo',
|
|
|
|
settings.paypalShowLogo
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ( 'threeDSecure' in settings ) {
|
2025-01-27 11:15:37 +01:00
|
|
|
// TODO: Create a dedicated setter for this value.
|
2025-01-23 12:29:41 +01:00
|
|
|
setPersistent(
|
|
|
|
'threeDSecure',
|
|
|
|
settings.threeDSecure
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ( 'fastlaneCardholderName' in settings ) {
|
2025-01-27 11:15:37 +01:00
|
|
|
// TODO: Create a dedicated setter for this value.
|
2025-01-23 12:29:41 +01:00
|
|
|
setPersistent(
|
|
|
|
'fastlaneCardholderName',
|
|
|
|
settings.fastlaneCardholderName
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ( 'fastlaneDisplayWatermark' in settings ) {
|
2025-01-27 11:15:37 +01:00
|
|
|
// TODO: Create a dedicated setter for this value.
|
2025-01-23 12:29:41 +01:00
|
|
|
setPersistent(
|
|
|
|
'fastlaneDisplayWatermark',
|
|
|
|
settings.fastlaneDisplayWatermark
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-01-09 00:16:12 +01:00
|
|
|
setActiveModal( null );
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
) }
|
2024-10-29 12:39:44 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-10-25 14:35:16 +02:00
|
|
|
export default TabPaymentMethods;
|