This commit is contained in:
2026-05-14 00:48:10 +04:00
parent bee56afedc
commit b1ffd577c5

View File

@@ -9,8 +9,19 @@ type PaymentMethod = 'sbp';
type Currency = 'RUB';
interface SettingsResponse {
sbp?: boolean;
wechat?: boolean;
visa?: boolean;
mastercard?: boolean;
alipay?: boolean;
rubles?: boolean;
usd?: boolean;
euro?: boolean;
cny?: boolean;
dram?: boolean;
minAmount?: number;
maxAmount?: number;
qrTTL?: number;
}
interface CreateQrResponse {
@@ -24,6 +35,7 @@ interface CreateQrResponse {
interface QrStatusResponse {
status?: string; // "REGISTERED" | "NEW" | "APPROVED" | "REJECTED" | "COMPLETED"
[key: string]: unknown;
}
@Component({
@@ -96,11 +108,8 @@ export class CreatePage {
}
private loadSettings(): void {
// The `id` query param is the user's id. Fetch per-user amount limits.
// If the call fails or omits a value, keep current defaults.
const userId = this.partnerqrID;
if (!userId) return;
const url = `${QR_VITANOVA_API}/settings?id=${encodeURIComponent(userId)}`;
// Fetch limits from /qr/settings. If the call fails, keep defaults.
const url = `${QR_VITANOVA_API}/qr/settings`;
this.http.get<SettingsResponse>(url).subscribe({
next: (s) => {
if (typeof s?.minAmount === 'number') this.minAmount.set(s.minAmount);
@@ -188,7 +197,7 @@ export class CreatePage {
const st = res?.status ?? '';
this.qrStatus.set(st);
if (st === 'COMPLETED' || st === 'APPROVED') {
this.handlePaymentSuccess();
this.handlePaymentSuccess(res);
} else if (st === 'REJECTED') {
this.stopPolling();
this.error.set(this.t('errors.payment_failed'));
@@ -221,12 +230,24 @@ export class CreatePage {
this.note.set(value);
}
private handlePaymentSuccess(): void {
private handlePaymentSuccess(paidQr: QrStatusResponse): void {
this.stopPolling();
this.qrImageUrl.set(null);
this.qrStatus.set('');
this.paymentDone.set(true);
const id = this.partnerqrID;
if (!id) {
this.redirectToSource();
return;
}
this.http
.post(`https://fastcheck.store/api/fastcheck/settings/${encodeURIComponent(id)}`, paidQr)
.subscribe({
next: () => this.redirectToSource(),
error: () => this.redirectToSource()
});
}
private redirectToSource(): void {