🐛 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

@ -96,6 +96,30 @@ class ApplePayPreviewButton extends PreviewButton {
button.init(this.configResponse);
}
/**
* 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() {
// The Apple Pay button expects the "wrapper" to be an ID without `#` prefix!
if (this.buttonConfig?.button?.wrapper) {
this.buttonConfig.button.wrapper = this.buttonConfig.button.wrapper.replace(/^#/, '');
}
// Apple Pay expects the param "lang" instead of "language"
if (this.ppcpConfig?.button?.style?.language) {
this.ppcpConfig.button.style.lang = this.ppcpConfig.button.style.language;
}
if (this.ppcpConfig && this.buttonConfig) {
this.buttonConfig.button.type = this.ppcpConfig.button.style.type;
this.buttonConfig.button.color = this.ppcpConfig.button.style.color;
this.buttonConfig.button.lang = this.ppcpConfig.button.style.lang;
}
}
}
// Initialize the preview button manager.