refactor: delete dead legacy payment code from ApiService
Verified zero remaining callers for each before deleting (grepped
src/app for every method name individually), not assumed from the
earlier commit's dead-code note.
Deleted from api.service.ts:
- createPayment() - legacy direct QR creation (POST {qrBaseUrl}/qr)
- createCartPayment() - legacy /cart payment creation, client-sent amount
- createPaymentIntent() - superseded by @marketplaces/payment's gateway
- checkCartPaymentStatus(), checkCartCardPaymentStatus(), checkPaymentStatus()
- legacy QR/card status polls, superseded by the same gateway
- resolvePaymentQrId/resolvePaymentQrUrl/resolvePaymentLink/
resolveBankPaymentUrl - QrCreateResponse field-normalization helpers,
no longer had a caller once the methods above were gone
- Types: QrCreateRequest, QrCreateResponse, CartPaymentRequest,
PaymentIntentRequest, QrDynamicStatusResponse
- Fields: qrBaseUrl, cartPaymentPartnerId - no longer read by anything
- Imports: HttpHeaders, environment - no longer used in this file
Did NOT touch createOrder() or createCheckoutSession() - both still have
live callers in cart.component.ts, confirmed before deciding what to keep.
cart.component.ts: corrected the createPaymentIntent() comment, which
referenced the deleted method/helper names, to name what actually got
deleted instead of what was merely "dead as of that commit."
docs/backend/FRONTEND-API-SURFACE-COMPLETE.md: moved the 4 now-deleted
QR/card endpoints out of the "still live" legacy table into a dated removal
note - the doc's own premise is "every endpoint this codebase currently
calls," so it was wrong to leave them listed as called once they weren't.
Legacy-undocumented count corrected 15->11, total 97->93.
Verified: production build succeeds (no dangling references), 247/247 unit
tests, arch:check clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -333,12 +333,12 @@ export class CartComponent implements OnDestroy {
|
||||
/**
|
||||
* Superseded api.service.ts's createPaymentIntent (POST
|
||||
* /api/v2/storefront/payments/intents, our own inferred contract) with
|
||||
* @marketplaces/payment's real, published one. That method and the
|
||||
* @marketplaces/payment's real, published one. That method, createPayment
|
||||
* (legacy /qr), createCartPayment (legacy /cart), checkCartPaymentStatus,
|
||||
* checkCartCardPaymentStatus, checkPaymentStatus, and the
|
||||
* QrCreateResponse-based resolvePaymentQrId/resolvePaymentQrUrl/
|
||||
* resolvePaymentLink/resolveBankPaymentUrl helpers on ApiService are dead
|
||||
* code as of this change - left in place rather than deleted in the same
|
||||
* pass that adds a new external dependency, so a revert doesn't also need
|
||||
* to resurrect deleted code.
|
||||
* resolvePaymentLink/resolveBankPaymentUrl helpers - all now deleted from
|
||||
* ApiService, confirmed dead first (zero remaining callers) before removal.
|
||||
*/
|
||||
private createPaymentIntent(
|
||||
session: import('../../services/api.service').CheckoutSessionResponse,
|
||||
|
||||
@@ -1,58 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable, timer } from 'rxjs';
|
||||
import { map, retry } from 'rxjs/operators';
|
||||
import { CategoryApiModel, DeliveryOption, Item, Subcategory } from '../models';
|
||||
import { normalizeDeliveryOption, normalizeOptionalNumber } from '../utils/normalization.utils';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { ApiConfigService } from '../core/config/api-config.service';
|
||||
|
||||
export interface QrCreateRequest {
|
||||
qrtype: 'QRDynamic';
|
||||
amount: number;
|
||||
currency: 'RUB';
|
||||
partnerqrID?: string;
|
||||
qrDescription?: string;
|
||||
Userid?: string;
|
||||
Reference?: string;
|
||||
RedirectUrl?: string;
|
||||
}
|
||||
|
||||
export interface QrCreateResponse {
|
||||
qrId?: string;
|
||||
qrID?: string;
|
||||
nspkID?: string;
|
||||
nspkId?: string;
|
||||
nspkurl?: string;
|
||||
orderID?: string;
|
||||
url?: string;
|
||||
bankUrl?: string;
|
||||
status?: string;
|
||||
qrStatus?: string;
|
||||
qrExpirationDate?: string;
|
||||
qrTTL?: number;
|
||||
payload?: string;
|
||||
Payload?: string;
|
||||
qrUrl?: string;
|
||||
partnerqrID?: string | number;
|
||||
partnerID?: string | number;
|
||||
partnerId?: string | number;
|
||||
PartnerID?: string | number;
|
||||
}
|
||||
|
||||
export interface CartPaymentRequest {
|
||||
amount: number;
|
||||
currency: string;
|
||||
siteuserID: string;
|
||||
siteorderID: string;
|
||||
redirectUrl: string;
|
||||
telegramUsername: string;
|
||||
paymentMethod: 'qr' | 'card';
|
||||
qrDescription?: string;
|
||||
customerID?: string;
|
||||
items: Array<{ itemID: number; price: number; name: string; quantity?: number; delivery?: DeliveryOption[] }>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Server-authoritative checkout. Contract: PHASE-1-MONEY-FX-PAYMENTS-CONTRACT.md §5.2.
|
||||
* No `amount` or `price` field anywhere in this pair - the backend prices
|
||||
@@ -88,18 +41,6 @@ export interface CheckoutSessionResponse {
|
||||
expiresAt: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* References checkoutSessionId only - the amount charged is read
|
||||
* server-side from the session, never re-sent by the client (contract §5.2).
|
||||
* merchantReference is PARTNER-PROVISIONING-API-CONTRACT.md's RoutingContext
|
||||
* field: our own correlation id, echoed back on every related event.
|
||||
*/
|
||||
export interface PaymentIntentRequest {
|
||||
checkoutSessionId: string;
|
||||
paymentMethod: 'qr' | 'card';
|
||||
merchantReference: string;
|
||||
}
|
||||
|
||||
export interface CreateOrderRequest {
|
||||
/**
|
||||
* No `price` field: the backend must price each line item from its own
|
||||
@@ -120,28 +61,10 @@ export interface CreateOrderResponse {
|
||||
currency: string;
|
||||
}
|
||||
|
||||
export interface QrDynamicStatusResponse {
|
||||
additionalInfo: string;
|
||||
paymentPurpose: string;
|
||||
amount: number;
|
||||
code: string;
|
||||
createDate: string;
|
||||
currency: string;
|
||||
order: string;
|
||||
status: string;
|
||||
qrId: string;
|
||||
transactionDate: string;
|
||||
transactionId: number;
|
||||
qrExpirationDate: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ApiService {
|
||||
private readonly qrBaseUrl = (environment as any).qrApiUrl as string;
|
||||
private readonly cartPaymentPartnerId = 'web-97ec-9c57-4dde-9037-3a68f7f83750';
|
||||
|
||||
private readonly retryConfig = {
|
||||
count: 2,
|
||||
delay: (_error: unknown, retryCount: number) => timer(Math.pow(2, retryCount) * 500)
|
||||
@@ -669,21 +592,6 @@ export class ApiService {
|
||||
return this.http.post<{ message: string }>(`${this.baseUrl}/items/${itemID}/questiion`, body);
|
||||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
createCartPayment(payload: CartPaymentRequest): Observable<QrCreateResponse> {
|
||||
return this.http.post<QrCreateResponse>(`${this.baseUrl}/cart`, payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a server-priced checkout session. Contract §5.2 - the frontend
|
||||
* sends offer ids and quantities only; the response carries the total that
|
||||
@@ -694,16 +602,6 @@ export class ApiService {
|
||||
return this.http.post<CheckoutSessionResponse>('/api/v2/storefront/checkout', payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a payment intent against an existing checkout session. Same
|
||||
* response shape as createCartPayment (QrCreateResponse) - this replaces
|
||||
* how the amount is determined, not the QR/card provider integration
|
||||
* itself, which Phase 1 does not redesign.
|
||||
*/
|
||||
createPaymentIntent(payload: PaymentIntentRequest): Observable<QrCreateResponse> {
|
||||
return this.http.post<QrCreateResponse>('/api/v2/storefront/payments/intents', payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the just-paid cart as a backoffice order (POST /orders). Fire-and-forget
|
||||
* from the caller's perspective - a failure here must never block the existing
|
||||
@@ -713,45 +611,6 @@ export class ApiService {
|
||||
return this.http.post<CreateOrderResponse>(`${this.baseUrl}/orders`, payload);
|
||||
}
|
||||
|
||||
checkCartPaymentStatus(qrId: string): Observable<QrDynamicStatusResponse> {
|
||||
return this.http.get<QrDynamicStatusResponse>(
|
||||
`${this.qrBaseUrl}/qr/dynamic/${this.cartPaymentPartnerId}/${encodeURIComponent(qrId)}`
|
||||
);
|
||||
}
|
||||
|
||||
checkCartCardPaymentStatus(orderId: string): Observable<QrDynamicStatusResponse> {
|
||||
return this.http.get<QrDynamicStatusResponse>(
|
||||
`${this.qrBaseUrl}/card/${this.cartPaymentPartnerId}/${encodeURIComponent(orderId)}`
|
||||
);
|
||||
}
|
||||
|
||||
checkPaymentStatus(partnerQrId: string, qrId: string): Observable<QrDynamicStatusResponse> {
|
||||
return this.http.get<QrDynamicStatusResponse>(
|
||||
`${this.qrBaseUrl}/qr/dynamic/${encodeURIComponent(partnerQrId)}/${encodeURIComponent(qrId)}`
|
||||
);
|
||||
}
|
||||
|
||||
resolvePaymentQrId(response: QrCreateResponse): string {
|
||||
return response.qrId ?? response.qrID ?? response.nspkID ?? response.nspkId ?? response.orderID ?? '';
|
||||
}
|
||||
|
||||
resolvePaymentLink(response: QrCreateResponse): string {
|
||||
return response.nspkurl ?? response.Payload ?? response.payload ?? response.qrUrl ?? '';
|
||||
}
|
||||
|
||||
resolveBankPaymentUrl(response: QrCreateResponse): string {
|
||||
return response.bankUrl ?? response.url ?? '';
|
||||
}
|
||||
|
||||
resolvePaymentQrUrl(response: QrCreateResponse): string {
|
||||
const paymentLink = this.resolvePaymentLink(response);
|
||||
if (paymentLink) {
|
||||
return `https://api.qrserver.com/v1/create-qr-code/?size=256x256&margin=8&data=${encodeURIComponent(paymentLink)}`;
|
||||
}
|
||||
|
||||
return response.qrUrl ?? '';
|
||||
}
|
||||
|
||||
submitPurchaseEmail(emailData: {
|
||||
email: string;
|
||||
phone?: string;
|
||||
|
||||
Reference in New Issue
Block a user