Do not use timeout but return a promise on onApprove

This commit is contained in:
Emili Castells Guasch 2024-06-03 11:29:04 +02:00
parent c973871980
commit eaca9f6a41
2 changed files with 2 additions and 15 deletions

View file

@ -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,
}