Add Payment to an Invoice

Use our API to add a payment to an invoice.

This guide shows you how to add a payment to an invoice using the Invoice API resource. You can add a check or cash payment to either a saved or outstanding invoice. You cannot manually add credit card payments to an invoice. See Add Payment to an Invoice in our API Reference for field definitions.


Prerequisites

  1. See Create a Sandbox Account to sign up and log in to the Maast Manager portal.

  2. Follow the steps in Get Your API Credentials to save a sandbox ID and API key.

  3. See Authentication to format the credentials and generate your API token. (Alternatively, use the credentials as-is to test this endpoint with our 'Try It!' feature.)

  4. Follow the steps in the Create an Invoice guide to draft and save an invoice. Save the invoice_id value from the request response.


Implement

  1. Write a POST request. For the request endpoint, include the invoice_id value between /invoice/ and /payments. The resulting endpoint is /platform/invoice/invoice_id/payments, where the value replaces invoice_id.

  2. In the request body, include the payment type, the amount paid, and the date of payment. These are required. You can also add a description.

Once configured, your request will resemble the following sample code:

curl --request POST \
     --url https://api-test.maast.com/platform/invoice/22085/payments \
     --header 'accept: application/json' \
     --header 'authorization: Basic OjllZGVjMjFhMzFjMHh5ejc4OWUzMGEzNDE2YWJjMTIz' \
     --header 'content-type: application/json' \
     --data '
{
     "type": "CHECK",
     "amt_paid": 10.45,
     "date_payment": "2024-01-01T00:00:00.000Z",
     "description": "Check #3456"
}
'

Integrate

Send the configured request to your custom endpoint.

Maast will return a response like the code below:

{
  "code": 0,
  "message": "Success",
  "data": {
    "payment_id": 12457,
    "merchant_id": 212000000001,
    "type": "CHECK",
    "amt_paid": 10.45,
    "description": "Check #3456",
    "invoice_id": 22085,
    "date_payment": "2024-01-01T00:00:00.000Z",
    "status": "PAID",
    "tran_currency": "840",
    "tran_status": ""
  }
}

Check the code field in the request response: 0 confirms that you have successfully sent the invoice. If the value is something other than 0, check Platform API Response Codes in Reference.

Check the payment_id field and save its value to your records. This is the unique ID assigned to this invoice payment.

See Add Payment to an Invoice in API Reference for response field definitions.

🚧

Save the Payment ID

Be sure to save the payment_id value from the request response to manage invoice payments.


Test and Go Live

See our Test and Go Live guide to test your API integration and to start transacting with an active production account.