mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Do not use timeout but return a promise on onApprove
This commit is contained in:
parent
c973871980
commit
eaca9f6a41
2 changed files with 2 additions and 15 deletions
|
@ -22,25 +22,12 @@ export function CardFields({config, eventRegistration, emitResponse}) {
|
|||
localStorage.setItem('ppcp-save-card-payment', savePayment);
|
||||
}
|
||||
|
||||
const wait = (milliseconds) => {
|
||||
return new Promise((resolve) => {
|
||||
console.log('start...')
|
||||
setTimeout(() => {
|
||||
console.log('resolve')
|
||||
resolve()
|
||||
}, milliseconds)
|
||||
})
|
||||
};
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
onPaymentSetup(() => {
|
||||
async function handlePaymentProcessing() {
|
||||
await cardFieldsForm.submit();
|
||||
|
||||
// TODO temporary workaround to wait for onApprove to resolve
|
||||
await wait(3000)
|
||||
|
||||
return {
|
||||
type: responseTypes.SUCCESS,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue