UNPKG

@vulog/aima-billing

Version:

Invoice management, credits, wallets, and refunds.

28 lines (23 loc) 821 B
import { Client } from '@vulog/aima-client'; import { z } from 'zod'; import { Invoice } from './types'; const schema = z.object({ invoiceId: z.string().trim().min(1).uuid(), }); /** * Retry an invoices payment stuck in REFUSED and ERROR status, move the status to PENDING or PENDING_MANUAL_PAYMENT */ export const retryPayment = async (client: Client, invoiceId: string): Promise<Invoice> => { const result = schema.safeParse({ invoiceId }); if (!result.success) { throw new TypeError('Invalid args', { cause: result.error.issues, }); } return client .post<Invoice>( `/boapi/proxy/user/billing/fleets/${client.clientOptions.fleetId}/invoices/${result.data.invoiceId}/retry-payment`, {} ) .then(({ data }) => data); };