mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add place order logic (WIP)
This commit is contained in:
parent
4b3cd53f73
commit
e93e9db3be
6 changed files with 115 additions and 20 deletions
|
@ -1,23 +1,12 @@
|
|||
import {useEffect} from '@wordpress/element';
|
||||
import {usePayPalCardFields} from "@paypal/react-paypal-js";
|
||||
|
||||
export const CheckoutHandler = ({onPaymentSetup, responseTypes}) => {
|
||||
export const CheckoutHandler = ({getCardFieldsForm}) => {
|
||||
const {cardFieldsForm} = usePayPalCardFields();
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = onPaymentSetup(async () => {
|
||||
|
||||
await cardFieldsForm.submit()
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
return {
|
||||
type: responseTypes.ERROR,
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
return unsubscribe
|
||||
}, [onPaymentSetup, cardFieldsForm]);
|
||||
getCardFieldsForm(cardFieldsForm)
|
||||
}, []);
|
||||
|
||||
return null
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue