Skip to content

Commit

Permalink
render button separated from start method
Browse files Browse the repository at this point in the history
  • Loading branch information
gilv93 committed Oct 10, 2023
1 parent ff8eb2d commit 8f1d5e5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/recurly/amazon/amazon-pay.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ class AmazonPay extends Emitter {

async start () {
try {
await this.loadExternalLibraries();
await this.obtainMerchantId(this.recurly);
await this.renderButton(this.options.element);
await Promise.all([
this.loadExternalLibraries(),
this.obtainMerchantId(this.recurly)
]);
} catch (err) {
this.error(err);
}
Expand All @@ -42,7 +43,10 @@ class AmazonPay extends Emitter {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = this.scriptUrl();
script.onload = resolve;
script.onload = () => {
resolve;
this.emit('ready');
};
script.onerror = reject;
document.head.appendChild(script);
});
Expand Down

0 comments on commit 8f1d5e5

Please sign in to comment.