This commit is contained in:
2026-05-13 17:31:44 +04:00
parent ce2c9c42fe
commit bee56afedc

View File

@@ -35,6 +35,9 @@ interface QrStatusResponse {
export class CreatePage {
private http = inject(HttpClient);
private i18n = inject(TranslationService);
private readonly parentRedirects: Record<string, string> = {
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);