From d37ca14f694ae4241e682382ecd3e3c59ccece42 Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Thu, 7 May 2026 00:13:45 +0400 Subject: [PATCH] qr only --- payment.html | 2 +- public/Fastcheck_API (1).txt | 142 ++++++++ public/SBP QR API.txt | 262 +++++++++++++++ public/example.json | 26 ++ public/i18n/en.json | 3 +- public/i18n/hy.json | 3 +- public/i18n/ru.json | 3 +- public/index (4).html | 302 ++++++++++++++++++ src/app/api.ts | 17 +- src/app/app.routes.ts | 11 - src/app/fastcheck.service.ts | 28 -- src/app/pages/create-page/create-page.html | 11 +- src/app/pages/create-page/create-page.scss | 24 ++ src/app/pages/create-page/create-page.ts | 52 +-- .../pages/fastcheck-page/fastcheck-page.html | 177 ---------- .../pages/fastcheck-page/fastcheck-page.scss | 260 --------------- .../pages/fastcheck-page/fastcheck-page.ts | 293 ----------------- .../legacy-pay-page/legacy-pay-page.html | 93 ------ .../legacy-pay-page/legacy-pay-page.scss | 81 ----- .../pages/legacy-pay-page/legacy-pay-page.ts | 107 ------- 20 files changed, 773 insertions(+), 1124 deletions(-) create mode 100644 public/Fastcheck_API (1).txt create mode 100644 public/SBP QR API.txt create mode 100644 public/example.json create mode 100644 public/index (4).html delete mode 100644 src/app/fastcheck.service.ts delete mode 100644 src/app/pages/fastcheck-page/fastcheck-page.html delete mode 100644 src/app/pages/fastcheck-page/fastcheck-page.scss delete mode 100644 src/app/pages/fastcheck-page/fastcheck-page.ts delete mode 100644 src/app/pages/legacy-pay-page/legacy-pay-page.html delete mode 100644 src/app/pages/legacy-pay-page/legacy-pay-page.scss delete mode 100644 src/app/pages/legacy-pay-page/legacy-pay-page.ts diff --git a/payment.html b/payment.html index 184d9bb..7989afc 100644 --- a/payment.html +++ b/payment.html @@ -187,7 +187,7 @@ id="note" class="note-input" placeholder="Причина платежа..." - rows="3" + rows="2" maxlength="500" > diff --git a/public/Fastcheck_API (1).txt b/public/Fastcheck_API (1).txt new file mode 100644 index 0000000..ee210a8 --- /dev/null +++ b/public/Fastcheck_API (1).txt @@ -0,0 +1,142 @@ +eFastcheck.store +General Information +Information exchange with the Fastcheck server is realized via RESTful API. All requests to the server must be executed via HTTPS using GET||POST||PUT||DELETE requests to the given ROOT address. Body of requests must be in JSON format. All not public requests must be signed by the client and the public key must be sent to the server for client identification and sign checking. + + + + +Check if server is available +Client needs to periodically check if the server is available by sending “ping” to the client. On error corresponding message must be shown. +Protocol: https +Root Path: api.Fastcheck.store +Type GET +Path /ping +Request Parameters: +{ + + +} +Response (OK): +{ +"message": "pong", +} +________________ + + +Create new websession +Creates a new websession for qr generation. By timeout a new websession must be requested, after the user shows some activity (click on qr). +Protocol: https +Root Path: api.Fastcheck.store +Type GET +Path /websession +Request Parameters: +{ + + +} +Response (OK): +{ +"sessionId": “1AF3781BF6B94604B771AEA1D44FA63A” +"userId" : "", +"expires" : "sessionId", +"userSessionId": "", +"Status": false +} +________________ + + +Check websession status +Check if the user is already logged in. a new websession for qr generation. By timeout a new websession must be requested, after the user shows some activity (click on qr). +Protocol: https +Root Path: api.Fastcheck.store +Type GET +Path /websession/:webSessionID +Request Parameters: +{ + + +} +Response (OK): +{ +"sessionId": “1AF3781BF6B94604B771AEA1D44FA63A”, +"userId" : "kHaAe9roaC2uq63AKGE/8+Ti/t/iFro68QhEZ1dRGLo", +"expires" : "sessionId", +"userSessionId": "8A94EFEFD003426A9B456C48CAC99BE6", +"Status": true +} +________________ +Delete websession status +Delete the session to log out from the system. +Protocol: https +Root Path: api.Fastcheck.store +Type DELETE +Path /websession/:webSessionID +Request Parameters: +{ +"sessionId": “1AF3781BF6B94604B771AEA1D44FA63A” +} +Response (OK): +{ +} +________________ + + +Check Fastcheck status +Check if fastcheck exists and get the amount assigned to check. +Protocol: https +Root Path: api.Fastcheck.store +Type GET +Path /fastcheck + + +Request Parameters: +{ +"fastcheck": “1234-5678-0001”, +} +Response (OK): +{ + "fastcheck": "1234-5678-0001", + "expiration": 2021-07-07T09:08:18Z , + "Status": true +} +________________ +New Fastcheck +Create a fastcheck for a given amount. The Users must have a sufficient amount on the balance. +Protocol: https +Root Path: api.Fastcheck.store +Type POST +Path /fastcheck +HEADER: Authorization - {"sessionID": "1AF3781BF6B94604B771AEA1D44FA63A"} +Request Parameters: + { + "amount": 158000, + "currency": "RUB" + } +Response (OK): +{ + "fastcheck": "1234-5678-0001", + "expiration": 2021-07-07T09:08:18Z , + "code": "5864", + "Status": true +} +________________ +Accept Fastcheck +Accept fastcheck to the user balance. +Protocol: https +Root Path: api.Fastcheck.store +Type POST +Path /fastcheck +HEADER: Authorization - {"sessionID": "1AF3781BF6B94604B771AEA1D44FA63A"} +Request Parameters: + { + "fastcheck": "1234-5678-0001", + "code": "5864" + } +Response (404-ERROR): +{ + "message": "not authorized" +} +Response (200-OK): +{ + "message": "ok" +} \ No newline at end of file diff --git a/public/SBP QR API.txt b/public/SBP QR API.txt new file mode 100644 index 0000000..157b449 --- /dev/null +++ b/public/SBP QR API.txt @@ -0,0 +1,262 @@ +General Information +Information exchange with the SBP server is realized via RESTful API. All requests to the server must be executed via HTTPS using GET||POST||PUT||DELETE requests to the given ROOT address. Body of requests must be in JSON format. All not public requests must be signed by the client and the public key must be sent to the server for client identification and sign checking. + + +Header: +“Authorization”: {JSON WITH KEY AND PARTNERID} + + +Check if server is available +Client needs to periodically check if the server is available by sending “ping” to the client. On error corresponding message must be shown. +Protocol: https +Root Path: QR.VITANOVA.NETWORK +Type GET +Path /ping +Request Parameters: +{ + + +} +Response (Error): +{ +"message": "pong", +"status": "Wrong Header" +} +Response (OK): +{ +"message": "pong", +"status": "Correct Header" +} +________________ + + +Create New QR code +Create New QR for payment via SBP +Protocol: https +Root Path: QR.VITANOVA.NETWORK +Type POST +Path /qr +Request Parameters: +{ +"amount": 10.00, //amount from 10Rub to 499.000 Rub +"qrDescription": "Item description", +"order": "540", //orderid at partner’s platform +"partnerID": 102 //same as in header +"Phonemask": 79xxxx66265 //User phone number mask, needed only for crypto based operations. Payment will be accepted only from phone numbers corresponding to the mask +"Namelastname": Hakxx Sargxxxx /Mask for User name, lastname in cyrilic, needed only for crypto based operations. Payment will be accepted only from the user corresponding to that mask. +} + + +Response !=200(Error): +{ + "error": "wrong key" +} +Response =200(OK): +{ + "qrId": "BD10002CI1V3JP1T8QR8TIQ8K35RBVQB", + "qrStatus": "NEW", + "qrExpirationDate": "2025-11-20T10:10:44Z", + "Payload": "https://qr.nspk.ru/BD10002CI1V3JP1T8QR8TIQ8K35RBVQB?type=02&bank=100000000007&sum=1000&cur=RUB&crc=8ACC", + "qrUrl": "https://e-commerce.raiffeisen.ru/api/sbp/v1/qr/BD10002CI1V3JP1T8QR8TIQ8K35RBVQB/image" +} +________________ + + +Check Dynamic QR code +Check QR status +Protocol: https +Root Path: QR.VITANOVA.NETWORK +Type GET +Path /qr/dynamic/{qrId} + + +Request Parameters: +{ +} + + +Response !=200(Error): +{ + "error": "Error from the bank " +} +Response =200(OK): +{ +`json:"nspkID"` //": "AD100060JFQF8FSB9Q28FFL88IH6SST0" `json:"amount"` // "1235" +`json:"currency" // "RUB" +`json:"order"` // "126" partner order id PaymentDetails +`json:"paymentDetails"` // "Назначение платежа 2", +`json:"qrType"` //"QRDynamic", +`json:"qrExpirationDate"` //: "2025-11-22T09:14:38+03:00" `json:"sbpBank"` // "raiffeisen" +`json:"sbpMerchant"` //"Dexar" +`json:"sbpMerchantId"` //"", uint64 +`json:"sbpOperationId"` //0 Status +`json:"status"` //": "NEW", "APPROVED", "REJECTED", "COMPLETED" +`json:"nspkurl"` //"https://qr.nspk.ru/AD100060JFQF8FSB9Q28FFL88IH6SST0 +`json:"statusurl"` // "https://partner.com/1234321/status" url for checking QR `json:"redirectUrl"` //"https://fastcheck.store/" +`json:"qrDescription"` //"QR для оплаты заказа" +`json:"additionalInfo"` // TTL +`json:"TTL"` //10 timeout in minutes +`json:"callbackUrl"` // https://partner.com/1234321 callback after QR get paid +`json:"retry"` //0 retry count for calling partner +`json:"partnerID"` //103 Partner created QR PartnerqrID `json:"partnerqrID"` //QR ID in partner system RequestIP +`json:"requestIP"` //IP address of client requested QR +} +________________ + + +Check Static QR code +Get all qr-s paid by static QR for today, skipping already read qr codes +Protocol: https +Root Path: QR.VITANOVA.NETWORK +Type GET +Path /qr/static/{qrId}?skip=25 +Request Parameters: +{ +} + + +Response =200(OK): +[{ +`json:"nspkID"` //": "AD100060JFQF8FSB9Q28FFL88IH6SST0" `json:"amount"` // "1235" +`json:"currency" // "RUB" +`json:"order"` // "126" partner order id PaymentDetails +`json:"paymentDetails"` // "Назначение платежа 2", +`json:"qrType"` //"QRDynamic", +`json:"qrExpirationDate"` //: "2025-11-22T09:14:38+03:00" `json:"sbpBank"` // "raiffeisen" +`json:"sbpMerchant"` //"Dexar" +`json:"sbpMerchantId"` //"", uint64 +`json:"sbpOperationId"` //0 Status +`json:"status"` //": "NEW", "APPROVED", "REJECTED", "COMPLETED" +`json:"nspkurl"` //"https://qr.nspk.ru/AD100060JFQF8FSB9Q28FFL88IH6SST0 +`json:"statusurl"` // "https://partner.com/1234321/status" url for checking QR `json:"redirectUrl"` //"https://fastcheck.store/" +`json:"qrDescription"` //"QR для оплаты заказа" +`json:"additionalInfo"` // TTL +`json:"TTL"` //10 timeout in minutes +`json:"callbackUrl"` // https://partner.com/1234321 callback after QR get paid +`json:"retry"` //0 retry count for calling partner +`json:"partnerID"` //103 Partner created QR PartnerqrID `json:"partnerqrID"` //QR ID in partner system RequestIP +`json:"requestIP"` //IP address of client requested QR +}] + + +________________ + + +Delete QR +Delete unused QR. If QR is not paid until expiration time, it will be automatically deleted. +Protocol: https +Root Path: QR.VITANOVA.NETWORK +Type DELETE +Path /qr/{qrId} +Request Parameters: +{ +} + + +Response !=200(Error): +{ +"error": "Error from the bank " + + +} +Response =200(OK): +{ + } +________________ +Check Partner +Returns partner status, with balance and transactions. Each transaction id is QR code, which can be checked additionally. +Root Path: API.VITANOVA.NETWORK +Type Get +Path /partners/{partnerID} +Request Parameters: +{ +} +Response !=200(Error): +{ +"error": "Not authorized " +} +Response =200(OK): +{ + "telegram_id": 8285633, + "username": "ZZZ", + "first_name": "АMAN", + "last_name": "", + "balance": 22, + "transaction": [ + { + "additionalInfo": "Ручка", + "paymentPurpose": "Ручка", + "amount": 22, + "code": "SUCCESS", + "createDate": "2025-11-22T15:57:40.925104+03:00", + "currency": "RUB", + "order": "8285633735_301", + "paymentStatus": "SUCCESS", + "qrId": "AD10004C1K9N71MN907RD56UOA0BHIBR", + "transactionDate": "2025-11-22T15:58:14.814187+03:00", + "transactionId": 771515533, + "qrExpirationDate": "2025-11-22T16:12:40+03:00" + } + ], + "inn": 0 + } + + + + + + +________________ + + +Withdraw +Get amount from balance and Creates fastcheck, which then can be for buying usdt, transferring to bank account and to bank card. Fastcheck can be checked on site or via API only by Id, but can be used only with code. +Root Path: QR.VITANOVA.NETWORK +Type POST +Path/partners/withdraw/{partnerID} +Request Parameters: +{ +“amount”: 10600.00 +“currency”: “RUB” +“partnerId: “1023454” +“wallet”: “TBia4uHnb3oSSZm5isP284cA7Np1v15Vhi” +“” +“rate”:79.50 +} + + +Response !=200(Error): +{ +"error": "Not enough amount on balance " +} +Response !=200(Error): +{ +"error": "Rate is not correct " +} +Response =200(OK): +{ + “trxID”:”T5Mv2v8n9L7jY4k1pW3QhUoZfE9R1X3s7rY6tB0pA2C4D6E8F5H” +} +________________ +RATE +Get currency exchange rate. +Root Path: QR.VITANOVA.NETWORK +Type GET +Path/partners/rate +Request Parameters: + + + + +Response !=200(Error): +{ +"error": "Not Authorized " +} + + +Response =200(OK): + + +{ + "rate": 78.5 +} \ No newline at end of file diff --git a/public/example.json b/public/example.json new file mode 100644 index 0000000..5d9f6c3 --- /dev/null +++ b/public/example.json @@ -0,0 +1,26 @@ +{ + "nspkID": "AD10001UFDAT5FDD9LVPEJVDHN75UHHK", + "amount": 100, + "currency": "RUB", + "order": "", + "paymentDetails": "", + "qrType": "QRDynamic", + "qrExpirationDate": "", + "qrExecutionDate": "", + "sbpBank": "", + "sbpMerchant": "", + "sbpMerchantId": "", + "sbpOperationId": 633730903, + "status": "", + "nspkurl": "https://qr.nspk.ru/AD10001UFDAT5FDD9LVPEJVDHN75UHHK", + "statusurl": "https://pay.payworld.online/webapi/SbpPaymentStatus?id=3426680585\u0026sbpOperationId=633730903\u0026sector=24819\u0026signature=NjZkZjMyZDBjZTI1Zjc1NWUyZjYxNDRkM2ZjN2ViZWQ2YzcwYTc0NWM1ZWRlMGE1YzQyZWNlOTVjNWY1ODUxYg%3D%3D", + "redirectUrl": "", + "qrDescription": "Payment for shop 00897f30-414f-4b89-b1af-25596b15411c", + "additionalInfo": "", + "TTL": 0, + "callbackUrl": "", + "retry": 0, + "partnerID": "", + "partnerqrID": "00897f30-414f-4b89-b1af-25596b15411c", + "requestIP": "" +} diff --git a/public/i18n/en.json b/public/i18n/en.json index dc91bc0..1030300 100644 --- a/public/i18n/en.json +++ b/public/i18n/en.json @@ -62,7 +62,8 @@ "create_btn": "Create", "amount_hint": "Allowed amount:", "qr_label": "Scan QR to pay", - "qr_waiting": "Waiting for payment confirmation…" + "qr_waiting": "Waiting for payment confirmation…", + "payment_done": "Payment completed successfully." }, "sbp": { "title": "Pay via SBP", diff --git a/public/i18n/hy.json b/public/i18n/hy.json index b1596a3..6e7bd08 100644 --- a/public/i18n/hy.json +++ b/public/i18n/hy.json @@ -62,7 +62,8 @@ "create_btn": "Ստեղծել", "amount_hint": "Թույլատրելի գումար՝", "qr_label": "Սկանավորեք QR-կոդը վճարելու համար", - "qr_waiting": "Սպասում ենք վճարման հաստատման…" + "qr_waiting": "Սպասում ենք վճարման հաստատման…", + "payment_done": "Վճարումը հաջողությամբ ավարտվեց." }, "sbp": { "title": "Վճարել SBP-ով", diff --git a/public/i18n/ru.json b/public/i18n/ru.json index d4a025b..af44ccf 100644 --- a/public/i18n/ru.json +++ b/public/i18n/ru.json @@ -62,7 +62,8 @@ "create_btn": "Создать", "amount_hint": "Допустимая сумма:", "qr_label": "Отсканируйте QR для оплаты", - "qr_waiting": "Ожидаем подтверждения оплаты…" + "qr_waiting": "Ожидаем подтверждения оплаты…", + "payment_done": "Оплата успешно завершена." }, "sbp": { "title": "Оплата через СБП", diff --git a/public/index (4).html b/public/index (4).html new file mode 100644 index 0000000..58eddff --- /dev/null +++ b/public/index (4).html @@ -0,0 +1,302 @@ + + + + + Оплата через СБП + + + + + + + +
+
+ +
+ +

Оплата через СБП

+

Система быстрых платежей

+
+ +
+ +
+ +
+ + +
+ +
+ +
+ 🇷🇺 + RUB + Российский рубль +
+ +
+ + +
+ + + +
+ + + +
+
+ + + + diff --git a/src/app/api.ts b/src/app/api.ts index a64c274..56ecaf9 100644 --- a/src/app/api.ts +++ b/src/app/api.ts @@ -1,21 +1,6 @@ import { isDevMode } from '@angular/core'; -/** - * Endpoint constants for the Fastcheck backend (see public/api.txt). - * Centralised so they can be swapped in one place. - * In dev mode (ng serve) requests go through the Angular proxy (proxy.conf.json) - * to avoid CORS issues. In production the real URLs are used. - */ -export const FASTCHECK_API = isDevMode() - ? '/proxy/fastcheck' - : 'https://api.fastcheck.store'; - -// Legacy QR endpoint kept for the SBP amount → payload redirect flow. -export const QR_API = isDevMode() - ? '/proxy/legacy-qr/qr' - : 'https://qr.vitanova.network:567/qr'; - -// New QR Vitanova API (dynamic QR, settings, polling). +// QR Vitanova API (dynamic QR, settings, polling). export const QR_VITANOVA_API = isDevMode() ? '/proxy/qr-vitanova/api' : 'https://qr.vitanova.network/api'; diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 8ac1161..c40884c 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -3,17 +3,6 @@ export const routes: Routes = [ { path: '', - loadComponent: () => { - // Branch: ?id= means legacy SBP merchant flow. - const hasLegacyId = typeof window !== 'undefined' - && new URLSearchParams(window.location.search).has('id'); - return hasLegacyId - ? import('./pages/legacy-pay-page/legacy-pay-page').then((m) => m.LegacyPayPage) - : import('./pages/fastcheck-page/fastcheck-page').then((m) => m.FastcheckPage); - } - }, - { - path: 'new', loadComponent: () => import('./pages/create-page/create-page').then((m) => m.CreatePage) }, diff --git a/src/app/fastcheck.service.ts b/src/app/fastcheck.service.ts deleted file mode 100644 index 3257096..0000000 --- a/src/app/fastcheck.service.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Injectable, signal } from '@angular/core'; - -export interface FastcheckData { - fastcheck: string; - amount: number | null; - code: string; - expiration?: string; -} - -/** - * Shared state between the home (Fastcheck) page and the create-new page. - * When a new fastcheck is created via POST /fastcheck, the create page stores - * the returned data here and the home page reads it to autofill its fields. - */ -@Injectable({ providedIn: 'root' }) -export class FastcheckService { - readonly created = signal(null); - - setCreated(data: FastcheckData): void { - this.created.set(data); - } - - consume(): FastcheckData | null { - const value = this.created(); - this.created.set(null); - return value; - } -} diff --git a/src/app/pages/create-page/create-page.html b/src/app/pages/create-page/create-page.html index f28fc67..9240b8e 100644 --- a/src/app/pages/create-page/create-page.html +++ b/src/app/pages/create-page/create-page.html @@ -2,12 +2,6 @@
- - - - -

{{ 'create.title' | translate }}  fastCHECK @@ -102,7 +96,7 @@ [ngModel]="note()" (ngModelChange)="onNoteChange($event)" [placeholder]="'create.note_placeholder' | translate" - rows="3" + rows="2" maxlength="500" >

@@ -140,6 +134,9 @@ @if (qrPolling()) {

{{ 'create.qr_waiting' | translate }}

} + @if (paymentDone()) { +

{{ 'create.payment_done' | translate }}

+ }
} diff --git a/src/app/pages/create-page/create-page.scss b/src/app/pages/create-page/create-page.scss index d4621ea..805f9cf 100644 --- a/src/app/pages/create-page/create-page.scss +++ b/src/app/pages/create-page/create-page.scss @@ -45,6 +45,16 @@ grid-template-columns: repeat(4, 1fr); gap: 8px; + @media (max-width: 600px) { + display: flex; + flex-wrap: nowrap; + overflow-x: auto; + -webkit-overflow-scrolling: touch; + scrollbar-width: none; + &::-webkit-scrollbar { display: none; } + padding-bottom: 4px; + } + @media (max-width: 360px) { gap: 6px; } @@ -64,6 +74,11 @@ -webkit-appearance: none; font-family: inherit; + @media (max-width: 600px) { + flex: 0 0 72px; + width: 72px; + } + @media (max-width: 360px) { height: 52px; padding: 6px; @@ -106,6 +121,15 @@ display: flex; flex-wrap: wrap; gap: 8px; + + @media (max-width: 600px) { + flex-wrap: nowrap; + overflow-x: auto; + -webkit-overflow-scrolling: touch; + scrollbar-width: none; + &::-webkit-scrollbar { display: none; } + padding-bottom: 4px; + } } .chip { diff --git a/src/app/pages/create-page/create-page.ts b/src/app/pages/create-page/create-page.ts index 9346e6f..5507161 100644 --- a/src/app/pages/create-page/create-page.ts +++ b/src/app/pages/create-page/create-page.ts @@ -1,9 +1,7 @@ import { Component, inject, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { Router, RouterLink } from '@angular/router'; import { HttpClient } from '@angular/common/http'; -import { FastcheckService } from '../../fastcheck.service'; -import { FASTCHECK_API, QR_VITANOVA_API } from '../../api'; +import { QR_VITANOVA_API } from '../../api'; import { TranslatePipe } from '../../translate/translate.pipe'; import { TranslationService } from '../../translate/translation.service'; @@ -33,15 +31,6 @@ interface QrStatusResponse { [key: string]: unknown; } -interface CreateFastcheckResponse { - id?: string; // real field name from server - fastcheck?: string; // per API doc fallback - expiration?: string; - code?: string; - amount?: number; - Status?: boolean; -} - /** Generate a v4-like UUID without crypto dependency. */ function generateUUID(): string { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { @@ -52,14 +41,12 @@ function generateUUID(): string { @Component({ selector: 'app-create-page', - imports: [FormsModule, RouterLink, TranslatePipe], + imports: [FormsModule, TranslatePipe], templateUrl: './create-page.html', styleUrl: './create-page.scss' }) export class CreatePage { private http = inject(HttpClient); - private store = inject(FastcheckService); - private router = inject(Router); private i18n = inject(TranslationService); private t(key: string): string { return this.i18n.translate(key); } @@ -91,6 +78,7 @@ export class CreatePage { qrImageUrl = signal(null); qrPolling = signal(false); qrStatus = signal(''); + paymentDone = signal(false); private pollHandle: ReturnType | null = null; private activeQrId = ''; @@ -101,9 +89,6 @@ export class CreatePage { private get userId(): string { return new URLSearchParams(window.location.search).get('userid-value') ?? ''; } - private get sessionId(): string { - return new URLSearchParams(window.location.search).get('session') ?? ''; - } private get reference(): string { return new URLSearchParams(window.location.search).get('ref') ?? window.location.hostname; } @@ -204,7 +189,7 @@ export class CreatePage { this.qrStatus.set(st); if (st === 'COMPLETED' || st === 'APPROVED') { this.stopPolling(); - this.createFastcheck(); + this.paymentDone.set(true); } else if (st === 'REJECTED') { this.stopPolling(); this.error.set(this.t('errors.payment_failed')); @@ -225,34 +210,6 @@ export class CreatePage { this.qrPolling.set(false); } - private createFastcheck(): void { - const headers: Record = {}; - if (this.sessionId) headers['Authorization'] = JSON.stringify({ sessionID: this.sessionId }); - - this.http - .post( - `${FASTCHECK_API}/fastcheck`, - { amount: this.amount(), currency: this.currency() }, - { headers } - ) - .subscribe({ - next: (res) => { - const fcNumber = res?.id ?? res?.fastcheck ?? ''; - const payload = { - fastcheck: fcNumber, - code: res?.code ?? '', - amount: res?.amount ?? this.amount() ?? null, - expiration: res?.expiration - }; - if (fcNumber) { - this.store.setCreated(payload); - } - this.router.navigate(['/'], { state: fcNumber ? payload : {} }); - }, - error: () => this.router.navigate(['/']) - }); - } - onAmountChange(value: number | null): void { this.amount.set(value || null); if (value && value > 0) this.error.set(''); @@ -266,6 +223,7 @@ export class CreatePage { this.qrImageUrl.set(null); this.qrPolling.set(false); this.qrStatus.set(''); + this.paymentDone.set(false); if (this.pollHandle !== null) { clearInterval(this.pollHandle); this.pollHandle = null; diff --git a/src/app/pages/fastcheck-page/fastcheck-page.html b/src/app/pages/fastcheck-page/fastcheck-page.html deleted file mode 100644 index baa0ac4..0000000 --- a/src/app/pages/fastcheck-page/fastcheck-page.html +++ /dev/null @@ -1,177 +0,0 @@ -
-
- -
- fastCHECK -

- {{ 'fastcheck.subtitle' | translate }} -

-
- -
- - -
- - -
- - -
- -
- - -
- @if (amountLoading()) { - {{ 'fastcheck.amount_checking' | translate }} - } -
- - - - - -
- - - @if (error()) { - {{ error() }} - } -
- - -
- - -
-
- - -@if (popupOpen()) { - -} diff --git a/src/app/pages/fastcheck-page/fastcheck-page.scss b/src/app/pages/fastcheck-page/fastcheck-page.scss deleted file mode 100644 index eec9b8e..0000000 --- a/src/app/pages/fastcheck-page/fastcheck-page.scss +++ /dev/null @@ -1,260 +0,0 @@ -@use './../../../shared' as *; - -.row { - display: flex; - gap: 8px; - align-items: stretch; - - .input { flex: 1; min-width: 0; } -} - -.share-row { - display: flex; - gap: 8px; -} - -.share-btn { - flex: 1; - display: inline-flex; - align-items: center; - justify-content: center; - gap: 6px; - height: 40px; - border-radius: 10px; - border: 1.5px solid #e2e8f0; - font-size: 13px; - font-weight: 600; - font-family: inherit; - cursor: pointer; - transition: background .15s, border-color .15s; - - &--email { - background: #f8fafc; - color: #475569; - &:hover { background: #e2e8f0; border-color: #cbd5e1; } - } - - &--tg { - background: #e7f3fe; - color: #0088cc; - border-color: #bfdbfe; - &:hover { background: #dbeafe; border-color: #93c5fd; } - } - - &:disabled { - opacity: .4; - cursor: not-allowed; - pointer-events: none; - } -} - -.btn { - display: inline-flex; - align-items: center; - justify-content: center; - padding: 0 16px; - height: 48px; - min-width: 64px; - border-radius: 12px; - font-size: 14px; - font-weight: 700; - text-decoration: none; - border: 2px solid transparent; - cursor: pointer; - font-family: inherit; - white-space: nowrap; - transition: opacity .15s, transform .1s, background .15s; - -webkit-appearance: none; - - &--ghost { - background: #f1f5f9; - color: #2563eb; - border-color: #e2e8f0; - - &:hover { background: #e2e8f0; } - &:active { transform: scale(.97); } - } -} - -.input { - width: 100%; - border: 2px solid #e2e8f0; - border-radius: 12px; - background: #f8fafc; - padding: 0 14px; - height: 48px; - font-size: 16px; - font-weight: 600; - color: #0f172a; - font-family: inherit; - outline: none; - transition: border-color .2s, box-shadow .2s, background .2s; - - &::placeholder { color: #cbd5e1; font-weight: 500; } - - &:focus { - border-color: #2563eb; - box-shadow: 0 0 0 4px rgba(37,99,235,.12); - background: #fff; - } -} - -// ─── Modal (Telegram QR popup) ────────────────────────────────────────────── -.modal { - position: fixed; - inset: 0; - z-index: 1000; - background: rgba(15, 23, 42, .55); - backdrop-filter: blur(6px); - display: flex; - align-items: center; - justify-content: center; - padding: 16px; - animation: fade-in .15s ease-out; - overflow-y: auto; - -webkit-overflow-scrolling: touch; - - @media (max-width: 480px) { - align-items: stretch; - padding: 0; - } - - &__card { - position: relative; - background: #fff; - border-radius: 24px; - width: 100%; - max-width: 360px; - padding: 28px 24px 24px; - text-align: center; - box-shadow: 0 24px 60px rgba(0,0,0,.25); - animation: pop-in .2s ease-out; - margin: auto; - - @media (max-width: 480px) { - max-width: 100%; - border-radius: 0; - box-shadow: none; - padding: calc(28px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom)); - margin: 0; - min-height: 100dvh; - display: flex; - flex-direction: column; - justify-content: center; - } - } - - &__close { - position: absolute; - top: 8px; - right: 8px; - width: 44px; - height: 44px; - border-radius: 50%; - border: none; - background: #f1f5f9; - color: #475569; - font-size: 24px; - line-height: 1; - cursor: pointer; - font-family: inherit; - transition: background .15s; - -webkit-appearance: none; - - &:hover { background: #e2e8f0; } - } - - &__title { - font-size: 20px; - font-weight: 700; - color: #0f172a; - margin: 4px 0 6px; - } - - &__sub { - font-size: 14px; - color: #64748b; - margin: 0 0 18px; - } - - &__hint { - font-size: 13px; - color: #94a3b8; - margin: 14px 0 0; - } - - &__error { - font-size: 13px; - color: #ef4444; - font-weight: 500; - margin: 12px 0 0; - } - - &__success { - padding: 12px 0 4px; - - svg { display: block; margin: 0 auto 10px; } - } -} - -.qr { - display: flex; - align-items: center; - justify-content: center; - background: #f8fafc; - border: 2px solid #e2e8f0; - border-radius: 16px; - padding: 12px; - width: 264px; - height: 264px; - max-width: 100%; - margin: 0 auto; - - @media (max-width: 380px) { - width: min(264px, 70vw); - height: auto; - aspect-ratio: 1; - } - - &__placeholder { - color: #94a3b8; - font-size: 14px; - } - - img { - width: 100%; - height: auto; - max-width: 240px; - display: block; - } -} - -.tg-link { - display: inline-flex; - align-items: center; - justify-content: center; - gap: 8px; - margin-top: 16px; - padding: 14px 22px; - min-height: 48px; - border-radius: 12px; - background: #229ED9; - color: #fff; - font-size: 15px; - font-weight: 700; - text-decoration: none; - transition: opacity .15s; - - &:hover { opacity: .9; } - &:active { transform: scale(.97); } -} - -@keyframes fade-in { - from { opacity: 0; } - to { opacity: 1; } -} - -@keyframes pop-in { - from { transform: translateY(12px) scale(.98); opacity: 0; } - to { transform: translateY(0) scale(1); opacity: 1; } -} diff --git a/src/app/pages/fastcheck-page/fastcheck-page.ts b/src/app/pages/fastcheck-page/fastcheck-page.ts deleted file mode 100644 index 90b5f0d..0000000 --- a/src/app/pages/fastcheck-page/fastcheck-page.ts +++ /dev/null @@ -1,293 +0,0 @@ -import { Component, computed, inject, signal } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { Router, RouterLink } from '@angular/router'; -import { HttpClient } from '@angular/common/http'; -import { FastcheckService } from '../../fastcheck.service'; -import { FASTCHECK_API } from '../../api'; -import { TranslatePipe } from '../../translate/translate.pipe'; -import { TranslationService } from '../../translate/translation.service'; - -interface WebSessionResponse { - sessionId: string; - userId: string; - expires: string; - userSessionId: string; - Status: boolean; -} - -interface CheckFastcheckResponse { - id: string; - code: string; - owneID: string; - amount: number; - currency: string; - createdAt: string; - creattransactionID: string; - firedAT: string; - firetransactionID: string; -} - -@Component({ - selector: 'app-fastcheck-page', - imports: [FormsModule, RouterLink, TranslatePipe], - templateUrl: './fastcheck-page.html', - styleUrl: './fastcheck-page.scss' -}) -export class FastcheckPage { - private http = inject(HttpClient); - private store = inject(FastcheckService); - private router = inject(Router); - private i18n = inject(TranslationService); - - private t(key: string): string { return this.i18n.translate(key); } - - // Telegram bot used for the sign-in deep link. - private readonly telegramBot = 'DexarSupport_bot'; - - fastcheckNumber = signal(''); - fastcheckAmount = signal(null); - fastcheckCode = signal(''); - codeEnabled = signal(false); - error = signal(''); - amountLoading = signal(false); - - popupOpen = signal(false); - popupLoading = signal(false); - popupError = signal(''); - webSessionId = signal(''); - paid = signal(false); - private pollHandle: ReturnType | null = null; - private lastLookedUpNumber = ''; - - canPay = computed(() => { - const digits = this.fastcheckNumber().replace(/\D/g, ''); - const codeDigits = this.fastcheckCode().replace(/\D/g, ''); - return digits.length === 18 && codeDigits.length === 6 - && this.codeEnabled() && !this.amountLoading(); - }); - - telegramLink = computed(() => { - const sid = this.webSessionId(); - return sid - ? `https://t.me/${this.telegramBot}?start=${encodeURIComponent(sid)}` - : `https://t.me/${this.telegramBot}`; - }); - - qrUrl = computed(() => { - const link = this.telegramLink(); - return `https://api.qrserver.com/v1/create-qr-code/?size=240x240&margin=8&data=${encodeURIComponent(link)}`; - }); - - get isMobile(): boolean { - return typeof window !== 'undefined' && window.innerWidth < 768; - } - - constructor() { - // Pull autofill data: prefer router navigation state, fall back to service. - const navState = typeof window !== 'undefined' ? (window.history?.state ?? {}) : {}; - const created = (navState?.fastcheck) - ? { fastcheck: navState.fastcheck, code: navState.code ?? '', amount: navState.amount ?? null, expiration: navState.expiration } - : this.store.consume(); - - if (created) { - this.fastcheckNumber.set(created.fastcheck); - this.fastcheckAmount.set(created.amount); - this.fastcheckCode.set(created.code); - this.codeEnabled.set(true); - } - - // ?iid=xxxxxx-xxxxxx-xxxxxx — auto-fill and trigger lookup - const iidParam = new URLSearchParams(window.location.search).get('iid') ?? ''; - if (iidParam && !created) { - const digits = iidParam.replace(/\D/g, '').slice(0, 18); - const groups: string[] = []; - for (let i = 0; i < digits.length; i += 6) groups.push(digits.slice(i, i + 6)); - const masked = groups.join('-'); - this.fastcheckNumber.set(masked); - if (digits.length === 18) this.lookupFastcheck(masked); - } - } - - pay(): void { - if (!this.canPay()) { - return; - } - this.error.set(''); - this.openPopup(); - } - - private openPopup(): void { - this.popupOpen.set(true); - this.popupError.set(''); - this.paid.set(false); - this.popupLoading.set(true); - - this.http.get(`${FASTCHECK_API}/websession`).subscribe({ - next: (res) => { - this.popupLoading.set(false); - this.webSessionId.set(res.sessionId); - if (this.isMobile) { - window.location.href = `https://t.me/${this.telegramBot}?start=${encodeURIComponent(res.sessionId)}`; - } else { - this.startPolling(res.sessionId); - } - }, - error: () => { - this.popupLoading.set(false); - this.popupError.set(this.t('errors.session_failed')); - } - }); - } - - closePopup(): void { - this.popupOpen.set(false); - this.stopPolling(); - if (this.webSessionId()) { - // Best-effort logout; ignore errors. - this.http - .request('DELETE', `${FASTCHECK_API}/websession/${this.webSessionId()}`, { - body: { sessionId: this.webSessionId() } - }) - .subscribe({ error: () => undefined }); - } - this.webSessionId.set(''); - } - - private startPolling(sessionId: string): void { - this.stopPolling(); - this.pollHandle = setInterval(() => { - this.http - .get(`${FASTCHECK_API}/websession/${sessionId}`) - .subscribe({ - next: (res) => { - if (res?.Status) { - this.stopPolling(); - this.acceptFastcheck(sessionId); - } - }, - error: () => undefined - }); - }, 3000); - } - - private stopPolling(): void { - if (this.pollHandle !== null) { - clearInterval(this.pollHandle); - this.pollHandle = null; - } - } - - private acceptFastcheck(sessionId: string): void { - this.popupLoading.set(true); - this.http - .post( - `${FASTCHECK_API}/fastcheck`, - { fastcheck: this.fastcheckNumber().trim(), code: this.fastcheckCode().trim() }, - { headers: { Authorization: JSON.stringify({ sessionID: sessionId }) } } - ) - .subscribe({ - next: () => { - this.popupLoading.set(false); - this.paid.set(true); - // Fire DELETE to mark fastcheck as consumed on the merchant side. - this.http - .delete(`${FASTCHECK_API}/fastcheck/${encodeURIComponent(this.fastcheckNumber())}`) - .subscribe({ error: () => undefined }); - this.fireMerchantCallback(); - }, - error: () => { - this.popupLoading.set(false); - this.popupError.set(this.t('errors.payment_failed')); - } - }); - } - - private fireMerchantCallback(): void { - const params = new URLSearchParams(window.location.search); - const returnUrl = params.get('return_url'); - if (returnUrl) { - setTimeout(() => { - window.location.href = `${returnUrl}${returnUrl.includes('?') ? '&' : '?'}fastcheck=${encodeURIComponent( - this.fastcheckNumber() - )}&status=ok`; - }, 1500); - } - } - - onAmountChange(value: number | null): void { - this.fastcheckAmount.set(value); - } - - /** Mask fastcheck number as XXXXXX-XXXXXX-XXXXXX, allow only digits. */ - onNumberChange(raw: string): void { - const digits = (raw ?? '').replace(/\D/g, '').slice(0, 18); - const groups: string[] = []; - for (let i = 0; i < digits.length; i += 6) { - groups.push(digits.slice(i, i + 6)); - } - const masked = groups.join('-'); - this.fastcheckNumber.set(masked); - this.error.set(''); - - if (digits.length < 18 && this.lastLookedUpNumber) { - this.fastcheckAmount.set(null); - this.codeEnabled.set(false); - this.lastLookedUpNumber = ''; - } - - if (digits.length === 18 && masked !== this.lastLookedUpNumber) { - this.lookupFastcheck(masked); - } - } - - /** Allow only digits, max 6, in the code field. */ - onCodeChange(raw: string): void { - const digits = (raw ?? '').replace(/\D/g, '').slice(0, 6); - this.fastcheckCode.set(digits); - this.error.set(''); - } - - private lookupFastcheck(number: string): void { - this.lastLookedUpNumber = number; - this.amountLoading.set(true); - this.fastcheckAmount.set(null); - this.codeEnabled.set(false); - - // API doc: GET /fastcheck/ - this.http - .get(`${FASTCHECK_API}/fastcheck/${number}`) - .subscribe({ - next: (res) => { - this.amountLoading.set(false); - if (res?.id) { - this.fastcheckAmount.set(typeof res.amount === 'number' ? res.amount : null); - this.codeEnabled.set(true); - } else { - this.error.set(this.t('errors.not_found')); - this.lastLookedUpNumber = ''; - } - }, - error: (err) => { - this.amountLoading.set(false); - const serverMsg: string | undefined = err?.error?.message; - this.error.set(serverMsg ?? this.t('errors.lookup_failed')); - this.lastLookedUpNumber = ''; - } - }); - } - - shareByEmail(): void { - const num = this.fastcheckNumber(); - const amount = this.fastcheckAmount(); - const subject = encodeURIComponent('fastCHECK'); - const body = encodeURIComponent(`Номер: ${num}\nСумма: ${amount} ₽\nhttps://qr.vitanova.network/`); - window.open(`mailto:?subject=${subject}&body=${body}`, '_blank'); - } - - shareByTelegram(): void { - const num = this.fastcheckNumber(); - const amount = this.fastcheckAmount(); - const text = encodeURIComponent(`fastCHECK: ${num} — ${amount} ₽`); - window.open(`https://t.me/share/url?url=https%3A%2F%2Fqr.vitanova.network%2F&text=${text}`, '_blank'); - } -} diff --git a/src/app/pages/legacy-pay-page/legacy-pay-page.html b/src/app/pages/legacy-pay-page/legacy-pay-page.html deleted file mode 100644 index 963379b..0000000 --- a/src/app/pages/legacy-pay-page/legacy-pay-page.html +++ /dev/null @@ -1,93 +0,0 @@ -
-
- -
- -

{{ 'sbp.title' | translate }}

-

{{ 'sbp.subtitle' | translate }}

-
- -
- -
- -
- - -
- @if (error()) { - {{ error() }} - } -
- -
- 🇷🇺 - RUB - {{ 'sbp.currency_name' | translate }} -
- -
- - -
- - @if (nspkUrl()) { -
- SBP QR -

Отсканируйте QR-код в приложении вашего банка

-
- } - - -
- - -
-
diff --git a/src/app/pages/legacy-pay-page/legacy-pay-page.scss b/src/app/pages/legacy-pay-page/legacy-pay-page.scss deleted file mode 100644 index 7af3f29..0000000 --- a/src/app/pages/legacy-pay-page/legacy-pay-page.scss +++ /dev/null @@ -1,81 +0,0 @@ -@use './../../../shared' as *; - -.sbp-logo { - display: inline-flex; - align-items: center; - justify-content: center; - background: rgba(255, 255, 255, 0.15); - backdrop-filter: blur(8px); - border-radius: 16px; - padding: 12px 20px; - border: 1px solid rgba(255, 255, 255, 0.25); - margin-bottom: 14px; - - img { - height: 40px; - display: block; - - @media (max-width: 480px) { - height: 34px; - } - } -} - -.currency-badge { - display: flex; - align-items: center; - gap: 10px; - background: #f1f5f9; - border-radius: 12px; - padding: 12px 16px; - margin-bottom: 18px; - - &__flag { font-size: 22px; line-height: 1; } - &__code { font-size: 15px; font-weight: 700; color: #0f172a; } - &__name { font-size: 13px; color: #64748b; margin-left: auto; } -} - -.qr-pay { - display: flex; - flex-direction: column; - align-items: center; - gap: 12px; - margin-bottom: 20px; - - img { - border-radius: 12px; - border: 1px solid #e2e8f0; - display: block; - } - - &__hint { - font-size: 13px; - color: #64748b; - text-align: center; - margin: 0; - } -} - -.note-input { - width: 100%; - border: 2px solid #e2e8f0; - border-radius: 14px; - background: #f8fafc; - padding: 14px 16px; - font-size: 15px; - font-weight: 500; - color: #0f172a; - font-family: inherit; - resize: vertical; - outline: none; - transition: border-color 0.2s, box-shadow 0.2s, background 0.2s; - line-height: 1.5; - - &::placeholder { color: #cbd5e1; font-weight: 400; } - - &:focus { - border-color: #2563eb; - box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12); - background: #fff; - } -} diff --git a/src/app/pages/legacy-pay-page/legacy-pay-page.ts b/src/app/pages/legacy-pay-page/legacy-pay-page.ts deleted file mode 100644 index f8530e3..0000000 --- a/src/app/pages/legacy-pay-page/legacy-pay-page.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { Component, computed, inject, isDevMode, signal } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { ActivatedRoute } from '@angular/router'; -import { HttpClient } from '@angular/common/http'; -import { TranslatePipe } from '../../translate/translate.pipe'; -import { TranslationService } from '../../translate/translation.service'; - -interface LegacyPayResponse { - nspkurl?: string; -} - -/** - * Legacy SBP merchant payment flow. - * Activated when the root URL has `?id=`. - * Mirrors public/payment.html behaviour: - * POST https://qr.vitanova.network:567/qr - * { payment, amount, currency, id, note } -> { payload: '' } - * then window.location.href = payload. - */ -@Component({ - selector: 'app-legacy-pay-page', - imports: [FormsModule, TranslatePipe], - templateUrl: './legacy-pay-page.html', - styleUrl: './legacy-pay-page.scss' -}) -export class LegacyPayPage { - private http = inject(HttpClient); - private route = inject(ActivatedRoute); - private i18n = inject(TranslationService); - - private t(key: string): string { return this.i18n.translate(key); } - - private readonly LEGACY_API = isDevMode() - ? '/proxy/legacy-qr/qr' - : 'https://qr.vitanova.network:567/qr'; - - amount = signal(null); - note = signal(''); - error = signal(''); - loading = signal(false); - nspkUrl = signal(''); - - get isMobile(): boolean { - return window.innerWidth < 768; - } - - paymentId = signal(''); - - canPay = computed(() => { - const a = this.amount(); - return !!this.paymentId() && a !== null && a > 0 && !this.loading(); - }); - - constructor() { - const id = this.route.snapshot.queryParamMap.get('id') ?? ''; - this.paymentId.set(id); - } - - onAmountChange(value: number | null): void { - this.amount.set(value); - if (this.error()) this.error.set(''); - } - - onNoteChange(value: string): void { - this.note.set(value); - } - - pay(): void { - if (!this.canPay()) { - if (!this.paymentId()) { - this.error.set(this.t('errors.not_found')); - } else { - this.error.set(this.t('errors.invalid_amount')); - } - return; - } - this.error.set(''); - this.loading.set(true); - - const body = { - qrtype: 'QRDynamic', - amount: this.amount(), - currency: 'RUB', - partnerqrID: this.paymentId(), - qrDescription: this.note().trim() - }; - - this.http.post(this.LEGACY_API, body).subscribe({ - next: (res) => { - this.loading.set(false); - if (res?.nspkurl) { - if (this.isMobile) { - window.location.href = res.nspkurl; - } else { - this.nspkUrl.set(res.nspkurl); - } - } else { - this.error.set(this.t('errors.payment_failed')); - } - }, - error: () => { - this.loading.set(false); - this.error.set(this.t('errors.lookup_failed')); - } - }); - } -}