# Tutorial: Receiving an Order Change from the buyer

After the buyer sends an order, the buyer may change the order if this is done before the order is prepared for delivery. The seller can either accept or reject the change with the Order Response.

# Prerequisite

# Step 1: Register hook

Register a hook for the topic OrderChangeReceived.

Webhook example:

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

# Step 2: Register capability in Peppol

You have to register the Order Change as a capability in the SMP if you want to receive order change messages via Peppol.

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

{  
  "capabilities": {
    "orderAdvanced": {
      "state": "on",
      "description": "PEPPOL Order transaction 3.3, PEPPOL Order change transaction 3.3, PEPPOL Order cancellation transaction 3.3"
    }
  }
}

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

# Step 3: Wait till the event arrives

Once the order change message is received a hook with topic OrderChangeReceived will be sent.

Order Change Received example

{
	"topic": "OrderChangeReceived",
	"partyId": "NL:KVK:RECEIVER",
	"hookId": "111",
	"documentId": "b34d7213-dd81-4a23-8867-99b12b4ca39e",
	"refToDocumentId": "2a737b9e-a724-4153-8a86-4fb8f334db8b",
	"message": "'OrderChange' received.",
	"details": {
		"note": "Changes according to Order response",
		"orderReferenceId": "Order-1",
    	"sequenceNumberId": "1",
		"id": "12115118",
		"protocol": "As4",
		"returnedMessageId": "b34d7213-dd81-4a23-8867-99b12b4ca39e@econnect.eu",
		"sender": "NL:KVK:SENDER",
		"accessPoint": "C=NL, O=eConnect International B.V., OU=PEPPOL TEST AP, CN=PNL000052",
		"documentTypeId": "urn:oasis:names:specification:ubl:schema:xsd:OrderChange-2::OrderChange##urn:fdc:peppol.eu:poacc:trns:order_change:3::2.3",
		"profileId": "urn:fdc:peppol.eu:poacc:bis:advanced_ordering:3",
		"receiver": "NL:KVK:RECEIVER",
		"messageId": "5156bf0f-9bf7-4687-9ae7-a678c7931a9b@econnect.eu",
		"refToMessageId": "2a737b9e-a724-4153-8a86-4fb8f334db8b@econnect.eu"
	},
	"createdOn": "2022-01-28T14:26:52.3980938+00:00",
	"sentOn": "2022-01-28T14:26:52.6101319+00:00"
}

# Step 4: Download the Order change

Use the DocumentId you got from the hook and call the GET api/v1-beta/{partyId}/generic/{documentId}/download API to download the Order Change. In the downloaded document you'll find the changes made to the order lines.

# Step 5: Accept or reject the change

Send an Order Response to the buyer to either accept or reject the change.

Order Change Accepted Response example

{
  "status": "AP",
  "note": "Order change accepted."
}
© 2024 eConnect International B.V.