@@ -18,15 +18,18 @@ interface SettingsResponse {
|
|||||||
|
|
||||||
interface CreateQrResponse {
|
interface CreateQrResponse {
|
||||||
qrId?: string;
|
qrId?: string;
|
||||||
payload?: string; // raw QR data string to encode
|
nspkID?: string;
|
||||||
qrUrl?: string; // pre-rendered image URL (if provided)
|
Payload?: string; // per API doc (capital P)
|
||||||
Status?: boolean;
|
nspkurl?: string; // actual field name in real responses
|
||||||
|
qrUrl?: string;
|
||||||
|
qrStatus?: string;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface QrStatusResponse {
|
interface QrStatusResponse {
|
||||||
qrStatus?: string; // e.g. "PAID"
|
status?: string; // "NEW" | "APPROVED" | "REJECTED" | "COMPLETED"
|
||||||
Status?: boolean;
|
nspkurl?: string;
|
||||||
|
nspkID?: string;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,14 +157,16 @@ export class CreatePage {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (res) => {
|
next: (res) => {
|
||||||
this.loading.set(false);
|
this.loading.set(false);
|
||||||
if (res?.qrId || res?.payload || res?.qrUrl) {
|
const qrId = res?.qrId ?? res?.nspkID ?? '';
|
||||||
this.activeQrId = res.qrId ?? '';
|
// Real API uses 'nspkurl'; doc says 'Payload' — try both
|
||||||
// Use server-provided image URL or generate one from payload string.
|
const nspkUrl = res?.nspkurl ?? res?.Payload;
|
||||||
const qrData = res.qrUrl ?? (res.payload
|
if (qrId || nspkUrl) {
|
||||||
? `https://api.qrserver.com/v1/create-qr-code/?size=240x240&margin=8&data=${encodeURIComponent(res.payload)}`
|
this.activeQrId = qrId;
|
||||||
: null);
|
const qrData = nspkUrl
|
||||||
|
? `https://api.qrserver.com/v1/create-qr-code/?size=256x256&margin=8&data=${encodeURIComponent(nspkUrl)}`
|
||||||
|
: (res.qrUrl ?? null);
|
||||||
this.qrImageUrl.set(qrData);
|
this.qrImageUrl.set(qrData);
|
||||||
if (this.activeQrId) this.startPolling(this.activeQrId);
|
if (qrId) this.startPolling(qrId);
|
||||||
} else {
|
} else {
|
||||||
this.error.set(this.t('errors.payment_failed'));
|
this.error.set(this.t('errors.payment_failed'));
|
||||||
}
|
}
|
||||||
@@ -181,10 +186,14 @@ export class CreatePage {
|
|||||||
this.http.get<QrStatusResponse>(`${QR_VITANOVA_API}/qr/dynamic/${qrId}`)
|
this.http.get<QrStatusResponse>(`${QR_VITANOVA_API}/qr/dynamic/${qrId}`)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (res) => {
|
next: (res) => {
|
||||||
const paid = res?.qrStatus === 'PAID' || res?.Status === true;
|
// API returns status: "NEW" | "APPROVED" | "REJECTED" | "COMPLETED"
|
||||||
if (paid) {
|
if (res?.status === 'COMPLETED' || res?.status === 'APPROVED') {
|
||||||
this.stopPolling();
|
this.stopPolling();
|
||||||
this.createFastcheck();
|
this.createFastcheck();
|
||||||
|
} else if (res?.status === 'REJECTED') {
|
||||||
|
this.stopPolling();
|
||||||
|
this.error.set(this.t('errors.payment_failed'));
|
||||||
|
this.qrImageUrl.set(null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: () => undefined
|
error: () => undefined
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ interface WebSessionResponse {
|
|||||||
|
|
||||||
interface CheckFastcheckResponse {
|
interface CheckFastcheckResponse {
|
||||||
fastcheck: string;
|
fastcheck: string;
|
||||||
amount?: number;
|
amount?: number; // not in doc but server may include it
|
||||||
expiration: string;
|
expiration: string;
|
||||||
Status: boolean;
|
Status: boolean;
|
||||||
message?: string;
|
message?: string;
|
||||||
@@ -237,13 +237,17 @@ export class FastcheckPage {
|
|||||||
this.fastcheckAmount.set(null);
|
this.fastcheckAmount.set(null);
|
||||||
this.codeEnabled.set(false);
|
this.codeEnabled.set(false);
|
||||||
|
|
||||||
|
// API doc: GET /fastcheck with fastcheck as query param
|
||||||
this.http
|
this.http
|
||||||
.get<CheckFastcheckResponse>(`${FASTCHECK_API}/fastcheck/${encodeURIComponent(number)}`)
|
.get<CheckFastcheckResponse>(`${FASTCHECK_API}/fastcheck`, {
|
||||||
|
params: { fastcheck: number }
|
||||||
|
})
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (res) => {
|
next: (res) => {
|
||||||
this.amountLoading.set(false);
|
this.amountLoading.set(false);
|
||||||
if (res?.Status && typeof res.amount === 'number') {
|
if (res?.Status) {
|
||||||
this.fastcheckAmount.set(res.amount);
|
// amount may or may not be in response — show if present
|
||||||
|
this.fastcheckAmount.set(typeof res.amount === 'number' ? res.amount : null);
|
||||||
this.codeEnabled.set(true);
|
this.codeEnabled.set(true);
|
||||||
} else {
|
} else {
|
||||||
this.error.set(res?.message ?? this.t('errors.not_found'));
|
this.error.set(res?.message ?? this.t('errors.not_found'));
|
||||||
|
|||||||
Reference in New Issue
Block a user