Order validation
/order_validation
Validate order¶
Target audience: Developers
Release version: 4.4.0
Introduction¶
This endpoint returns a true/false value whether the user can purchase a package, and if not, a reason and code explaining why.
URI¶
| Environment | URI |
|---|---|
| Stage | https://payway-api.stage.adeprimo.se/external/api/v2/order_validation |
| Production | https://backend.worldoftulo.com/external/api/v2/order_validation |
Requirements¶
| Identity | Scope |
|---|---|
| No | /external/order_validation/r |
Parameters¶
| Name | Required | Description |
|---|---|---|
| product_code | Yes | The code of the package that the user should be checked against |
| account_id | No* | The id of the account that should be checked |
| date_of_birth | No* | The date of birth of the user (DateTime format) |
| ssn | No* | The social security number of the user |
Validation Parameter Requirement
Exactly one of account_id, date_of_birth, or ssn must be provided. You cannot omit all three, nor can you provide more than one.
Curl Examples¶
Check eligibility using account_id¶
curl --request GET \
--url https://payway-api.stage.adeprimo.se/external/api/v2/order_validation?account_id=abc123&product_code=adeprimo_test_package \
--header 'accept: application/json' \
--header 'authorization: Bearer token' \
Check eligibility using date_of_birth¶
curl --request GET \
--url 'https://payway-api.stage.adeprimo.se/external/api/v2/order_validation?date_of_birth=1990-01-15T00:00:00Z&product_code=adeprimo_test_package' \
--header 'accept: application/json' \
--header 'authorization: Bearer token' \
Check eligibility using ssn¶
curl --request GET \
--url https://payway-api.stage.adeprimo.se/external/api/v2/order_validation?ssn=199001151234&product_code=adeprimo_test_package \
--header 'accept: application/json' \
--header 'authorization: Bearer token' \
Response¶
| Field | Description |
|---|---|
| purchase_allowed | Whether the user is allowed to purchase the requested package. |
| can_purchase_fallback_package | Whether the user could purchase the fallback package instead. This checks the provided user information against the fallback package's own order validation (if one is configured) to ensure the user is not too young or too old for the package they would end up in next. false when no fallback package is configured. When the fallback package has no order validation of its own there is no age restriction and this is true. |
| reason | Code explaining why purchase_allowed is false. Possible values: too_young, too_old. |
| message | Human readable explanation of the reason. |
| fallback_package_code | The product code of the fallback package the user should be offered instead, when configured. |
Example response if user can purchase package¶
HTTP 200
{
"item": {
"purchase_allowed": true,
"can_purchase_fallback_package": false,
"reason": null,
"message": null,
"fallback_package_code": null
}
}
Example response if user cannot purchase package¶
HTTP 200
{
"item": {
"purchase_allowed": false,
"can_purchase_fallback_package": false,
"reason": "too_young",
"message": "User is too young to purchase this package",
"fallback_package_code": null
}
}
Example response if user cannot purchase the package but can purchase the fallback package¶
HTTP 200
{
"item": {
"purchase_allowed": false,
"can_purchase_fallback_package": true,
"reason": "too_old",
"message": "User is too old to purchase this package",
"fallback_package_code": "youth_package"
}
}
Errors¶
This API uses the common error conventions of the Payway API