mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
execute js bootstrap after paypal.com script has been loaded.
This commit is contained in:
parent
41f86426d8
commit
6d93f6316a
4 changed files with 74 additions and 79 deletions
|
@ -1,29 +1,11 @@
|
|||
class Renderer {
|
||||
|
||||
constructor(url, wrapper)
|
||||
constructor(wrapper)
|
||||
{
|
||||
this.url = url;
|
||||
this.wrapper = wrapper;
|
||||
}
|
||||
|
||||
render(buttonConfig)
|
||||
{
|
||||
|
||||
const script = document.createElement('script');
|
||||
|
||||
if (typeof paypal !== 'object') {
|
||||
script.setAttribute('src', this.url);
|
||||
script.addEventListener('load', (event) => {
|
||||
this.renderButtons(buttonConfig);
|
||||
})
|
||||
document.body.append(script);
|
||||
return;
|
||||
}
|
||||
|
||||
this.renderButtons(buttonConfig);
|
||||
}
|
||||
|
||||
renderButtons(buttonConfig)
|
||||
{
|
||||
|
||||
paypal.Buttons(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue