🐛 Fix button specific config-preparation

This commit is contained in:
Philipp Stracker 2024-06-07 15:42:16 +02:00
parent da64ffbac5
commit 33c6c06e85
No known key found for this signature in database
4 changed files with 51 additions and 8 deletions

View file

@ -20,7 +20,6 @@ class PreviewButton {
this.selector = selector;
this.domWrapper = null;
this.payButton = null;
}
/**
@ -50,18 +49,24 @@ class PreviewButton {
this.buttonConfig.button.wrapper = this.selector
}
if (this.ppcpConfig && this.buttonConfig) {
this.buttonConfig.button.style = this.ppcpConfig.button.style;
}
this.applyPreviewConfig();
return this;
}
/**
* Some style details need to be copied from the ppcpConfig object to buttonConfig.
*
* - ppcpConfig: Generated by JS, containing the current form values.
* - buttonConfig: Generated on server side, contains the full (saved) button details.
*/
applyPreviewConfig() {
// Implement in the derived class.
}
/**
* Responsible for creating the actual payment button preview.
* Called by the `render()` method, after the wrapper DOM element is ready.
*
* @return {any} Return value is assigned to `this.payButton`
*/
createButton() {
throw new Error('The "createButton" method must be implemented by the derived class');