# Tutorial: Responding to the buyer via "Order Response"
Once an incoming order is accepted by the PSB an OrderReceived
topic is broadcasted and will be delivered to your hooks
. The PSB only accepts orders that are technically correct. However a problem could still exists on business level, for example the agreed prices are incorrect, or the ordered item is no longer in stock. These kind of messages, together with status messages can be send back to the buyer via the POST /api/v1/{partyId}/salesOrder/{documentId}/response
endpoint.
# Prerequisite
You have received an order via a hook with the topic
OrderReceived
. If not, follow the Tutorial: Receiving Orders.The buyer supports the Order Response (Advanced). This can be checked using the
GET /api/v1/peppol/deliveryOption?partyIds={buyerPartyId}&documentFamily=orderResponse
.Or by using this form:
# Step 1: Start with an acknowledgement
The flow always start with an acknowledgement message, whatever the outcome. Acknowledgement means that you have received a readable order message that can be understood and submitted for processing.
Acknowledgement example:
{
"status": "AB",
"note": "Order successfully received and delivered into the administration."
}
# Step 2: Status update
Update about the process of the order. The next minimum status must be a "Reject", "Approved" or "Conditionally Accepted".
Rejection example:
{
"status": "RE",
"note": "Order rejected due to validation errors."
}
Approval example:
{
"status": "AP",
"note": "Order accepted and will be delivered on due date."
}
# Step 3: Retrieve the status of the response transaction
When the response is successfully received by the receiver access point a topic OrderResponseSent
will be broadcasted. However in case the buyer doesn't support the Order Response Message the topic OrderResponseSentError
will be used.
The available topics are:
- OrderResponseSent
- OrderResponseSentError
- OrderResponseSentRetry
{
"topic": "OrderResponseSent",
"partyId": "NL:KVK:seller",
"hookId": "1",
"documentId": "de548d14-8b84-4f7d-88fc-09b2fedf54f3",
"message": "'OrderResponse' successfully sent: 'e12b19a3-30ed-4c26-b712-5112f6b24ceb@econnect.eu'.",
"details": {
"note": "Order approved.",
"statusCode": "AP",
"status": "Approved"
}
}