🐛 Address some errors in preview (Settings page)

This commit is contained in:
Philipp Stracker 2024-08-08 13:10:10 +02:00
parent 7f3636348b
commit 9ac4300995
No known key found for this signature in database
4 changed files with 155 additions and 53 deletions

View file

@ -30,13 +30,19 @@ class GooglepayManager {
this.buttons.push( button );
const initButton = () => {
button.configure( this.googlePayConfig, this.transactionInfo );
button.init();
};
// Initialize button only if googlePayConfig and transactionInfo are already fetched.
if ( this.googlePayConfig && this.transactionInfo ) {
button.init( this.googlePayConfig, this.transactionInfo );
initButton();
} else {
await this.init();
if ( this.googlePayConfig && this.transactionInfo ) {
button.init( this.googlePayConfig, this.transactionInfo );
initButton();
}
}
} );
@ -54,7 +60,8 @@ class GooglepayManager {
}
for ( const button of this.buttons ) {
button.init( this.googlePayConfig, this.transactionInfo );
button.configure( this.googlePayConfig, this.transactionInfo );
button.init();
}
} catch ( error ) {
console.error( 'Error during initialization:', error );