Use custom save card payment checkbox and show/hide it based on vaulting setting

This commit is contained in:
Emili Castells Guasch 2024-05-22 15:52:45 +02:00
parent 13b5338627
commit 880bd48271
6 changed files with 45 additions and 13 deletions

View file

@ -1,12 +1,21 @@
import {useEffect} from '@wordpress/element';
import {usePayPalCardFields} from "@paypal/react-paypal-js";
export const CheckoutHandler = ({getCardFieldsForm}) => {
export const CheckoutHandler = ({getCardFieldsForm, getSavePayment, saveCardText, is_vaulting_enabled}) => {
const {cardFieldsForm} = usePayPalCardFields();
useEffect(() => {
getCardFieldsForm(cardFieldsForm)
}, []);
return null
if (!is_vaulting_enabled) {
return null;
}
return (
<>
<input type="checkbox" id="save" name="save" onChange={(e) => getSavePayment(e.target.checked)}/>
<label htmlFor="save">{saveCardText}</label>
</>
)
}