release: @marketplaces/payment 0.1.0 (5ffc1b1)
This commit is contained in:
104
dist/types/marketplaces-payment.d.ts
vendored
Normal file
104
dist/types/marketplaces-payment.d.ts
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
import * as _angular_core from '@angular/core';
|
||||
import { InjectionToken, EnvironmentProviders } from '@angular/core';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
type PaymentMethod = 'qr' | 'card' | 'sbp' | 'yandex-pay';
|
||||
type PaymentStatus = 'created' | 'pending' | 'authorized' | 'paid' | 'failed' | 'cancelled' | 'expired';
|
||||
/** Central payment API resolves amount/currency/routing from this server checkout id. */
|
||||
interface PaymentRequest {
|
||||
checkoutSessionId: string;
|
||||
returnUrl?: string;
|
||||
metadata?: Readonly<Record<string, string>>;
|
||||
}
|
||||
interface PaymentAttempt {
|
||||
paymentId: string;
|
||||
method: PaymentMethod;
|
||||
status: PaymentStatus;
|
||||
action?: {
|
||||
type: 'redirect' | 'qr';
|
||||
url: string;
|
||||
};
|
||||
failureMessage?: string;
|
||||
}
|
||||
interface PaymentResult extends PaymentAttempt {
|
||||
status: 'paid' | 'authorized';
|
||||
}
|
||||
interface PaymentFailure {
|
||||
method: PaymentMethod;
|
||||
code: 'configuration' | 'backend' | 'declined' | 'expired' | 'popup_blocked';
|
||||
message: string;
|
||||
cause?: unknown;
|
||||
}
|
||||
|
||||
declare class MarketplacesPaymentComponent {
|
||||
readonly qr: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
||||
readonly card: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
||||
readonly sbp: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
||||
readonly yandexPay: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
||||
readonly request: _angular_core.InputSignal<PaymentRequest>;
|
||||
readonly title: _angular_core.InputSignal<string>;
|
||||
readonly completed: _angular_core.OutputEmitterRef<PaymentResult>;
|
||||
readonly paymentError: _angular_core.OutputEmitterRef<PaymentFailure>;
|
||||
readonly cancelled: _angular_core.OutputEmitterRef<void>;
|
||||
readonly busy: _angular_core.WritableSignal<boolean>;
|
||||
readonly error: _angular_core.WritableSignal<PaymentFailure | null>;
|
||||
readonly attempt: _angular_core.WritableSignal<PaymentAttempt | null>;
|
||||
readonly qrImage: _angular_core.WritableSignal<string | null>;
|
||||
readonly actionUrl: _angular_core.WritableSignal<string | null>;
|
||||
private readonly gateway;
|
||||
private readonly config;
|
||||
private poll?;
|
||||
constructor();
|
||||
pay(method: PaymentMethod): void;
|
||||
cancel(): void;
|
||||
private handleCreated;
|
||||
private handleStatus;
|
||||
private finish;
|
||||
private fail;
|
||||
private isFailure;
|
||||
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MarketplacesPaymentComponent, never>;
|
||||
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MarketplacesPaymentComponent, "mp-payment, marketplaces-payment", never, { "qr": { "alias": "qr"; "required": false; "isSignal": true; }; "card": { "alias": "card"; "required": false; "isSignal": true; }; "sbp": { "alias": "sbp"; "required": false; "isSignal": true; }; "yandexPay": { "alias": "yandexPay"; "required": false; "isSignal": true; }; "request": { "alias": "request"; "required": true; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; }, { "completed": "completed"; "paymentError": "paymentError"; "cancelled": "cancelled"; }, never, never, true, never>;
|
||||
}
|
||||
|
||||
interface MarketplacesPaymentConfig {
|
||||
/** Central payment service URL. It is not the tenant API URL. */
|
||||
apiUrl: string;
|
||||
marketplaceDomain?: string | (() => string);
|
||||
paymentsPath?: string;
|
||||
pollIntervalMs?: number;
|
||||
}
|
||||
declare const MARKETPLACES_PAYMENT_CONFIG: InjectionToken<MarketplacesPaymentConfig>;
|
||||
declare function provideMarketplacesPayment(config: MarketplacesPaymentConfig): EnvironmentProviders;
|
||||
|
||||
declare const MARKETPLACE_DOMAIN_HEADER = "X-Marketplace-Domain";
|
||||
declare function normalizeMarketplaceDomain(domain: string): string;
|
||||
declare class PaymentMarketplaceContext {
|
||||
private readonly config;
|
||||
domain(): string;
|
||||
headers(): HttpHeaders;
|
||||
static ɵfac: _angular_core.ɵɵFactoryDeclaration<PaymentMarketplaceContext, never>;
|
||||
static ɵprov: _angular_core.ɵɵInjectableDeclaration<PaymentMarketplaceContext>;
|
||||
}
|
||||
|
||||
interface MarketplacesPaymentGateway {
|
||||
create(method: PaymentMethod, request: PaymentRequest): Observable<PaymentAttempt>;
|
||||
status(paymentId: string, method: PaymentMethod): Observable<PaymentAttempt>;
|
||||
cancel(paymentId: string): Observable<void>;
|
||||
}
|
||||
declare const MARKETPLACES_PAYMENT_GATEWAY: InjectionToken<MarketplacesPaymentGateway>;
|
||||
declare class HttpMarketplacesPaymentGateway implements MarketplacesPaymentGateway {
|
||||
private readonly http;
|
||||
private readonly config;
|
||||
private readonly context;
|
||||
create(method: PaymentMethod, request: PaymentRequest): Observable<PaymentAttempt>;
|
||||
status(paymentId: string, method: PaymentMethod): Observable<PaymentAttempt>;
|
||||
cancel(paymentId: string): Observable<void>;
|
||||
private baseUrl;
|
||||
private handle;
|
||||
static ɵfac: _angular_core.ɵɵFactoryDeclaration<HttpMarketplacesPaymentGateway, never>;
|
||||
static ɵprov: _angular_core.ɵɵInjectableDeclaration<HttpMarketplacesPaymentGateway>;
|
||||
}
|
||||
|
||||
export { HttpMarketplacesPaymentGateway, MARKETPLACES_PAYMENT_CONFIG, MARKETPLACES_PAYMENT_GATEWAY, MARKETPLACE_DOMAIN_HEADER, MarketplacesPaymentComponent, PaymentMarketplaceContext, normalizeMarketplaceDomain, provideMarketplacesPayment };
|
||||
export type { MarketplacesPaymentConfig, MarketplacesPaymentGateway, PaymentAttempt, PaymentFailure, PaymentMethod, PaymentRequest, PaymentResult, PaymentStatus };
|
||||
Reference in New Issue
Block a user