Account Payment Matching


Overview

In addition of creating the Payment Ledger Entries manually, the system offers the posibility to match a payment into one or more ledger entries following the specified strategy.

We offer these strategies to do the matching:

  • ORDERED_LEDGER_ENTRIES the ledger entries are paid based on the creation time, regardless of the type (Account or Invoice level)
  • ORDERED_INVOICES_WITH_FEES_THEN_ACCOUNT_ENTRIES it orders the invoices based on the creation time, then the fees from those invoices, and at the end the Account Adjustments and Fees
  • ACCOUNT_ENTRIES_THEN_ORDERED_INVOICES_WITH_FEES it pays first the Account Adjustments and Fees, then the invoices with their Fees based on the creation time
  • CUSTOM_ORDERED_FEES the Fees are paid first, but they are ordered by type following the provided context in the request followed by the Invoices and Account Adjustments

Examples

This request will map 100 euros in the still non-paid Account Ledger Entries using the ORDERED_LEDGER_ENTRIES strategy

POST /v1/${clientId}/match_account_payment HTTP/1.1
Content-Type: application/json

[
  {
    "meta": {},
    "currency": "EUR",
    "totalAmount": 10000,
    "providerName": "trustly",
    "trackingId": "PROVIDER_TRACKING_ID",
    "paymentReference": "PAYMENT_REFERENCE",
    "accountReference": "ACCOUNT_REFERENCE",

    "matchStrategy": "ORDERED_LEDGER_ENTRIES"
  }
]

This request will map 100 euros in the still non-paid Account Ledger Entries using the CUSTOM_ORDERED_FEES strategy

POST /v1/${clientId}/match_account_payment HTTP/1.1
Content-Type: application/json

[
  {
    "meta": {},
    "currency": "EUR",
    "totalAmount": 10000,
    "providerName": "trustly",
    "trackingId": "PROVIDER_TRACKING_ID",
    "paymentReference": "PAYMENT_REFERENCE",
    "accountReference": "ACCOUNT_REFERENCE",

    "matchStrategy": "CUSTOM_ORDERED_FEES",
    "context": {
      "feeLedgerEntriesOrder": ["PENALTY_FEE", "PERCENT_DEBT_FEE"]
    }
  }
]

Where PENALTY_FEE and PERCENT_DEBT_FEE are custom Fee Ledger Entry Types

Notes

  • If the amount to pay is bigger than the remaining amount to pay, the system will throw an error and it won’t create any Payment Ledger Entry
  • In addition to the strategy, you can use productReference as part of the context to reduce the ledger entries that will be used for the payment matching.