2024-07-23 17:36:10 +02:00
|
|
|
/* global paypal */
|
2024-04-23 15:00:05 +02:00
|
|
|
|
2024-07-23 17:36:10 +02:00
|
|
|
import ApplePayButton from './ApplepayButton';
|
|
|
|
|
|
|
|
class ApplePayManagerBlockEditor {
|
2024-07-12 12:58:34 +02:00
|
|
|
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();
|
|
|
|
|
2024-07-23 17:36:10 +02:00
|
|
|
const button = new ApplePayButton(
|
2024-07-12 12:58:34 +02:00
|
|
|
this.ppcpConfig.context,
|
|
|
|
null,
|
|
|
|
this.buttonConfig,
|
|
|
|
this.ppcpConfig
|
|
|
|
);
|
|
|
|
|
|
|
|
button.init( this.applePayConfig );
|
|
|
|
} catch ( error ) {
|
|
|
|
console.error( 'Failed to initialize Apple Pay:', error );
|
|
|
|
}
|
|
|
|
}
|
2024-04-23 15:00:05 +02:00
|
|
|
}
|
|
|
|
|
2024-07-23 17:36:10 +02:00
|
|
|
export default ApplePayManagerBlockEditor;
|