Skip to main content

Order validation

Introduction

important

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:

  1. 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.

  2. Ledyer will make a POST request to the submitted URL and await a response before the order is created.

  3. 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.

tip

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

stringOptional

The desired order reference to be set or edited. Max 50 characters.

title

stringOptional

The custom message title.

body

stringOptional

The custom message body.

HTTP 200 - will treat order as valid

  // optionally update the order reference
{
"reference": "721672"
}