execute js bootstrap after paypal.com script has been loaded.

This commit is contained in:
David Remer 2020-04-08 13:33:12 +03:00
parent 41f86426d8
commit 6d93f6316a
4 changed files with 74 additions and 79 deletions

View file

@ -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(