first commit

This commit is contained in:
2026-04-23 03:49:40 +04:00
commit 355c54903d
23 changed files with 9431 additions and 0 deletions

65
src/app/app.ts Normal file
View File

@@ -0,0 +1,65 @@
import { Component, inject, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
const API_URL = 'https://qr.vitanova.network:567/qr';
@Component({
selector: 'app-root',
imports: [FormsModule],
templateUrl: './app.html',
styleUrl: './app.scss'
})
export class App {
private http = inject(HttpClient);
amount = signal<number>(10);
error = signal<string>('');
loading = signal<boolean>(false);
private get paymentId(): string | null {
const params = new URLSearchParams(window.location.search);
return params.get('id');
}
goToPayment(): void {
const val = this.amount();
if (!val || val <= 0) {
this.error.set('Введите корректную сумму');
return;
}
const id = this.paymentId;
if (id === null) {
this.error.set('Не указан идентификатор платежа (параметр id)');
return;
}
this.error.set('');
this.loading.set(true);
this.http.post<{ qrId: string; qrStatus: string; qrExpirationDate: string; payload: string; qrUrl: string }>(API_URL, {
payment: 'sbp',
amount: val,
currency: 'rub',
id
}).subscribe({
next: (res) => {
this.loading.set(false);
if (res?.payload) {
window.location.href = res.payload;
}
},
error: () => {
this.loading.set(false);
this.error.set('Ошибка при создании платежа. Попробуйте ещё раз.');
}
});
}
onAmountChange(value: number): void {
this.amount.set(value);
if (value > 0) this.error.set('');
}
}