woocommerce-paypal-payments/modules/ppcp-blocks/resources/js/Components/checkout-handler.js

29 lines
828 B
JavaScript
Raw Normal View History

2024-05-15 17:37:02 +02:00
import {useEffect} from '@wordpress/element';
import {usePayPalCardFields} from "@paypal/react-paypal-js";
export const CheckoutHandler = ({getCardFieldsForm, getSavePayment, hasSubscriptionProducts, saveCardText, is_vaulting_enabled}) => {
2024-05-15 17:37:02 +02:00
const {cardFieldsForm} = usePayPalCardFields();
useEffect(() => {
2024-05-20 16:37:11 +02:00
getCardFieldsForm(cardFieldsForm)
}, []);
2024-05-15 17:37:02 +02:00
if (!is_vaulting_enabled) {
return null;
}
return (
<>
<input
type="checkbox"
id="save"
name="save"
onChange={(e) => getSavePayment(e.target.checked)}
defaultChecked={hasSubscriptionProducts}
disabled={hasSubscriptionProducts}
/>
<label htmlFor="save">{saveCardText}</label>
</>
)
2024-05-15 17:37:02 +02:00
}