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