# Tutorial: Receiving an "Invoice Response Message" from the buyer

Once the sales invoice is successfully delivery to the receiver access point you can expect to get a hook with topic InvoiceResponseReceived. The InvoiceResponseReceived event message will contain the status of the document on the buyers behalf.

# Prerequisite

  • An invoice is successfully delivery, an InvoiceSent topic is provided.
  • The buyer supports the "Invoice Response Message".

# Step 1: Register hook

Register a hook for the topic InvoiceResponseReceived.

Webhook example:

{
   "id": "1",
   "name": "webhook",
   "action": "https://webhook.site/a81a0be5-8aad-4110-a40c-aa41a2c6e9ac#secureKey",
   "topics": [
     "InvoiceResponseReceived"
   ],
   "isActive": true
}

# Step 2: Register capability in Peppol

You have to register the IMR as a capability in the SMP if you want to receive status messages via Peppol.

We advise to do update your default Peppol configuration using PUT /api/v1-beta/peppol/config by putting the state of the invoicesResponse capability to "on". For example:

{  
  "capabilities": {
    "invoicesResponse": {
      "state": "on",
      "description": "IMR v3"
    }
  }
}

It is also possible to do this on per partyId using the `PUT /api/v1-beta/peppol/config/party/{partyId} endpoint. Read more about the the Peppol SMP.

# Step 3: Wait till the event arrives

Once the invoice response message is received a hook with topic InvoiceResponseReceived will be sent.

{
  "topic": "InvoiceResponseReceived",
  "partyId": "NL:KVK:seller",
  "hookId": "webhook",
  "documentId": "939a0813-a6f3-40eb-80b1-be10b126510e",
  "message": "'InvoiceResponse' received. Status: 'Reject' Reason: 'Invoice rejected due to validation errors. [REF] Purchase order number is invalid. The format should be POnnnnnn.'.",
  "details": {
    "note": "Invoice rejected due to validation errors.",
    "statusCode": "RE",
    "status": "Reject",
    "actions": {
      "nin": null
    },
    "reasons": {
      "ref": "Purchase order number is invalid. The format should be POnnnnnn."
    },
    "id": "PsbPingTestInvoice",
    "receiver": "NL:KVK:buyer"
  },
  "createdOn": "2021-05-21T20:02:02.9723352+00:00",
  "sentOn": "2021-05-21T20:02:03.046749+00:00"
}

Some useful fields of the received invoice response are:

Field Description
documentId Id that uniquely identifies the received Invoice response
message Summarize message
details.invoiceResponse Invoice response object

The hook contains all necessary information to process the response. However you could also download the received IMR using GET /api/v1-beta/{partyId}/generic/{documentId}/download.

© 2021 eConnect International B.V.