Skip to content

Commit

Permalink
Poll the payment every 5 seconds in case the payment is pending
Browse files Browse the repository at this point in the history
  • Loading branch information
lazka committed Nov 2, 2023
1 parent 30ef4a3 commit e6f0713
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/dbp-mono-processpayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class DbpMonoProcessPayment extends ScopedElementsMixin(DBPMonoLitElement) {

this.popUp = null;

this._paymentPollingTimerID = null;

// view
let view = this.getView();
switch (view) {
Expand All @@ -103,6 +105,27 @@ class DbpMonoProcessPayment extends ScopedElementsMixin(DBPMonoLitElement) {
}
}

pollPayment() {
if (this.showPending) {
this.getPayment();
}
}

connectedCallback() {
super.connectedCallback();

this._paymentPollingTimerID = setInterval(() => {
this.pollPayment();
}, 1000 * 5);
}

disconnectedCallback() {
clearInterval(this._paymentPollingTimerID);
this._paymentPollingTimerID = null;

super.disconnectedCallback();
}

updated(changedProperties) {
if (changedProperties.has('lang')) {
if (this._loginStatus === 'logged-in' && this.view === VIEW_SELECT) {
Expand Down

0 comments on commit e6f0713

Please sign in to comment.