Order validation
Introduction
This feature is optional and should only be used in cases where it is necessary as additional API calls will result in a potentially slower experience for the customer.
As a merchant, you have the option to validate an order before it is created, this feature can be useful for cases such as order stock validation or order comparison. This is how it works:
-
When an order is created with a create order session request you need to pass a validation URL in the request body under
settings.urls.validate
. -
Ledyer will make a POST request to the submitted URL and await a response before the order is created.
-
Ledyer waits for a request response. If no response is returned within 6 seconds the validation will be treated as valid. The response may also contain an order reference.
Possible response status codes:
200
: Ledyer will proceed with creating the order.
303
: Ledyer will redirect the user to a URL in the location header.
400
: Order will not be created and an error message will be shown in the checkout.
422
: Order will not be created and a custom error message will be shown in the checkout.
A common use case when sending a 303 response is to include query parameters with useful information such as reason for decline, order ID, etc.
Response
Depending on the outcome of the validation in the order system you can respond with either HTTP status code 200
, 400
or 422
.
reference
stringOptionalThe desired order reference to be set or edited. Max 50 characters.
title
stringOptionalThe custom message title.
body
stringOptionalThe custom message body.
- Ok response
- Decline response
- Decline response with custom message
HTTP 200
- will treat order as valid
// optionally update the order reference
{
"reference": "721672"
}
HTTP 400
- The order will be declined, and the customer will be notified that the purchase was unsuccessful.
HTTP 422
- The order will be declined, and the customer will be notified with a custom message.
{
"title": "We're sorry."
"body": "The green T-shirt is currently out of stock."
}