🐛 Fix init errors “No API configuration...”

Caused by calling `reinit()` before the invoking `init()` first. New condition in `reinit()` ensures that the button configuration is present.
This commit is contained in:
Philipp Stracker 2024-08-12 18:50:17 +02:00
parent 843403cbdc
commit 966b76102c
No known key found for this signature in database
2 changed files with 63 additions and 47 deletions

View file

@ -472,18 +472,6 @@ export default class PaymentButton {
return this.methodId === getCurrentPaymentMethod();
}
/**
* Determines if the current button instance has valid and complete configuration details.
* Used during initialization to decide if the button can be initialized or should be skipped.
*
* Can be implemented by the derived class.
*
* @return {boolean} True indicates the config is valid and initialization can continue.
*/
get isConfigValid() {
return true;
}
/**
* Flags a preview button without actual payment logic.
*
@ -640,6 +628,19 @@ export default class PaymentButton {
this.#logger.error( ...args );
}
/**
* Determines if the current button instance has valid and complete configuration details.
* Used during initialization to decide if the button can be initialized or should be skipped.
*
* Can be implemented by the derived class.
*
* @param {boolean} [silent=false] - Set to true to suppress console errors.
* @return {boolean} True indicates the config is valid and initialization can continue.
*/
validateConfiguration( silent = false ) {
return true;
}
applyButtonStyles( buttonConfig, ppcpConfig = null ) {
if ( ! ppcpConfig ) {
ppcpConfig = this.ppcpConfig;