Skip to content

Commit bd25b6b

Browse files
committed
fix: handle dynamic form IDs in Bizum create_hidden_input
- Try primary form ID (monei-bizum-form) first - Fall back to order-pay form ID (wc-monei_bizum-cc-form) - Only append hidden input if target element exists - Add error logging for missing form container - Prevents exceptions that could block payment submission in order-pay flow
1 parent 02ed272 commit bd25b6b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

assets/js/monei-bizum-classic.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,20 @@
226226
hiddenInput.setAttribute( 'name', id );
227227
hiddenInput.setAttribute( 'id', id );
228228
hiddenInput.setAttribute( 'value', token );
229+
230+
// Try primary form ID first, then fall back to order-pay form ID
229231
wc_bizum_form.$paymentForm =
230-
document.getElementById( 'monei-bizum-form' );
231-
wc_bizum_form.$paymentForm.appendChild( hiddenInput );
232+
document.getElementById( 'monei-bizum-form' ) ||
233+
document.getElementById( 'wc-monei_bizum-cc-form' );
234+
235+
// Only append if we found a target element
236+
if ( wc_bizum_form.$paymentForm ) {
237+
wc_bizum_form.$paymentForm.appendChild( hiddenInput );
238+
} else {
239+
console.error(
240+
'Bizum form container not found. Cannot append payment token.'
241+
);
242+
}
232243
},
233244
};
234245

0 commit comments

Comments
 (0)