Revert "enqueue PayPal script from backend"

This reverts commit 238a71f9a4.
This commit is contained in:
Kirill Braslavsky 2021-03-19 17:40:11 +02:00
parent daf7caf9f4
commit 1ce5e27f37
2 changed files with 23 additions and 10 deletions

View file

@ -73,6 +73,27 @@ const bootstrap = () => {
document.addEventListener(
'DOMContentLoaded',
() => {
bootstrap();
if (!typeof (PayPalCommerceGateway)) {
console.error('PayPal button could not be configured.');
return;
}
const script = document.createElement('script');
script.addEventListener('load', (event) => {
bootstrap();
});
script.setAttribute('src', PayPalCommerceGateway.button.url);
Object.entries(PayPalCommerceGateway.script_attributes).forEach(
(keyValue) => {
script.setAttribute(keyValue[0], keyValue[1]);
}
);
if (PayPalCommerceGateway.data_client_id.set_attribute) {
dataClientIdAttributeHandler(script, PayPalCommerceGateway.data_client_id);
return;
}
document.body.append(script);
},
);

View file

@ -351,19 +351,11 @@ class SmartButton implements SmartButtonInterface {
wp_enqueue_script(
'ppcp-smart-button',
$this->module_url . '/assets/js/button.js',
array( 'jquery', 'ppcp-paypal-buttons' ),
array( 'jquery' ),
1,
true
);
wp_enqueue_script(
'ppcp-paypal-buttons',
$this->url(),
array('jquery'),
null,
false
);
wp_localize_script(
'ppcp-smart-button',
'PayPalCommerceGateway',