api change
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Observable, timer } from 'rxjs';
|
||||
import { map, retry } from 'rxjs/operators';
|
||||
import { Category, Item, Subcategory } from '../models';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
export interface PaymentCreateRequest {
|
||||
export interface QrCreateRequest {
|
||||
qrtype: 'QRDynamic';
|
||||
amount: number;
|
||||
currency: string;
|
||||
siteuserID: string;
|
||||
siteorderID: string;
|
||||
redirectUrl: string;
|
||||
telegramUsername: string;
|
||||
items: Array<{ itemID: number; price: number; name: string; quantity?: number }>;
|
||||
currency: 'RUB';
|
||||
partnerqrID: string;
|
||||
qrDescription?: string;
|
||||
Userid?: string;
|
||||
Reference?: string;
|
||||
RedirectUrl?: string;
|
||||
}
|
||||
|
||||
export interface QrCreateResponse {
|
||||
@@ -33,7 +34,7 @@ export interface QrCreateResponse {
|
||||
PartnerID?: string | number;
|
||||
}
|
||||
|
||||
export interface PaymentStatusResponse {
|
||||
export interface QrDynamicStatusResponse {
|
||||
additionalInfo: string;
|
||||
paymentPurpose: string;
|
||||
amount: number;
|
||||
@@ -53,6 +54,7 @@ export interface PaymentStatusResponse {
|
||||
})
|
||||
export class ApiService {
|
||||
private readonly baseUrl = environment.apiUrl;
|
||||
private readonly qrBaseUrl = (environment as any).qrApiUrl as string;
|
||||
|
||||
private readonly retryConfig = {
|
||||
count: 2,
|
||||
@@ -391,12 +393,21 @@ export class ApiService {
|
||||
return this.http.post<{ message: string }>(`${this.baseUrl}/items/${itemID}/questiion`, body);
|
||||
}
|
||||
|
||||
createPayment(payload: PaymentCreateRequest): Observable<QrCreateResponse> {
|
||||
return this.http.post<QrCreateResponse>(`${this.baseUrl}/cart`, payload);
|
||||
createPayment(payload: QrCreateRequest, headers?: { authorizationKey?: string; userIdValue?: string }): Observable<QrCreateResponse> {
|
||||
let httpHeaders = new HttpHeaders();
|
||||
if (headers?.authorizationKey) {
|
||||
httpHeaders = httpHeaders.set('authorization-key', headers.authorizationKey);
|
||||
}
|
||||
if (headers?.userIdValue) {
|
||||
httpHeaders = httpHeaders.set('userid-value', headers.userIdValue);
|
||||
}
|
||||
return this.http.post<QrCreateResponse>(`${this.qrBaseUrl}/qr`, payload, { headers: httpHeaders });
|
||||
}
|
||||
|
||||
checkPaymentStatus(qrId: string): Observable<PaymentStatusResponse> {
|
||||
return this.http.get<PaymentStatusResponse>(`${this.baseUrl}/qr/payment/${encodeURIComponent(qrId)}`);
|
||||
checkPaymentStatus(partnerQrId: string, qrId: string): Observable<QrDynamicStatusResponse> {
|
||||
return this.http.get<QrDynamicStatusResponse>(
|
||||
`${this.qrBaseUrl}/qr/dynamic/${encodeURIComponent(partnerQrId)}/${encodeURIComponent(qrId)}`
|
||||
);
|
||||
}
|
||||
|
||||
resolvePaymentQrId(response: QrCreateResponse): string {
|
||||
|
||||
Reference in New Issue
Block a user