Skip to main content

Post-order deal handling

Process to handle a deal after order placement/failures

The sequence diagram below illustrates the flow after order placement. The first part of the diagram is the same as in the fulfillment flow.

Capture requested event

{
"specversion": "1.0",
"data": {
"tenantId": "my_tenant",
"key": "key-for-my-own-integration",
"orderVersionId": "10",
"orderId": "ebuvUDP0i8i"
},
"dataContentType": "application/json",
"id": "7fd89d0b-76bd-42b8-bce3-1c149bddfa92",
"source": "https://api.futureordering.com",
"time": "2024-05-21T10:30:54.990511+00:00",
"type": "com.futureordering.order.deal.capture_requested"
}

When this event is received by the Loyalty Integration, it indicates that the order placement is successful. The deal/order should then be marked as captured in the external Loyalty system to register points for the user and mark any discount codes/deals as used. Once this is done in the Loyalty system, all deals for the order should be marked as captured in Future Ordering. This can be done by using the /capture action endpoint or one of the PATCH endpoints.

  • POST /orders/{order-id}/deals/{deal-id}/capture
    • No request body needed. Response code 204 No Content
  • PATCH /orders/{order-id}/deals

PATCH request for isCaptured:

{
"a0e34dd7-1052-4918-9896-2930d4c121e1": {
"isCaptured": true
}
}

Response for PATCH request:

{
"statusCode": "successful",
"message": "Patched",
"innerCode": null,
"successful": true,
"outerCode": 200
}

Annulment requested event

{
"specversion": "1.0",
"data": {
"tenantId": "my_tenant",
"key": "key-for-my-own-integration",
"orderVersionId": "10",
"orderId": "ebuvUDP0i8i"
},
"dataContentType": "application/json",
"id": "7fd89d0b-76bd-42b8-bce3-1c149bddfa92",
"source": "https://api.futureordering.com",
"time": "2024-05-21T10:30:54.990511+00:00",
"type": "com.futureordering.order.deal.annulment_requested"
}

When this event is received by the Loyalty Integration, it indicates that the order placement has failed or encountered a similar issue. In such cases, the deal/order should be marked as annulled in the external Loyalty system to void any discount codes/deals. This can be done by using the action endpoint /annul or one of the PATCH endpoints.

  • POST /orders/{order-id}/deals/{deal-id}/annul
    • No request body needed. Response code 204 No Content
  • PATCH /orders/{order-id}/deals

PATCH request for isAnnulled:

{
"a0e34dd7-1052-4918-9896-2930d4c121e1": {
"isAnnulled": true
}
}

Response for PATCH request:

{
"statusCode": "successful",
"message": "Patched",
"innerCode": null,
"successful": true,
"outerCode": 200
}