api changes

This commit is contained in:
sdarbinyan
2026-06-06 22:38:01 +04:00
parent 9b5c2dd95c
commit 80cc90d347
2 changed files with 45 additions and 75 deletions

View File

@@ -34,6 +34,16 @@ export interface QrCreateResponse {
PartnerID?: string | number;
}
export interface CartPaymentRequest {
amount: number;
currency: 'RUB';
siteuserID: string;
siteorderID: string;
redirectUrl: string;
telegramUsername: string;
items: Array<{ itemID: number; price: number; name: string }>;
}
export interface QrDynamicStatusResponse {
additionalInfo: string;
paymentPurpose: string;
@@ -49,19 +59,13 @@ export interface QrDynamicStatusResponse {
qrExpirationDate: string;
}
export interface QrPaymentStatusResponse {
status?: string;
paymentStatus?: string;
code?: string;
}
@Injectable({
providedIn: 'root'
})
export class ApiService {
private readonly baseUrl = environment.apiUrl;
private readonly qrBaseUrl = (environment as any).qrApiUrl as string;
private readonly sbpQrUrl = 'https://qr.vitanova.network/api/qr';
private readonly cartPaymentPartnerId = 'web-97ec-9c57-4dde-9037-3a68f7f83750';
private readonly retryConfig = {
count: 2,
@@ -411,13 +415,14 @@ export class ApiService {
return this.http.post<QrCreateResponse>(`${this.qrBaseUrl}/qr`, payload, { headers: httpHeaders });
}
createSbpPayment(payload: QrCreateRequest): Observable<QrCreateResponse> {
return this.http.post<QrCreateResponse>(this.sbpQrUrl, payload);
createCartPayment(payload: CartPaymentRequest): Observable<QrCreateResponse> {
return this.http.post<QrCreateResponse>(`${this.baseUrl}/cart`, payload);
}
checkSbpPaymentStatus(paymentId: string): Observable<QrPaymentStatusResponse> {
const params = new HttpParams().set('id', paymentId);
return this.http.get<QrPaymentStatusResponse>(this.sbpQrUrl, { params });
checkCartPaymentStatus(qrId: string): Observable<QrDynamicStatusResponse> {
return this.http.get<QrDynamicStatusResponse>(
`${this.qrBaseUrl}/qr/dynamic/${this.cartPaymentPartnerId}/${encodeURIComponent(qrId)}`
);
}
checkPaymentStatus(partnerQrId: string, qrId: string): Observable<QrDynamicStatusResponse> {