Fix the Apple Pay button in the editor

This commit is contained in:
Daniel Dudzic 2024-04-23 15:00:05 +02:00
parent d1b4d7721e
commit 436fd77587
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
6 changed files with 112 additions and 28 deletions

View file

@ -0,0 +1,36 @@
import ApplepayButton from "./ApplepayButton";
class ApplepayManagerBlockEditor {
constructor(buttonConfig, ppcpConfig) {
this.buttonConfig = buttonConfig;
this.ppcpConfig = ppcpConfig;
this.applePayConfig = null;
}
init() {
(async () => {
await this.config();
})();
}
async config() {
try {
this.applePayConfig = await paypal.Applepay().config();
const button = new ApplepayButton(
this.ppcpConfig.context,
null,
this.buttonConfig,
this.ppcpConfig,
);
button.init(this.applePayConfig);
} catch (error) {
console.error('Failed to initialize Apple Pay:', error);
}
}
}
export default ApplepayManagerBlockEditor;