From bee56afedc109b96894aefd3a61a36cf48566b1c Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Wed, 13 May 2026 17:31:44 +0400 Subject: [PATCH] qr check --- src/app/pages/create-page/create-page.ts | 36 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/app/pages/create-page/create-page.ts b/src/app/pages/create-page/create-page.ts index c4bb1d6..5d97df2 100644 --- a/src/app/pages/create-page/create-page.ts +++ b/src/app/pages/create-page/create-page.ts @@ -35,6 +35,9 @@ interface QrStatusResponse { export class CreatePage { private http = inject(HttpClient); private i18n = inject(TranslationService); + private readonly parentRedirects: Record = { + fast: 'https://fastcheck.store' + }; private t(key: string): string { return this.i18n.translate(key); } @@ -80,6 +83,9 @@ export class CreatePage { private get partnerqrID(): string { return new URLSearchParams(window.location.search).get('id') ?? ''; } + private get parentAlias(): string { + return new URLSearchParams(window.location.search).get('parent') ?? ''; + } get isMobile(): boolean { return window.innerWidth < 768; @@ -182,8 +188,7 @@ export class CreatePage { const st = res?.status ?? ''; this.qrStatus.set(st); if (st === 'COMPLETED' || st === 'APPROVED') { - this.stopPolling(); - this.paymentDone.set(true); + this.handlePaymentSuccess(); } else if (st === 'REJECTED') { this.stopPolling(); this.error.set(this.t('errors.payment_failed')); @@ -216,6 +221,33 @@ export class CreatePage { this.note.set(value); } + private handlePaymentSuccess(): void { + this.stopPolling(); + this.qrImageUrl.set(null); + this.qrStatus.set(''); + this.paymentDone.set(true); + this.redirectToSource(); + } + + private redirectToSource(): void { + const alias = this.parentAlias.trim().toLowerCase(); + const fromAlias = this.parentRedirects[alias]; + if (fromAlias) { + window.location.href = fromAlias; + return; + } + + const referrer = document.referrer; + if (referrer) { + window.location.href = referrer; + return; + } + + if (window.history.length > 1) { + window.history.back(); + } + } + closeQr(): void { this.stopPolling(); this.qrImageUrl.set(null);