api changes
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user