From 35473df661c52f5c2e759f859ed4a3a320395205 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Tue, 8 Oct 2024 14:26:46 +0200
Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Make=20internal=20attribut?=
=?UTF-8?q?es=20private?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/js/ApplepayManager.js | 39 +++++++++++--------
.../js/ApplepayManagerBlockEditor.js | 32 ++++++++-------
2 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/modules/ppcp-applepay/resources/js/ApplepayManager.js b/modules/ppcp-applepay/resources/js/ApplepayManager.js
index 5dcb0cf7b..6bff52577 100644
--- a/modules/ppcp-applepay/resources/js/ApplepayManager.js
+++ b/modules/ppcp-applepay/resources/js/ApplepayManager.js
@@ -3,50 +3,55 @@ import ApplePayButton from './ApplepayButton';
import ContextHandlerFactory from './Context/ContextHandlerFactory';
class ApplePayManager {
+ #namespace = '';
+ #buttonConfig = null;
+ #ppcpConfig = null;
+ #applePayConfig = null;
+ #contextHandler = null;
+ #buttons = [];
+
constructor( namespace, buttonConfig, ppcpConfig ) {
- this.namespace = namespace;
- this.buttonConfig = buttonConfig;
- this.ppcpConfig = ppcpConfig;
- this.ApplePayConfig = null;
- this.buttons = [];
+ this.#namespace = namespace;
+ this.#buttonConfig = buttonConfig;
+ this.#ppcpConfig = ppcpConfig;
this.onContextBootstrap = this.onContextBootstrap.bind( this );
buttonModuleWatcher.watchContextBootstrap( this.onContextBootstrap );
}
async onContextBootstrap( bootstrap ) {
- this.contextHandler = ContextHandlerFactory.create(
+ this.#contextHandler = ContextHandlerFactory.create(
bootstrap.context,
- this.buttonConfig,
- this.ppcpConfig,
+ this.#buttonConfig,
+ this.#ppcpConfig,
bootstrap.handler
);
const button = ApplePayButton.createButton(
bootstrap.context,
bootstrap.handler,
- this.buttonConfig,
- this.ppcpConfig,
- this.contextHandler
+ this.#buttonConfig,
+ this.#ppcpConfig,
+ this.#contextHandler
);
- this.buttons.push( button );
+ this.#buttons.push( button );
// Ensure ApplePayConfig is loaded before proceeding.
await this.init();
- button.configure( this.applePayConfig );
+ button.configure( this.#applePayConfig );
button.init();
}
async init() {
try {
- if ( ! this.applePayConfig ) {
- this.applePayConfig = await window[ this.namespace ]
+ if ( ! this.#applePayConfig ) {
+ this.#applePayConfig = await window[ this.#namespace ]
.Applepay()
.config();
- if ( ! this.applePayConfig ) {
+ if ( ! this.#applePayConfig ) {
console.error( 'No ApplePayConfig received during init' );
}
}
@@ -56,7 +61,7 @@ class ApplePayManager {
}
reinit() {
- for ( const button of this.buttons ) {
+ for ( const button of this.#buttons ) {
button.reinit();
}
}
diff --git a/modules/ppcp-applepay/resources/js/ApplepayManagerBlockEditor.js b/modules/ppcp-applepay/resources/js/ApplepayManagerBlockEditor.js
index a8fa9d7c9..ee992a9b7 100644
--- a/modules/ppcp-applepay/resources/js/ApplepayManagerBlockEditor.js
+++ b/modules/ppcp-applepay/resources/js/ApplepayManagerBlockEditor.js
@@ -2,10 +2,16 @@ import ApplePayButton from './ApplepayButton';
import ContextHandlerFactory from './Context/ContextHandlerFactory';
class ApplePayManagerBlockEditor {
+ #namespace = '';
+ #buttonConfig = null;
+ #ppcpConfig = null;
+ #applePayConfig = null;
+ #contextHandler = null;
+
constructor( namespace, buttonConfig, ppcpConfig ) {
- this.namespace = namespace;
- this.buttonConfig = buttonConfig;
- this.ppcpConfig = ppcpConfig;
+ this.#namespace = namespace;
+ this.#buttonConfig = buttonConfig;
+ this.#ppcpConfig = ppcpConfig;
/*
* On the front-end, the init method is called when a new button context was detected
@@ -17,26 +23,26 @@ class ApplePayManagerBlockEditor {
async init() {
try {
- this.applePayConfig = await window[ this.namespace ]
+ this.#applePayConfig = await window[ this.#namespace ]
.Applepay()
.config();
- this.contextHandler = ContextHandlerFactory.create(
- this.ppcpConfig.context,
- this.buttonConfig,
- this.ppcpConfig,
+ this.#contextHandler = ContextHandlerFactory.create(
+ this.#ppcpConfig.context,
+ this.#buttonConfig,
+ this.#ppcpConfig,
null
);
const button = ApplePayButton.createButton(
- this.ppcpConfig.context,
+ this.#ppcpConfig.context,
null,
- this.buttonConfig,
- this.ppcpConfig,
- this.contextHandler
+ this.#buttonConfig,
+ this.#ppcpConfig,
+ this.#contextHandler
);
- button.configure( this.applePayConfig );
+ button.configure( this.#applePayConfig );
button.init();
} catch ( error ) {
console.error( 'Failed to initialize Apple Pay:', error );