UNPKG

1.75 kBTypeScriptView Raw
1import { ErrorResponse, SubscriptionResponse, SuccessResponse } from "frontblock-generic/Service";
2import { Coin, Transaction, Account } from "frontblock-generic/Types";
3export declare class Payment<C extends Coin> {
4 readonly dollarValue: number;
5 readonly amount: number;
6 readonly currency: C;
7 readonly sendTo: Account;
8 received: number;
9 readonly createdAt: Date;
10 updatedAt: Date;
11 readonly paymentID: string;
12 status: PaymentStatus;
13 transactions: Transaction<C>[];
14 error?: string;
15 constructor(dollarValue: number, amount: number, currency: C, sendTo: Account, received?: number, createdAt?: Date, updatedAt?: Date, paymentID?: string);
16 addTransaction(tx: Transaction<C>): void;
17}
18export declare type PaymentStatus = "Created" | "Pending" | "Completed" | "Expired" | "Underpaid" | "Overpaid" | "Resolved" | "Canceled" | "Other (See error field)" | "Finalized";
19export interface PaymentService {
20 createUsdValuePayment<C extends Coin>(currency: C, amount: number): Promise<Payment<C> | ErrorResponse>;
21 createCryptoPayment<C extends Coin>(currency: C, amount: number): Promise<Payment<C> | ErrorResponse>;
22 getPayment(paymentID: string | Payment<Coin>): Promise<Payment<Coin> | ErrorResponse>;
23 cancelPayment(paymentID: string | Payment<Coin>): Promise<SuccessResponse | ErrorResponse>;
24 resolvePayment(paymentID: string | Payment<Coin>): Promise<SuccessResponse | ErrorResponse>;
25 finalizePayment(paymentID: string | Payment<Coin>): Promise<SuccessResponse | ErrorResponse>;
26 streamPayments(callback: (payment: Payment<Coin>) => void): Promise<SubscriptionResponse | ErrorResponse>;
27 cancelStream(uid: string | SubscriptionResponse): Promise<ErrorResponse | SuccessResponse>;
28}