Post-funding flow

## Post-Funding Flow

The post-funding model, also known as direct funding, is a method where payables are created and approved before any funds are sent. You then generate a single funding invoice that is directly tied to a specific batch of approved payables.

This flow is ideal for paying exact invoice amounts and ensuring that incoming funds are immediately and automatically allocated to their intended payments without first sitting in a general workspace balance.

How It Works

The process involves preparing your payables first, then generating a funding request that covers their exact total.

  1. Create and Approve Payables: Your application or a user in the Lumanu web app first creates and approves one or more payables. At this stage, the payables are ready but are waiting for funds.
    • API Call: POST /payable to create a new payable.
    • Webhook Event: payable.created
    • API Call: PUT /payable/{id}/approve to approve an existing payable.
    • Webhook Event: payable.approved
  2. Initiate Direct Funding: Once you have a batch of approved payables, your application makes an API call to create a funding resource. The request body must include the IDs of the specific payables this funding will cover.
    • API Call: POST /funding (with an array of payable_ids)
  3. Invoice Payment: The Lumanu platform calculates the total amount from the associated payables, generates a single invoice, and sends it to the designated recipient (e.g., your finance department). The recipient pays the invoice.
  4. Automatic Payout: Once the invoice is paid and the funds have settled in the wallet account, you will need to match the deposit to the invoice.
    • Webhook Event: transfer.created fires when the funds have settled.
    • API Call: POST /funding/{id}/link-deposit if the transfer from the above webhook matches the deposit you are expecting for the invoice
    • Webhook Event: payable.paid as soon as the invoice is linked to the deposit, the payables attached to the invoice will start to be paid out.

Interaction Diagram

This diagram illustrates the sequence of events, highlighting how payables are created first and paid immediately upon the settlement of funds.

sequenceDiagram
    participant Client App as Client Application / Web App
    participant LumanuAPI as Lumanu API
    participant Finance as Finance Department

    Client App->>+LumanuAPI: 1. POST /payable
    LumanuAPI-->>-Client App: Payable object created
    note right of LumanuAPI: Webhook: `payable.created`

    Client App->>+LumanuAPI: 2. POST /payable/{id}/approve
    LumanuAPI-->>-Client App: Payable approved
    note right of LumanuAPI: Webhook: `payable.approved`

    Client App->>+LumanuAPI: 3. POST /funding (with payable_ids)
    LumanuAPI-->>-Client App: Funding object created

    LumanuAPI-->>Finance: 4. Sends Funding Invoice
    Finance-->>LumanuAPI: 5. Pays Invoice
    note right of LumanuAPI: Webhook: `transfer.created`
    Client App->>+LumanuAPI: 6. POST /funding/{id}/link-deposit

    note right of LumanuAPI: Lumanu automatically triggers payouts...
    note right of LumanuAPI: Webhook: `payable.paid`