mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add card fields component (WIP)
This commit is contained in:
parent
0862e5fb3d
commit
e3ac190849
4 changed files with 70 additions and 54 deletions
|
@ -0,0 +1,33 @@
|
|||
import {useEffect} from '@wordpress/element';
|
||||
import {usePayPalCardFields} from "@paypal/react-paypal-js";
|
||||
|
||||
export const CheckoutHandler = ({onPaymentSetup, responseTypes}) => {
|
||||
const {cardFieldsForm} = usePayPalCardFields();
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = onPaymentSetup(async () => {
|
||||
|
||||
cardFieldsForm.submit()
|
||||
.then(() => {
|
||||
return {
|
||||
type: responseTypes.SUCCESS,
|
||||
meta: {
|
||||
paymentMethodData: {
|
||||
foo: 'bar',
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
.catch((err) => {
|
||||
return {
|
||||
type: responseTypes.ERROR,
|
||||
message: err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
return unsubscribe
|
||||
}, [onPaymentSetup, cardFieldsForm]);
|
||||
|
||||
return null
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue