changes and optimisations

This commit is contained in:
sdarbinyan
2026-03-06 17:45:34 +04:00
parent c112aded47
commit c3e4e695eb
9 changed files with 129 additions and 69 deletions

View File

@@ -167,7 +167,7 @@ export class CartComponent implements OnDestroy {
const paymentData = {
amount: this.totalPrice(),
currency: 'RUB',
currency: this.items()[0]?.currency || 'RUB',
siteuserID: userId,
siteorderID: orderId,
redirectUrl: '',
@@ -193,6 +193,7 @@ export class CartComponent implements OnDestroy {
error: (err) => {
console.error('Error creating payment:', err);
this.paymentStatus.set('timeout');
if (this.closeTimeout) clearTimeout(this.closeTimeout);
this.closeTimeout = setTimeout(() => {
this.closePaymentPopup();
}, 4000);
@@ -201,6 +202,7 @@ export class CartComponent implements OnDestroy {
}
startPolling(): void {
this.stopPolling();
this.pollingSubscription = interval(5000) // every 5 seconds
.pipe(
take(this.maxChecks), // maximum 36 checks (3 minutes)
@@ -225,6 +227,7 @@ export class CartComponent implements OnDestroy {
if (this.paymentStatus() === 'waiting') {
this.paymentStatus.set('timeout');
// Close popup after showing timeout message
if (this.closeTimeout) clearTimeout(this.closeTimeout);
this.closeTimeout = setTimeout(() => {
this.closePaymentPopup();
}, 3000);
@@ -233,6 +236,7 @@ export class CartComponent implements OnDestroy {
error: (err) => {
console.error('Error checking payment status:', err);
// Continue checking even on error until time runs out
if (this.closeTimeout) clearTimeout(this.closeTimeout);
this.closeTimeout = setTimeout(() => {
this.closePaymentPopup();
}, 3000);