UNPKG

@vulog/aima-billing

Version:

87 lines (80 loc) 2.68 kB
import { Client } from '@vulog/aima-client'; import { UUID } from 'crypto'; type ChargeProductInfo = { productId: string; serviceId?: string; amount: number; userId: string; entityId: string; subscriptionId?: string; productNotes?: string; originId?: string; chargeProductRequestId?: string; }; type Invoice = { id: string; sequence: number; refundSequence?: number; userId: string; pricingId?: string; tripId?: string; invoiceDate: string; updateDate: string; fleetId: string; invoiceYear: number; invoicesStatus: 'PENDING' | 'PAID' | 'REFUSED' | 'ERROR' | 'REFUNDED' | 'CANCELLED' | 'PENDING_EXTERNAL_PAYMENT' | 'PENDING_MANUAL_PAYMENT' | 'PENDING_AUTHENTICATION' | 'MOP_MISSING'; amount: number; productId?: string; currency: string; serviceId?: string; tokenId?: string; entityId: string; amountPayWithSystemCredit?: number; attempts: number; pspName?: string; pspReference: string; withTaxRefundAmount: number; isRefunded?: boolean; paymentInProgress: boolean; subscriptionId?: string; paymentDate?: string; externalPaymentRequesterId?: string; externalPaymentNotes?: string; isPaidExternally?: boolean; refundInProgress?: boolean; originId?: string; originRole?: string; pspIdempotency: string; paidExternally?: boolean; refunded?: boolean; productTaxIncluded?: boolean; pspReferencePreAuth?: string; amountPreAuth?: number; preAuthEnabled?: boolean; [key: string]: any; }; type Credit = { initialAmount: number; validityStartDate: string; validityEndDate: string; notes: string; discountCategory: 'CREDITS' | 'PERCENTAGE'; oneTimeUsage: boolean; id: UUID; availableAmount: number; usedAmount: number; originId: UUID; entityId: UUID; creditAlreadyUsed: boolean; updateDate: string; type: 'LOCAL' | 'GLOBAL' | 'PERIODIC'; usage: 'TRIP' | 'REGISTRATION' | 'PRODUCTS' | 'ALL'; [key: string]: any; }; declare const chargeProduct: (client: Client, info: ChargeProductInfo) => Promise<Invoice>; declare const getUserCreditsByEntityId: (client: Client, id: string) => Promise<Credit>; interface Payload extends Omit<Credit, 'id' | 'availableAmount' | 'usedAmount' | 'originId' | 'creditAlreadyUsed' | 'updateDate'> { } declare const addCredits: (client: Client, payload: Payload) => Promise<Credit>; declare const getInvoiceById: (client: Client, id: string) => Promise<Invoice>; export { type ChargeProductInfo, type Credit, type Invoice, addCredits, chargeProduct, getInvoiceById, getUserCreditsByEntityId };