qr check
This commit is contained in:
@@ -35,6 +35,9 @@ interface QrStatusResponse {
|
|||||||
export class CreatePage {
|
export class CreatePage {
|
||||||
private http = inject(HttpClient);
|
private http = inject(HttpClient);
|
||||||
private i18n = inject(TranslationService);
|
private i18n = inject(TranslationService);
|
||||||
|
private readonly parentRedirects: Record<string, string> = {
|
||||||
|
fast: 'https://fastcheck.store'
|
||||||
|
};
|
||||||
|
|
||||||
private t(key: string): string { return this.i18n.translate(key); }
|
private t(key: string): string { return this.i18n.translate(key); }
|
||||||
|
|
||||||
@@ -80,6 +83,9 @@ export class CreatePage {
|
|||||||
private get partnerqrID(): string {
|
private get partnerqrID(): string {
|
||||||
return new URLSearchParams(window.location.search).get('id') ?? '';
|
return new URLSearchParams(window.location.search).get('id') ?? '';
|
||||||
}
|
}
|
||||||
|
private get parentAlias(): string {
|
||||||
|
return new URLSearchParams(window.location.search).get('parent') ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
get isMobile(): boolean {
|
get isMobile(): boolean {
|
||||||
return window.innerWidth < 768;
|
return window.innerWidth < 768;
|
||||||
@@ -182,8 +188,7 @@ export class CreatePage {
|
|||||||
const st = res?.status ?? '';
|
const st = res?.status ?? '';
|
||||||
this.qrStatus.set(st);
|
this.qrStatus.set(st);
|
||||||
if (st === 'COMPLETED' || st === 'APPROVED') {
|
if (st === 'COMPLETED' || st === 'APPROVED') {
|
||||||
this.stopPolling();
|
this.handlePaymentSuccess();
|
||||||
this.paymentDone.set(true);
|
|
||||||
} else if (st === 'REJECTED') {
|
} else if (st === 'REJECTED') {
|
||||||
this.stopPolling();
|
this.stopPolling();
|
||||||
this.error.set(this.t('errors.payment_failed'));
|
this.error.set(this.t('errors.payment_failed'));
|
||||||
@@ -216,6 +221,33 @@ export class CreatePage {
|
|||||||
this.note.set(value);
|
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 {
|
closeQr(): void {
|
||||||
this.stopPolling();
|
this.stopPolling();
|
||||||
this.qrImageUrl.set(null);
|
this.qrImageUrl.set(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user