# Tutorial: Receiving an Order Cancellation from the buyer

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

# Prerequisite

# Step 1: Register hook

Register a hook for the topic OrderCancellationReceived.

Webhook example:

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

# Step 2: Register capability in Peppol

You have to register the Order Cancellation as a capability in the SMP if you want to receive order cancellation 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 cancellation message is received a hook with topic OrderCancellationReceived will be sent.

Order Cancellation Received example

{
	"topic": "OrderCancellationReceived",
	"partyId": "NL:KVK:RECEIVER",
	"hookId": "111",
	"documentId": "b34d7213-dd81-4a23-8867-99b12b4ca39e",
	"refToDocumentId": "2a737b9e-a724-4153-8a86-4fb8f334db8b",
	"message": "'OrderCancellation' received.",
	"details": {
		"note": "Order cancelled.",
		"cancellationNote": "With reference to phone call",
		"orderReferenceId": "Order-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:OrderCancellation-2::OrderCancellation##urn:fdc:peppol.eu:poacc:trns:order_cancellation: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: Accept or reject the cancellation

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

*Order Cancellation Accepted Response example *

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